How do I use the Nbest function?

sanghun jeon 41 Reputation points
2021-11-04T07:46:59.697+00:00

Now I want to use Python to see the voice recognizer's expected words.
However, just one word is being broadcast continually, and no other projected word can be observed at this time.
So when I looked up the function, I saw NBest and wanted to include it, but I couldn't figure out how.
Where should I place the Nbest in the code below?

-----------------------------------------------------------------------------------

Example) https://learn.microsoft.com/en-us/azure/cognitive-services/speech-service/rest-speech-to-text#query-parameters
{
"RecognitionStatus": "Success",
"Offset": "1236645672289",
"Duration": "1236645672289",
"NBest": [
{
"Confidence": 0.9052885,
"Display": "What's the weather like?",
"ITN": "what's the weather like",
"Lexical": "what's the weather like",
"MaskedITN": "what's the weather like"
},
{
"Confidence": 0.92459863,
"Display": "what is the weather like",
"ITN": "what is the weather like",
"Lexical": "what is the weather like",
"MaskedITN": "what is the weather like"
}
]
}

------------------------------------------------------------------------------------------------------

speech_key = subscription_key  
service_region = 'koreacentral'  

config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region)  
recognizer = speechsdk.SpeechRecognizer(speech_config=config, language="ko-KR")  
result = recognizer.recognize_once_async().get()  

if result.reason == speechsdk.ResultReason.RecognizedSpeech:  
    print("Recognized: {}".format(result.text))  
elif result.reason == speechsdk.ResultReason.NoMatch:  
    print("No speech could be recognized: {}".format(result.no_match_details))  
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))
Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
1,380 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. GiftA-MSFT 11,151 Reputation points
    2021-11-04T19:58:31.607+00:00

    Hi, you can specify the OutputFormat attribute in the SpeechConfig to OutputFormat.Detailed as shown below:

    speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region)  
    speech_config.output_format=speechsdk.OutputFormat.Detailed  
    

    --- *Kindly Accept Answer if the information helps. Thanks.*

    0 comments No comments