Azure TTS fixed by clearing the audio queue before synthesizing the next text
This commit is contained in:
@@ -72,6 +72,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed an issue where audio would get stuck in the queue when an interrupt occurs
|
||||
during Azure TTS synthesis.
|
||||
|
||||
- Fixed a race condition that occurs in Python 3.10+ where the task could miss
|
||||
the `CancelledError` and continue running indefinitely, freezing the pipeline.
|
||||
|
||||
|
||||
@@ -282,6 +282,13 @@ class AzureTTSService(AzureBaseTTSService):
|
||||
"""
|
||||
logger.debug(f"{self}: Generating TTS [{text}]")
|
||||
|
||||
# Clear the audio queue in case there's still audio in it, causing the next audio response
|
||||
# to be cut off by the 'None' element returned at the end of the previous audio synthesis.
|
||||
# Empty the audio queue before processing the new text
|
||||
while not self._audio_queue.empty():
|
||||
self._audio_queue.get_nowait()
|
||||
self._audio_queue.task_done()
|
||||
|
||||
try:
|
||||
if self._speech_synthesizer is None:
|
||||
error_msg = "Speech synthesizer not initialized."
|
||||
|
||||
Reference in New Issue
Block a user