Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Utils

get_sentence_based_splitter

get_sentence_based_splitter(min_sentence_length:int=20,)->Callable[[str],tuple[str,str]]

Returns a function that splits text into chunks based on sentence boundaries.

Parameters:

NameTypeDescriptionDefault
min_sentence_lengthint

The minimum length of a sentence to be included in a chunk.

20

Returns:

TypeDescription
Callable[[str],tuple[str,str]]

A function that splits text into chunks based on sentence boundaries.

Source code insrc/agents/voice/utils.py
defget_sentence_based_splitter(min_sentence_length:int=20,)->Callable[[str],tuple[str,str]]:"""Returns a function that splits text into chunks based on sentence boundaries.    Args:        min_sentence_length: The minimum length of a sentence to be included in a chunk.    Returns:        A function that splits text into chunks based on sentence boundaries.    """defsentence_based_text_splitter(text_buffer:str)->tuple[str,str]:"""        A function to split the text into chunks. This is useful if you want to split the text into        chunks before sending it to the TTS model rather than waiting for the whole text to be        processed.        Args:            text_buffer: The text to split.        Returns:            A tuple of the text to process and the remaining text buffer.        """sentences=re.split(r"(?<=[.!?])\s+",text_buffer.strip())iflen(sentences)>=1:combined_sentences=" ".join(sentences[:-1])iflen(combined_sentences)>=min_sentence_length:remaining_text_buffer=sentences[-1]returncombined_sentences,remaining_text_bufferreturn"",text_bufferreturnsentence_based_text_splitter

[8]ページ先頭

©2009-2025 Movatter.jp