Last active
October 18, 2023 14:08
-
-
Save AlexanderHolmeset/8194ba19eb3258905bcc52b0659da1fa to your computer and use it in GitHub Desktop.
VoiceStyle
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
$AzureSpeechSubscriptionKey = 'enter your key here' | |
$AzureSpeechRegion = 'norwayeast' | |
$Language = 'en-us' | |
$VoiceName = 'en-US-JennyNeural' | |
$Style = 'whispering' | |
$FetchTokenHeader = @{ | |
'Content-type'='application/x-www-form-urlencoded'; | |
'Content-Length'= '0'; | |
'Ocp-Apim-Subscription-Key' = $AzureSpeechSubscriptionKey | |
} | |
$OAuthToken = Invoke-RestMethod -Method POST -Uri https://$AzureSpeechRegion.api.cognitive.microsoft.com/sts/v1.0/issueToken -Headers $FetchTokenHeader | |
# show the token received | |
$OAuthToken | |
$MyHeader = @{"Authorization" = "Bearer $OAuthToken"; | |
"X-Microsoft-OutputFormat" = "audio-16khz-128kbitrate-mono-mp3" } | |
$uri = "https://$AzureSpeechRegion.tts.speech.microsoft.com/cognitiveservices/v1" | |
$Body = @" | |
<speak version='1.0' xml:lang='$Language'> | |
<voice name="$VoiceName" style="$Style" styledegree="2"> | |
Hi my name is Jenny. I am a neural voice. This is what I sound like when I have a American voice and im whispering. | |
</voice> | |
</speak> | |
"@ | |
Invoke-RestMethod -Method Post -ContentType "application/ssml+xml" -Headers $MyHeader -Body $Body -Uri $uri -OutFile "audio1.wav" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment