Pronunciation Assessment using Python Speech SDK
See original GitHub issueDescribe the bug KeyError when using Pronunciation Assessment feature in Python Speech SDK
To Reproduce
import azure.cognitiveservices.speech as speechsdk
import json
SUB_KEY="" # replace this with the subscription key
REG="" # replace this with the region key
def recognize_from_file(wav_file, pronunciation_assessment_config):
speech_config = speechsdk.SpeechConfig(subscription=SUB_KEY, region=REG)
speech_config.speech_recognition_language="en-US"
audio_config = speechsdk.audio.AudioConfig(filename=wav_file)
speech_recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config, audio_config=audio_config)
pronunciation_assessment_config.apply_to(speech_recognizer)
speech_recognition_result = speech_recognizer.recognize_once()
pronunciation_assessment_result = speechsdk.PronunciationAssessmentResult(speech_recognition_result)
pronunciation_assessment_result_json = speech_recognition_result.properties.get(speechsdk.PropertyId.SpeechServiceResponse_JsonResult)
return pronunciation_assessment_result_json
pronunciation_assessment_config = speechsdk.PronunciationAssessmentConfig(json_string="{\"referenceText\":\"good morning.\",\"gradingSystem\":\"HundredMark\",\"granularity\":\"FullText\"}")
wav_file = "" # path to a wav file
pron_assessment = recognize_from_file(wav_file, pronunciation_assessment_config)
Expected behavior
code runs without error and the variable pron_assessment
has the json containing the pronunciation assessment scores for the corresponding reference text and wav file.
Version of the Cognitive Services Speech SDK 1.24.2
Platform, Operating System, and Programming Language
- OS: Linux
- Hardware - x64
- Programming language: Python
Additional context
- Stack Trace:
Traceback (most recent call last):
File "pron_assess.py", line 24, in <module>
pron_assessment = recognize_from_file(wav_file, pronunciation_assessment_config)
File "pron_assess.py", line 18, in recognize_from_file
pronunciation_assessment_result = speechsdk.PronunciationAssessmentResult(speech_recognition_result)
File "/home/azureuser/.local/lib/python3.8/site-packages/azure/cognitiveservices/speech/speech.py", line 3111, in __init__
self._words = [PronunciationAssessmentWordResult(w) for w in nb['Words']]
File "/home/azureuser/.local/lib/python3.8/site-packages/azure/cognitiveservices/speech/speech.py", line 3111, in <listcomp>
self._words = [PronunciationAssessmentWordResult(w) for w in nb['Words']]
File "/home/azureuser/.local/lib/python3.8/site-packages/azure/cognitiveservices/speech/speech.py", line 3042, in __init__
self._accuracy_score = _json['PronunciationAssessment'].get('AccuracyScore', 0)
KeyError: 'PronunciationAssessment'
Issue Analytics
- State:
- Created 10 months ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Use pronunciation assessment - Azure AI services
In this article, you learn how to evaluate pronunciation with speech to text through the Speech SDK. To get pronunciation assessment results ...
Read more >Azure-Samples/cognitive-services-speech-sdk
Sample code for the Microsoft Cognitive Services Speech SDK - cognitive-services-speech-sdk/samples/python/console/speech_sample.py at master ...
Read more >Azure Pronunciation Assessment SDK return wrong result ...
I'm using azure speech sdk to do pronunciation assessment, it works fine when i used api provide by azure, but when i use...
Read more >Pronunciation Assessment: a Developer Tutorial - YouTube
Comments1 · Introduction of Pronunciation Assessment, a feature of Speech service on Azure · speech recognition using deeplearning | speech to ...
Read more >SpeechSuper: Pronunciation Assessment and Scoring API ...
Get industry-leading pronunciation assessment and scoring API solutions from SpeechSuper. Our APIs accurately measure pronunciation, fluency, rhythm, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@AdityaYadavalli1 thanks for using Azure pronunciation assessment and reporting this issue, I will check.
@AdityaYadavalli1 the fix is in code review now. I will close this issue. The SDK release notes of the next version (1.25) will mention a fix for this GitHub issue.