Skip to content

Instantly share code, notes, and snippets.

@michaelhenry
Created August 21, 2019 11:58
Show Gist options
  • Save michaelhenry/00ed546579d210991ac64f766f6cc151 to your computer and use it in GitHub Desktop.
Save michaelhenry/00ed546579d210991ac64f766f6cc151 to your computer and use it in GitHub Desktop.
AZURE REST API CALL
# Reference: https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/rest-speech-to-text
subscriptionKey=SUBSCRIPTION_KEY
filename=AUDIO_FILE_NAME_WAV_PCM_FORMAT
token=$(curl -v -X POST "https://westus.api.cognitive.microsoft.com/sts/v1.0/issueToken" \
-H "Content-type: application/x-www-form-urlencoded" \
-H "Content-Length: 0" \
-H "Ocp-Apim-Subscription-Key: $subscriptionKey")
stt_api_url="https://westus.stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?language=en-US&format=detailed"
curl --http1.1 -v -X POST $stt_api_url \
-H "Accept: application/json;text/xml"\
-H "Content-type: audio/wav; codec=audio/wav; codecs=audio/pcm; samplerate=16000" \
-H "Host: westus.stt.speech.microsoft.com" \
-H "Transfer-Encoding: chunked" \
-H "Expect: 100-continue" \
-H "Authorization: Bearer $token" --data-binary @$filename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment