diff --git a/mimic3_http/synthesis.py b/mimic3_http/synthesis.py index 73bc899..35abf81 100644 --- a/mimic3_http/synthesis.py +++ b/mimic3_http/synthesis.py @@ -14,7 +14,6 @@ # along with this program. If not, see . # import argparse -import asyncio import io import logging import threading @@ -131,9 +130,7 @@ def do_synthesis_proc(args: argparse.Namespace, request_queue: Queue): _LOGGER.exception("Error during inference") # Signal error on main loop - item.loop.call_soon_threadsafe( - item.future.set_exception, e - ) + item.loop.call_soon_threadsafe(item.future.set_exception, e) except Exception: _LOGGER.exception("Unexpected error in inference thread") diff --git a/mimic3_tts/config.py b/mimic3_tts/config.py index 58c87ed..5193499 100644 --- a/mimic3_tts/config.py +++ b/mimic3_tts/config.py @@ -262,7 +262,13 @@ class InferenceConfig: noise_w: float = 0.8 minor_break_ms: typing.Optional[int] = None + """Automatically add milliseconds of silence after a minor break (comma)""" + major_break_ms: typing.Optional[int] = None + """Automatically add milliseconds of silence after a major break (period)""" + + auto_append_text: typing.Optional[str] = None + """Automatically append text to the end of an utterance if not present (e.g., punctuation)""" @dataclass diff --git a/mimic3_tts/tts.py b/mimic3_tts/tts.py index ed41248..b494869 100644 --- a/mimic3_tts/tts.py +++ b/mimic3_tts/tts.py @@ -364,13 +364,19 @@ class Mimic3TextToSpeechSystem(TextToSpeechSystem): def begin_utterance(self): pass - # pylint: disable=arguments-differ def speak_text(self, text: str, text_language: typing.Optional[str] = None): voice = self._get_or_load_voice(self.voice) + # Automatically append text (e.g., punctuation) if not present + append_text = voice.config.inference.auto_append_text + if append_text and (not text.endswith(append_text)): + text += append_text + + # Automatic silence after major/minor breaks (optional) minor_break_ms = voice.config.inference.minor_break_ms major_break_ms = voice.config.inference.major_break_ms + # Process chunks for sent_phonemes, break_type in voice.text_to_phonemes( text, text_language=text_language ):