An Azure service that integrates speech processing into apps and services.
Error: USP error: timeout waiting for the first audio chunk in Python SDK
Chuong Phung
70
Reputation points
Using the Python SDK on Ubuntu, the following error occurs: "Error details: USP error: timeout waiting for the first audio chunk."
I followed the code provided in this documentation: Lower Speech Synthesis Latency.
The sample code from the following link runs successfully with AudioOutput set to the speaker, indicating that the key and region are configured correctly: Get Started with Text-to-Speech.
Is there a specific version or environment that can resolve this issue?
Here is the code being used:
import os
import azure.cognitiveservices.speech as speechsdk
import config as cfg
# This example requires environment variables named "SPEECH_KEY" and "SPEECH_REGION"
speech_config = speechsdk.SpeechConfig(subscription=cfg.STT_SUPSCRIPTION_KEY, region=cfg.STT_REGION)
# audio_config = speechsdk.audio.AudioOutputConfig(use_default_speaker=True)
# The neural multilingual voice can speak different languages based on the input text.
speech_config.speech_synthesis_voice_name='en-US-AvaMultilingualNeural'
speech_synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config, audio_config=None)
# Get text from the console and synthesize to the default speaker.
print("Enter some text that you want to speak >")
text = input()
speech_synthesis_result = speech_synthesizer.speak_text_async(text).get()
audio_data_stream = speechsdk.AudioDataStream(speech_synthesis_result)
audio_buffer = bytes(16000)
filled_size = audio_data_stream.read_data(audio_buffer)
print(filled_size)
import time
while filled_size > 0:
print("{} bytes received.".format(filled_size))
filled_size = audio_data_stream.read_data(audio_buffer)
time.sleep(0.5)
if speech_synthesis_result.reason == speechsdk.ResultReason.SynthesizingAudioCompleted:
print("Speech synthesized for text [{}]".format(text))
elif speech_synthesis_result.reason == speechsdk.ResultReason.Canceled:
cancellation_details = speech_synthesis_result.cancellation_details
print("Speech synthesis canceled: {}".format(cancellation_details.reason))
if cancellation_details.reason == speechsdk.CancellationReason.Error:
if cancellation_details.error_details:
print("Error details: {}".format(cancellation_details.error_details))
print("Did you set the speech resource key and region values?")
Azure Speech in Foundry Tools
Azure Speech in Foundry Tools
Sign in to answer