From 31848acec025cbfe2050ed3bf0d65c53a85812e0 Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Sat, 2 Jan 2021 13:40:18 +0100 Subject: [PATCH] Added speak-test.ps1 --- Scripts/speak-test.ps1 | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/Scripts/speak-test.ps1 b/Scripts/speak-test.ps1 index 9d0d68ac..9a886edf 100755 --- a/Scripts/speak-test.ps1 +++ b/Scripts/speak-test.ps1 @@ -6,40 +6,48 @@ .NOTES Author: Markus Fleschutz / License: CC0 #> +function Speak { param([string]$Text) + write-output "'$Text'" + $Result = $Voice.speak("$Text") +} + try { $Voice = new-object -ComObject SAPI.SPVoice $DefaultVolume = $Voice.volume $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 - $Result = $Voice.Speak("Let's speak very, very slow") + Speak("Let's speak very, very slow") $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 - $Result = $Voice.Speak("Let's speak fast") + Speak("Let's speak fast") $Voice.rate = 5 - $Result = $Voice.Speak("Let's speak very fast") + Speak("Let's speak very fast") $Voice.rate = 10 - $Result = $Voice.Speak("Let's speak very, very fast") + Speak("Let's speak very, very fast") $Voice.rate = $DefaultRate $Voice.volume = 100 - $Result = $Voice.Speak("Let's try 100% volume") + Speak("Let's try 100% volume") $Voice.volume = 75 - $Result = $Voice.Speak("Let's try 75% volume") + Speak("Let's try 75% volume") $Voice.volume = 50 - $Result = $Voice.Speak("Let's try 50% volume") + Speak("Let's try 50% volume") $Voice.volume = 25 - $Result = $Voice.Speak("Let's try 25% volume") + Speak("Let's try 25% volume") $Voice.volume = $DefaultVolume $Voices = $Voice.GetVoices() foreach ($OtherVoice in $Voices) { - $Description = $OtherVoice.GetDescription() - write-output "Voice: $Description" $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 } catch {