From e1a4605a7efd18516fcd1e874346a3f2e5611917 Mon Sep 17 00:00:00 2001 From: Ajay Raj Date: Wed, 2 Aug 2023 19:05:48 -0700 Subject: [PATCH 1/2] set trailing silence to be as low as possible --- vocode/streaming/synthesizer/azure_synthesizer.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vocode/streaming/synthesizer/azure_synthesizer.py b/vocode/streaming/synthesizer/azure_synthesizer.py index 23f81a64f..dd7f3e711 100644 --- a/vocode/streaming/synthesizer/azure_synthesizer.py +++ b/vocode/streaming/synthesizer/azure_synthesizer.py @@ -184,6 +184,11 @@ def create_ssml( "styledegree", str(bot_sentiment.degree * 2) ) # Azure specific, it's a scale of 0-2 voice_root = styled + silence = ElementTree.SubElement( + voice_root, "{%s}silence" % NAMESPACES.get("mstts") + ) + silence.set("value", "500ms") + silence.set("type", "Tailing-exact") prosody = ElementTree.SubElement(voice_root, "prosody") prosody.set("pitch", f"{self.pitch}%") prosody.set("rate", f"{self.rate}%") From 008a23ece42593b09755e77642107707a7ff4567 Mon Sep 17 00:00:00 2001 From: Ajay Raj Date: Wed, 2 Aug 2023 19:09:20 -0700 Subject: [PATCH 2/2] seed with 1 second of silence so the stream can warm up --- vocode/streaming/output_device/blocking_speaker_output.py | 1 + 1 file changed, 1 insertion(+) diff --git a/vocode/streaming/output_device/blocking_speaker_output.py b/vocode/streaming/output_device/blocking_speaker_output.py index 268c2b278..7c402fbf3 100644 --- a/vocode/streaming/output_device/blocking_speaker_output.py +++ b/vocode/streaming/output_device/blocking_speaker_output.py @@ -32,6 +32,7 @@ def __init__( device=int(self.device_info["index"]), ) self._ended = False + self.input_queue.put_nowait(self.sampling_rate * b"\x00") self.stream.start() def start(self):