When I use my code in the remote server (virtual machine) the code is working fine (SPEECH KEYS and ENDPOINTS are working, using wav format audio file without noice) but when I am using the same code in local or in azure portal I am getting this error:
SessionStarted event Canceled event CLOSING on ConversationTranscriptionCanceledEventArgs(session_id=751531ddfea84904a646c43356cfd060, result=ConversationTranscriptionResult(result_id=49a65a470971423ea57cf231fcc161da, speaker_id=, text=, reason=ResultReason.Canceled)) SessionStopped event CLOSING on SessionEventArgs(session_id=751531ddfea84904a646c43356cfd060)
the code I used is: Below is the code:
import os
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('TRANSCRIBED:')
if evt.result.reason == speechsdk.ResultReason.RecognizedSpeech:
print('\tText={}'.format(evt.result.text))
print('\tSpeaker ID={}'.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_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="SPEECHKEY", region="REGION")
speech_config.speech_recognition_language="en-US"
audio_config = speechsdk.audio.AudioConfig(filename="Conference.wav")
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.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))