speech_to_text/create_subtitle_files.py
def generate_block_start_ends(
    letters: List[LetterIdx],
) -> Generator[int, None, None]:
    """
    for better visualization in video cut aligned transcript into segments separated ideally by pauses,
    so that transcitions between subtitle-block are not too anoying
    """
    block_len: int = 0
    last_end = 0
    for k, l in enumerate(letters):
        block_len += 1
        force_break = l.letter == FORCE_BREAK
        if force_break:
            print(f"DEBUG: foreced break after: {l.letter}")
        if l.letter == " " or force_break:
            next_one = min(
                k + 2, len(letters)
            )  # next token might start with vocal, heuristic to get at "real" start of token
            is_pause = letters[next_one].r_idx - l.r_idx > 0.25 * TARGET_SAMPLE_RATE
            if (is_pause and block_len > 10 or block_len > 90) or force_break:
                yield last_end, l.r_idx
                last_end = l.r_idx + 10
                block_len = 0
    yield last_end, l.r_idx

    for better visualization in video cut aligned transcript into segments separated ideally by pauses,
    so that transcitions between subtitle-block are not too anoying
    
for better visualization in video cut aligned transcript into segments separated ideally by pauses,
so that transcitions between subtitle-block are not too anoying
for better visualization in video cut aligned transcript into segments separated ideally by pauses so that transcitions between subtitle - block are not too anoying
def generate_block_start_ends(
    letters: List[LetterIdx],
) -> Generator[int, None, None]:
    block_len: int = 0
    last_end = 0
    for k, l in enumerate(letters):
        block_len += 1
        force_break = l.letter == FORCE_BREAK
        if force_break:
            print(f"DEBUG: foreced break after: {l.letter}")
        if l.letter == " " or force_break:
            next_one = min(
                k + 2, len(letters)
            )  
            is_pause = letters[next_one].r_idx - l.r_idx > 0.25 * TARGET_SAMPLE_RATE
            if (is_pause and block_len > 10 or block_len > 90) or force_break:
                yield last_end, l.r_idx
                last_end = l.r_idx + 10
                block_len = 0
    yield last_end, l.r_idx
def generate_block_start_ends ( letters : List [ LetterIdx ] , ) -> Generator [ int , None , None ] : block_len : int = 0 last_end = 0 for k , l in enumerate ( letters ) : block_len += 1 force_break = l . letter == FORCE_BREAK if force_break : print ( f"DEBUG: foreced break after: {l.letter}" ) if l . letter == " " or force_break : next_one = min ( k + 2 , len ( letters ) ) is_pause = letters [ next_one ] . r_idx - l . r_idx > 0.25 * TARGET_SAMPLE_RATE if ( is_pause and block_len > 10 or block_len > 90 ) or force_break : yield last_end , l . r_idx last_end = l . r_idx + 10 block_len = 0 yield last_end , l . r_idx
for better visualization in video cut aligned transcript into segments separated ideally by pauses,
so that transcitions between subtitle-block are not too anoying
for better visualization in video cut aligned transcript into segments separated ideally by pauses so that transcitions between subtitle - block are not too anoying
"""
    for better visualization in video cut aligned transcript into segments separated ideally by pauses,
    so that transcitions between subtitle-block are not too anoying
    """ # next token might start with vocal, heuristic to get at "real" start of token
letters
List[LetterIdx]