Add auto append text for punctuation
This commit is contained in:
parent
e31f6587ee
commit
938b5eff70
3 changed files with 14 additions and 5 deletions
|
|
@ -14,7 +14,6 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
import argparse
|
import argparse
|
||||||
import asyncio
|
|
||||||
import io
|
import io
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
|
|
@ -131,9 +130,7 @@ def do_synthesis_proc(args: argparse.Namespace, request_queue: Queue):
|
||||||
_LOGGER.exception("Error during inference")
|
_LOGGER.exception("Error during inference")
|
||||||
|
|
||||||
# Signal error on main loop
|
# Signal error on main loop
|
||||||
item.loop.call_soon_threadsafe(
|
item.loop.call_soon_threadsafe(item.future.set_exception, e)
|
||||||
item.future.set_exception, e
|
|
||||||
)
|
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
_LOGGER.exception("Unexpected error in inference thread")
|
_LOGGER.exception("Unexpected error in inference thread")
|
||||||
|
|
|
||||||
|
|
@ -262,7 +262,13 @@ class InferenceConfig:
|
||||||
noise_w: float = 0.8
|
noise_w: float = 0.8
|
||||||
|
|
||||||
minor_break_ms: typing.Optional[int] = None
|
minor_break_ms: typing.Optional[int] = None
|
||||||
|
"""Automatically add milliseconds of silence after a minor break (comma)"""
|
||||||
|
|
||||||
major_break_ms: typing.Optional[int] = None
|
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
|
@dataclass
|
||||||
|
|
|
||||||
|
|
@ -364,13 +364,19 @@ class Mimic3TextToSpeechSystem(TextToSpeechSystem):
|
||||||
def begin_utterance(self):
|
def begin_utterance(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# pylint: disable=arguments-differ
|
|
||||||
def speak_text(self, text: str, text_language: typing.Optional[str] = None):
|
def speak_text(self, text: str, text_language: typing.Optional[str] = None):
|
||||||
voice = self._get_or_load_voice(self.voice)
|
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
|
minor_break_ms = voice.config.inference.minor_break_ms
|
||||||
major_break_ms = voice.config.inference.major_break_ms
|
major_break_ms = voice.config.inference.major_break_ms
|
||||||
|
|
||||||
|
# Process chunks
|
||||||
for sent_phonemes, break_type in voice.text_to_phonemes(
|
for sent_phonemes, break_type in voice.text_to_phonemes(
|
||||||
text, text_language=text_language
|
text, text_language=text_language
|
||||||
):
|
):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue