question

sanghunjeon-9189 avatar image
0 Votes"
sanghunjeon-9189 asked GiftA-MSFT answered

How do I use the Nbest function?

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://docs.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-speech
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

GiftA-MSFT avatar image
0 Votes"
GiftA-MSFT answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.