Last active
July 23, 2021 16:55
-
-
Save darrenjrobinson/fa763b14789f7fd8273dbb4be675bdfa to your computer and use it in GitHub Desktop.
Convert Speech to Text with PowerShell and Azure Cognitive Services STT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 = "https://speech.platform.bing.com/speech/recognition/interactive/cognitiveservices/v1?language=en-us&format=detailed" | |
# 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 | |
$TextResponse.NBest.Lexical |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment