Speech to text Curl command not working

Adrien Adrien 25 Reputation points
2024-02-22T17:56:26.8833333+00:00

I am trying to run the following command in a bash script (the file name and subscription key variables are being set. curl --location --request POST "https://$region.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?language=en-US&format=detailed" --header "Ocp-Apim-Subscription-Key: $subscription_key" --header "Content-Type: audio/wav" --data-binary $input_wav

It returns:

{"RecognitionStatus":"Success","Offset":0,"Duration":0,"NBest":[{"Confidence":0.0,"Lexical":"","ITN":"","MaskedITN":"","Display":""}],"DisplayText":""}

I have used my own wav files as well as the weather example wav file. Any suggestions would be greatly appreciated.

Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
2,061 questions
{count} votes

Accepted answer
  1. VasaviLankipalle-MSFT 18,676 Reputation points Moderator
    2024-02-22T21:52:22.0733333+00:00

    Hello @Adrien Adrien , Thanks for using Microsoft Q&A Platform.

    I have reproduced the same on my end it worked successfully. Here is the sample command:

    curl --location --request POST "https://region.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?language=en-US&format=detailed" ^
    --header "Ocp-Apim-Subscription-Key: key" ^
    --header "Content-Type: audio/wav" ^
    --data-binary "@whatstheweatherlike.wav"
    

    Response:

    {"RecognitionStatus":"Success","Offset":1100000,"Duration":13200000,"NBest":[{"Confidence":0.9931853,"Lexical":"what's the weather like","ITN":"what's the weather like","MaskedITN":"what's the weather like","Display":"What's the weather like?"}],"DisplayText":"What's the weather like?"}
    

    The issue with your command is missing '@' character before the audio file path[ --data-binary "@whatstheweatherlike.wav"] or --data-binary "@c:\directory\whatstheweatherlike.wav"

    Try to add this to your code it should work. Here is the sample code: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/get-started-speech-to-text?tabs=windows%2Cterminal&pivots=programming-language-rest#recognize-speech-from-a-file

    I hope this helps. Please let us know if you still face issues.

    Regards,

    Vasavi

    -Please kindly accept the answer and vote 'yes' if you feel helpful to support the community, thanks.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Azar 29,520 Reputation points MVP Volunteer Moderator
    2024-02-22T18:00:55.1966667+00:00

    Hey there Adrien Adrien

    That's a great question and thanks for using QandA platform'

    It seems like your curl command is successfully sending the request but the response you're receiving indicates that the recognition did not produce any meaningful results. The "RecognitionStatus" field is "Success," but the "NBest" array and "DisplayText" field are empty, I think this means the speech recognition did not produce any recognized text.

    Let me drop you a few troubleshoots

    1. Mkse sure that the audio file you're providing in the request is in the correct format and encoding supported by the Azure Speech service. WAV files are typically supported, but double-check that the audio is encoded correctly and not corrupted.
    2. Double-check the language and format parameters in your request URL. Make sure that the language parameter ("en-US") matches the language of the audio content, and the format parameter ("detailed") is appropriate for your use case.
    3. If the confidence score of the recognition results is consistently low (e.g., 0.0), try increasing the confidence threshold or experimenting with different models or settings to improve recognition accuracy

    If this helps you kindly accept the answer thanks much,

    0 comments No comments

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.