Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Convert Speech to Text with PowerShell and Azure Cognitive Services STT
# Audio Phrase
$audiofile = Get-ChildItem "C:\temp\speech2convert.wav"
# Read audio into byte array
$audioBytes = [System.IO.File]::ReadAllBytes($audiofile)
# API Key
$key1 = "your api key"
# Conversion URI
$conversionURI = ""
# Conversion Headers
$Headers = @{
'Ocp-Apim-Subscription-Key' = $key1;
'Transfer-Encoding' = 'chunked';
'Content-type' = 'audio/pcm; codec=audio/pcm; samplerate=16000'
# Convert
$TextResponse = Invoke-RestMethod -Method POST -Uri $conversionURI -Headers $Headers -Body $audioBytes
# Result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.