Merge pull request #695 from pipecat-ai/mb/initialize-azure-lang

Initialize the speech_recognition_language for Azure TTS
This commit is contained in:
Mark Backman
2024-11-08 06:40:40 -05:00
committed by GitHub
2 changed files with 13 additions and 6 deletions

View File

@@ -68,6 +68,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed an issue with PlayHTTTSService, where the TTFB metrics were reporting
very small time values.
- Fixed an issue where AzureTTSService wasn't initializing the specified
language.
### Other
- Add `23-bot-background-sound.py` foundational example.

View File

@@ -43,8 +43,8 @@ try:
ResultReason,
SpeechConfig,
SpeechRecognizer,
SpeechSynthesizer,
SpeechSynthesisOutputFormat,
SpeechSynthesizer,
)
from azure.cognitiveservices.speech.audio import (
AudioStreamFormat,
@@ -128,11 +128,6 @@ class AzureTTSService(TTSService):
):
super().__init__(sample_rate=sample_rate, **kwargs)
speech_config = SpeechConfig(subscription=api_key, region=region)
speech_config.set_speech_synthesis_output_format(sample_rate_to_output_format(sample_rate))
self._speech_synthesizer = SpeechSynthesizer(speech_config=speech_config, audio_config=None)
self._settings = {
"sample_rate": sample_rate,
"emphasis": params.emphasis,
@@ -147,6 +142,15 @@ class AzureTTSService(TTSService):
"volume": params.volume,
}
speech_config = SpeechConfig(
subscription=api_key,
region=region,
speech_recognition_language=self._settings["language"],
)
speech_config.set_speech_synthesis_output_format(sample_rate_to_output_format(sample_rate))
self._speech_synthesizer = SpeechSynthesizer(speech_config=speech_config, audio_config=None)
self.set_voice(voice)
def can_generate_metrics(self) -> bool: