Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Speech Recognition result cannot always be converted to Pronunciation Assessment Result #770

Open
coreyward opened this issue Dec 8, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@coreyward
Copy link

What happened?

I ran into an issue where an audio recording sent didn't have any detectable speech in it. I would expect some kind of error message to come back, but what I did not expect is that the SDK would throw an error over it when used as shown in examples.

Cannot read properties of undefined (reading '0')

This is coming from line 108 here:

export class PronunciationAssessmentResult {
private privPronJson: DetailResult;
private constructor(jsonString: string) {
const j = JSON.parse(jsonString) as AssessmentResult;
Contracts.throwIfNullOrUndefined(j.NBest[0], "NBest");
this.privPronJson = j.NBest[0];
}

It seems like the types are inaccurate for j.NBest. When the Speech Recognizer is handed an audio file that does not have any words in it, the result comes back without any errors, but also rather sparse without many fields including NBest. For example:

SpeechRecognitionResult {
      privResultId: '75EDA7E5421A411F81E0D64B9504D75C',
      privReason: 0,
      privText: undefined,
      privDuration: 49200000,
      privOffset: 0,
      privLanguage: undefined,
      privLanguageDetectionConfidence: undefined,
      privErrorDetails: undefined,
      privJson: '{"Id":"0ed4402056c8472a99bc19fff317a024","RecognitionStatus":2,"Offset":0,"Duration":49200000,"Channel":0,"SNR":0}',
      privProperties: PropertyCollection {
        privKeys: [ 'SpeechServiceResponse_JsonResult' ],
        privValues: [
          '{"Id":"0ed4402056c8472a99bc19fff317a024","RecognitionStatus":"InitialSilenceTimeout","Offset":0,"Duration":49200000,"Channel":0,"SNR":0.0}'
        ]
      },
      privSpeakerId: undefined
    }

It would be really useful if this behavior (and overall, all of the potential response formats from the API) were documented somewhere accurately. It's hard to build robust applications that fail gracefully when the behavior of dependencies is undocumented.

Using v1.33.1, but the "Version" dropdown in the issue form only lists up to 1.33.0.

Version

1.33.0 (Latest)

What browser/platform are you seeing the problem on?

No response

Relevant log output

No response

@coreyward coreyward added the bug Something isn't working label Dec 8, 2023
@glharper
Copy link
Member

glharper commented Jan 5, 2024

@coreyward Thanks for submitting this issue and using JS Speech SDK. In theory, an InitialSilenceTimeout result should be shunted down a different codepath before attempting to create a PronunciationAssessmentResult, so this does feel like a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants