Skip to content

Commit 837cb2a

Browse files
committed
change result to speech_recognition_result for consistency with quickstart
1 parent 16aae5b commit 837cb2a

File tree

1 file changed

+11
-11
lines changed
  • articles/ai-services/speech-service/includes/how-to/recognize-speech

1 file changed

+11
-11
lines changed

articles/ai-services/speech-service/includes/how-to/recognize-speech/python.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def from_mic():
4242
speech_recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config)
4343

4444
print("Speak into your microphone.")
45-
result = speech_recognizer.recognize_once_async().get()
46-
print(result.text)
45+
speech_recognition_result = speech_recognizer.recognize_once_async().get()
46+
print(speech_recognition_result.text)
4747

4848
from_mic()
4949
```
@@ -62,27 +62,27 @@ def from_file():
6262
audio_config = speechsdk.AudioConfig(filename="your_file_name.wav")
6363
speech_recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config, audio_config=audio_config)
6464

65-
result = speech_recognizer.recognize_once_async().get()
66-
print(result.text)
65+
speech_recognition_result = speech_recognizer.recognize_once_async().get()
66+
print(speech_recognition_result.text)
6767

6868
from_file()
6969
```
7070

7171
## Handle errors
7272

73-
The previous examples only get the recognized text from the `result.text` property. To handle errors and other responses, you need to write some code to handle the result. The following code evaluates the [`result.reason`](/python/api/azure-cognitiveservices-speech/azure.cognitiveservices.speech.resultreason) property and:
73+
The previous examples only get the recognized text from the `speech_recognition_result.text` property. To handle errors and other responses, you need to write some code to handle the result. The following code evaluates the [`speech_recognition_result.reason`](/python/api/azure-cognitiveservices-speech/azure.cognitiveservices.speech.resultreason) property and:
7474

7575
* Prints the recognition result: `speechsdk.ResultReason.RecognizedSpeech`.
7676
* If there's no recognition match, it informs the user: `speechsdk.ResultReason.NoMatch`.
7777
* If an error is encountered, it prints the error message: `speechsdk.ResultReason.Canceled`.
7878

7979
```Python
80-
if result.reason == speechsdk.ResultReason.RecognizedSpeech:
81-
print("Recognized: {}".format(result.text))
82-
elif result.reason == speechsdk.ResultReason.NoMatch:
83-
print("No speech could be recognized: {}".format(result.no_match_details))
84-
elif result.reason == speechsdk.ResultReason.Canceled:
85-
cancellation_details = result.cancellation_details
80+
if speech_recognition_result.reason == speechsdk.ResultReason.RecognizedSpeech:
81+
print("Recognized: {}".format(speech_recognition_result.text))
82+
elif speech_recognition_result.reason == speechsdk.ResultReason.NoMatch:
83+
print("No speech could be recognized: {}".format(speech_recognition_result.no_match_details))
84+
elif speech_recognition_result.reason == speechsdk.ResultReason.Canceled:
85+
cancellation_details = speech_recognition_result.cancellation_details
8686
print("Speech Recognition canceled: {}".format(cancellation_details.reason))
8787
if cancellation_details.reason == speechsdk.CancellationReason.Error:
8888
print("Error details: {}".format(cancellation_details.error_details))

0 commit comments

Comments
 (0)