Hi Abdulla Rasfan,
I reproduced the issue using the Azure Speech SDK with the ConversationTranscriber
class and confirmed it works correctly with the following approach: ensure you are using the latest version of the SDK, set the diarization property via speech_config.set_property
with PropertyId.SpeechServiceResponse_DiarizeIntermediateResults
, and instantiate the ConversationTranscriber
from the speechsdk.transcription
namespace. The sample code processes audio input, outputs speaker diarization results, and completes without errors. Please verify your environment uses the latest SDK and your code follows this pattern.
Here is a sample code snippet for your reference:
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():
# Replace below with your Azure Speech subscription key and region
speech_key = "YourSubscriptionKeyHere"
service_region = "YourServiceRegionHere" # e.g., "eastus", "westus2"
speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_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="sampledata_audiofiles_katiesteve.wav")
conversation_transcriber = speechsdk.transcription.ConversationTranscriber(speech_config=speech_config, audio_config=audio_config)
transcribing_stop = False
def stop_cb(evt: speechsdk.SessionEventArgs):
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)
conversation_transcriber.session_stopped.connect(stop_cb)
conversation_transcriber.canceled.connect(stop_cb)
conversation_transcriber.start_transcribing_async()
# Wait for completion.
while not transcribing_stop:
time.sleep(0.5)
conversation_transcriber.stop_transcribing_async()
# Main
try:
recognize_from_file()
except Exception as err:
print("Encountered exception. {}".format(err))
Here is the output I received when running this code:
I hope this helps resolve your issue. Please ensure you have the latest Speech SDK installed, and feel free to reach out if you have any further questions.