How to send audio via the pronunciation assessment api

Dominar el ingles 20 Reputation points
2023-05-13T17:02:49.0733333+00:00

I'm trying to send a request to the Pronunciation Assessment API in my PHP application, and I'm receiving a 200 response from it, but the body of the response just looks something like this, which is not all that helpful:

{
    "RecognitionStatus": "EndOfDictation",
    "Offset": 5900000,
    "Duration": 0
}

I'm setting up the request like this:

User's image

To get the audio, I am doing this in javascript:

const audioBlob = new Blob(this.audioChunks, {'type': 'audio/wav'});
      formData.append('audio', audioBlob, 'recording.wav');
      formData.append('text', this.text);
      axios.post('/api/pronunciation-assessment', formData) ...

And then in PHP I am getting the contents of that passed audio and base64_encodeing it.

This is what I have been able to piece together from different sources on the web, since Azure has no official API documentation for this service as far as I can tell.

Any idea what I'm doing wrong here?

Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
3,629 questions
0 comments No comments
{count} votes

Accepted answer
  1. romungi-MSFT 48,911 Reputation points Microsoft Employee Moderator
    2023-05-15T09:35:15.2766667+00:00

    @Dominar el ingles I think you are passing the pronunciation assessment parameters in the body of the request rather than headers. I followed these steps to create a header for assessment parameters using the below snippet from this script and then used them in my POST call through postman.

    import requests
    import base64
    import json
    
    referenceText = "Good morning."
    pronAssessmentParamsJson = "\"ReferenceText\":\"%s\",\"GradingSystem\":\"HundredMark\",\"Dimension\":\"Comprehensive\"}" % referenceText
    pronAssessmentParamsBase64 = base64.b64encode(bytes(pronAssessmentParamsJson, 'utf-8'))
    pronAssessmentParams = str(pronAssessmentParamsBase64, "utf-8")
    print(pronAssessmentParams)
    
    

    Using Postman I selected the audio file required for assessment by selecting binary option as the body.

    enter image description here

    Copy the Assessment parameter header from the above snippet and use it in the request below as seen along with other parameters.

    enter image description here

    As observed, the response contains the result and the assessment of reference text with the scores. I hope this helps!!

    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.