Skip to content

Commit 034b401

Browse files
committed
Set up the TTS manager to use the pattern defined in the class def
1 parent de009e0 commit 034b401

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tts_manager.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def __init__(self, parent_client, verbose=False):
2626
self.verbose = verbose
2727
self.stop_playback = False
2828
self.playback_stopped = threading.Event()
29-
self.sentence_pattern = re.compile(r'(?<!\w\.\w.)(?<![A-Z][a-z]\.)(?<=\.|\?|\!)(?=\s|$)|\n')
29+
self.sentence_pattern = r'(?<!\w\.\w.)(?<![A-Z][a-z]\.)(?<=\.|\?|\!)(?=\s|$)|\n'
3030

3131
## NOTE: For now all TTS services need to return wav files.
3232
if self.service == "openai":
@@ -56,7 +56,7 @@ def split_sentences(self, text):
5656
"""
5757
Split the text into sentences and remove empty ones.
5858
"""
59-
sentences = re.split(r'(?<!\w\.\w.)(?<![A-Z][a-z]\.)(?<=\.|\?|\!)(?=\s|$)|\n', text)
59+
sentences = re.split(self.sentence_pattern, text)
6060
# Ensure sentences end with punctuation and remove empty sentences
6161
sentences = [s + '.' if not s.strip().endswith(('.', '!', '?')) else s for s in sentences if s.strip()]
6262

0 commit comments

Comments
 (0)