Speech To Text with REST API returns 'Success' with a partial word

Ian Choi 0 Reputation points
2023-08-17T03:26:27.0233333+00:00

I'm trying to use REST API for Speech To Text as below.

            const endpoint = `https://${azureRegion}.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1`;
            const query = new URLSearchParams({ language: 'en-US' });
            const url = `${endpoint}?${query}`;

            const headers = {
              'Ocp-Apim-Subscription-Key': azureSubscriptionKey,
              'Content-Type': 'audio/wav; codecs=audio/pcm; samplerate=16000',
              'Accept': 'application/json'
            };
        
            const response = await fetch(url, {
              method: 'POST',
              body,
              headers,
            });

And I used a wav file tested by many people as a reference, saying "What's the weather like".

API response looks not correct because DisplayText ontains only a partial word of the audio. ("The.")

Recognition result: {
  RecognitionStatus: 'Success',
  Offset: 8900000,
  Duration: 44500000,
  DisplayText: 'The.'
}

FYI the code above gets the arraybuffer of the wav file for 'body'. Please let me know how to fix it it...

Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
Microsoft 365 and Office | Development | Office JavaScript API
{count} votes

Your answer

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