Hi @Domenico Zurlo ,
Following up to see my above "comment" answer helps by checking the comments section of this thread. Do let us know if you have any queries.
To reiterate the resolution here, let me jot down the gist of my comment answer above.
I understand that you are adjusted the Speech_SegmentationSilenceTimeoutMs
parameter to 3500ms
and noticed an error: "ServiceTimeout, Due to service inactivity the client buffer size exceeded", when a long speech is done.
I ran the below code in my local Jupyter Notebook without any buffer error. The below code uses 3500ms
for Speech_SegmentationSilenceTimeoutMs
# Set up the speech configuration
speech_key = "<SPEECH-KEY>"
service_region = "SERVICE-REGION>"
speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region)
# Set the Speech_SegmentationSilenceTimeoutMs parameter to 3500ms
speech_config.set_property(speechsdk.PropertyId.Speech_SegmentationSilenceTimeoutMs, "3500")
# Set up the audio configuration
audio_config = speechsdk.audio.AudioConfig(use_default_microphone=True)
# Set up the speech recognizer
speech_recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config, audio_config=audio_config)
# Set the request timeout property
speech_config.set_service_property(name="requesttimeout", value="20000", channel=speechsdk.ServicePropertyChannel.UriQueryParameter)
# Start continuous recognition
done = False
def stop_cb(evt):
"""Callback that stops continuous recognition upon receiving an event `evt`"""
print('CLOSING on {}'.format(evt))
speech_recognizer.stop_continuous_recognition()
global done
done = True
speech_recognizer.recognizing.connect(lambda evt: print('RECOGNIZING: {}'.format(evt)))
speech_recognizer.recognized.connect(lambda evt: print('RECOGNIZED: {}'.format(evt)))
speech_recognizer.session_started.connect(lambda evt: print('SESSION STARTED: {}'.format(evt)))
speech_recognizer.session_stopped.connect(lambda evt: print('SESSION STOPPED {}'.format(evt)))
speech_recognizer.canceled.connect(lambda evt: print('CANCELED {}'.format(evt)))
speech_recognizer.session_stopped.connect(stop_cb)
speech_recognizer.canceled.connect(stop_cb)
speech_recognizer.start_continuous_recognition()
while not done:
pass
# Listen to the recognized event and check the duration property
for result in speech_recognizer.session_results:
if result.reason == speechsdk.ResultReason.RecognizedSpeech:
print("Recognized: {}".format(result.text))
print("Duration: {} seconds".format(result.duration))
elif result.reason == speechsdk.ResultReason.NoMatch:
print("No speech could be recognized")
elif result.reason == speechsdk.ResultReason.Canceled:
cancellation_details = result.cancellation_details
print("Speech recognition canceled: {}".format(cancellation_details.reason))
if cancellation_details.reason == speechsdk.CancellationReason.Error:
print("Error details: {}".format(cancellation_details.error_details))
Please have a look at the sample implementation done in the above "comment".
Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics. Thank you!