My event is getting cancelled while using microsoft speech service

Hari Narayan 0 Reputation points

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):


    if evt.result.reason == speechsdk.ResultReason.RecognizedSpeech:


        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")



    audio_config ="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





    # stop transcribing on either session stopped or canceled events






    # Waits for completion.

    while not transcribing_stop:








except Exception as err:

    print("Encountered exception. {}".format(err))

Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
1,378 questions
{count} votes

1 answer

Sort by: Most helpful
  1. navba-MSFT 16,695 Reputation points Microsoft Employee

    @Hari Narayan Welcome to Microsoft Q&A Forum, Thank you for posting your query here!

    • Could you please confirm if it was an Azure Virtual Machine ?
    • Are you using Speech Containers while running locally ?
    • You mentioned about the same code failing in Azure Portal, Could you please clarify which resource / how did you run this code in Azure ?
    • Could you please try to use the Azure Speech Studio and check if you encounter the same issue there too ?

    Action Plan:
    Could you please share the complete SDK logging from both working and non-working scenario ?

    This will help us to compare and identify the cause.

    Sharing another thread where the similar issue was reported:

    Awaiting your reply.

    0 comments No comments