we are able reproduce the issue and able to solve in our environment can you please check once with
import time
import azure.cognitiveservices.speech as speechsdk
def conversation_transcriber_recognition_canceled_cb(evt: speechsdk.SessionEventArgs):
print('Canceled event')
def conversation_transcriber_session_stopped_cb(evt: speechsdk.SessionEventArgs):
print('SessionStopped event')
def conversation_transcriber_transcribed_cb(evt: speechsdk.SpeechRecognitionEventArgs):
print('\nTRANSCRIBED:')
if evt.result.reason == speechsdk.ResultReason.RecognizedSpeech:
print('\tText={}'.format(evt.result.text))
print('\tSpeaker ID={}\n'.format(evt.result.speaker_id))
elif evt.result.reason == speechsdk.ResultReason.NoMatch:
print('\tNOMATCH: Speech could not be TRANSCRIBED: {}'.format(evt.result.no_match_details))
def conversation_transcriber_transcribing_cb(evt: speechsdk.SpeechRecognitionEventArgs):
print('TRANSCRIBING:')
print('\tText={}'.format(evt.result.text))
print('\tSpeaker ID={}'.format(evt.result.speaker_id))
def conversation_transcriber_session_started_cb(evt: speechsdk.SessionEventArgs):
print('SessionStarted event')
def recognize_from_file():
# This example requires environment variables named "SPEECH_KEY" and "SPEECH_REGION"
speech_config = speechsdk.SpeechConfig(subscription="<KEY>", region="<REGION>")
speech_config.speech_recognition_language="en-US"
speech_config.set_property(property_id=speechsdk.PropertyId.SpeechServiceResponse_DiarizeIntermediateResults, value='true')
audio_config = speechsdk.audio.AudioConfig(filename=r"FILE_PATH")
conversation_transcriber = speechsdk.transcription.ConversationTranscriber(speech_config=speech_config, audio_config=audio_config)
transcribing_stop = False
def stop_cb(evt: speechsdk.SessionEventArgs):
#"""callback that signals to stop continuous recognition upon receiving an event `evt`"""
print('CLOSING on {}'.format(evt))
nonlocal transcribing_stop
transcribing_stop = True
# Connect callbacks to the events fired by the conversation transcriber
conversation_transcriber.transcribed.connect(conversation_transcriber_transcribed_cb)
conversation_transcriber.transcribing.connect(conversation_transcriber_transcribing_cb)
conversation_transcriber.session_started.connect(conversation_transcriber_session_started_cb)
conversation_transcriber.session_stopped.connect(conversation_transcriber_session_stopped_cb)
conversation_transcriber.canceled.connect(conversation_transcriber_recognition_canceled_cb)
# stop transcribing on either session stopped or canceled events
conversation_transcriber.session_stopped.connect(stop_cb)
conversation_transcriber.canceled.connect(stop_cb)
conversation_transcriber.start_transcribing_async()
# Waits for completion.
while not transcribing_stop:
time.sleep(.5)
conversation_transcriber.stop_transcribing_async()
# Main
try:
recognize_from_file()
except Exception as err:
print("Encountered exception. {}".format(err))
output.
I hope this helps you. Thank you.