Added speak-test.ps1

This commit is contained in:
Markus Fleschutz 2021-01-02 13:40:18 +01:00
parent 80ca148f65
commit 31848acec0

View File

@ -6,40 +6,48 @@
.NOTES Author: Markus Fleschutz / License: CC0 .NOTES Author: Markus Fleschutz / License: CC0
#> #>
function Speak { param([string]$Text)
write-output "'$Text'"
$Result = $Voice.speak("$Text")
}
try { try {
$Voice = new-object -ComObject SAPI.SPVoice $Voice = new-object -ComObject SAPI.SPVoice
$DefaultVolume = $Voice.volume $DefaultVolume = $Voice.volume
$DefaultRate = $Voice.rate $DefaultRate = $Voice.rate
$Result = $Voice.Speak("This is the default voice with default volume $DefaultVolume and speed $DefaultRate") Speak("This is the default voice with default volume $DefaultVolume and speed $DefaultRate")
$Voice.rate = -10 $Voice.rate = -10
$Result = $Voice.Speak("Let's speak very, very slow") Speak("Let's speak very, very slow")
$Voice.rate = -5 $Voice.rate = -5
$Result = $Voice.Speak("Let's speak very slow") Speak("Let's speak very slow")
$Voice.rate = -3
Speak("Let's speak slow")
$Voice.rate = 0
Speak("Let's speak normal")
$Voice.rate = 2 $Voice.rate = 2
$Result = $Voice.Speak("Let's speak fast") Speak("Let's speak fast")
$Voice.rate = 5 $Voice.rate = 5
$Result = $Voice.Speak("Let's speak very fast") Speak("Let's speak very fast")
$Voice.rate = 10 $Voice.rate = 10
$Result = $Voice.Speak("Let's speak very, very fast") Speak("Let's speak very, very fast")
$Voice.rate = $DefaultRate $Voice.rate = $DefaultRate
$Voice.volume = 100 $Voice.volume = 100
$Result = $Voice.Speak("Let's try 100% volume") Speak("Let's try 100% volume")
$Voice.volume = 75 $Voice.volume = 75
$Result = $Voice.Speak("Let's try 75% volume") Speak("Let's try 75% volume")
$Voice.volume = 50 $Voice.volume = 50
$Result = $Voice.Speak("Let's try 50% volume") Speak("Let's try 50% volume")
$Voice.volume = 25 $Voice.volume = 25
$Result = $Voice.Speak("Let's try 25% volume") Speak("Let's try 25% volume")
$Voice.volume = $DefaultVolume $Voice.volume = $DefaultVolume
$Voices = $Voice.GetVoices() $Voices = $Voice.GetVoices()
foreach ($OtherVoice in $Voices) { foreach ($OtherVoice in $Voices) {
$Description = $OtherVoice.GetDescription()
write-output "Voice: $Description"
$Voice.Voice = $OtherVoice $Voice.Voice = $OtherVoice
$Result = $Voice.Speak("Hello, I'm the voice called $Description") $Description = $OtherVoice.GetDescription()
Speak("Hi, I'm the voice called $Description")
} }
exit 0 exit 0
} catch { } catch {