2021-09-27 10:38:12 +02:00
|
|
|
|
<#
|
2021-07-13 21:10:02 +02:00
|
|
|
|
.SYNOPSIS
|
2021-10-16 16:50:10 +02:00
|
|
|
|
Performs a text-to-speech test
|
2021-10-04 21:29:23 +02:00
|
|
|
|
.DESCRIPTION
|
2022-01-30 10:49:30 +01:00
|
|
|
|
This PowerShell script performs a text-to-speech (TTS) test.
|
2021-07-13 21:10:02 +02:00
|
|
|
|
.EXAMPLE
|
2021-09-27 08:35:45 +02:00
|
|
|
|
PS> ./speak-test
|
2021-07-13 21:10:02 +02:00
|
|
|
|
.LINK
|
|
|
|
|
https://github.com/fleschutz/PowerShell
|
2022-01-30 10:49:30 +01:00
|
|
|
|
.NOTES
|
|
|
|
|
Author: Markus Fleschutz / License: CC0
|
2020-12-31 11:02:08 +01:00
|
|
|
|
#>
|
|
|
|
|
|
2021-01-02 13:40:18 +01:00
|
|
|
|
function Speak { param([string]$Text)
|
|
|
|
|
write-output "'$Text'"
|
2021-01-09 16:40:46 +01:00
|
|
|
|
[void]$Voice.speak("$Text")
|
2021-01-02 13:40:18 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-31 11:02:08 +01:00
|
|
|
|
try {
|
|
|
|
|
$Voice = new-object -ComObject SAPI.SPVoice
|
2020-12-31 11:25:41 +01:00
|
|
|
|
$DefaultVolume = $Voice.volume
|
|
|
|
|
$DefaultRate = $Voice.rate
|
2021-01-02 13:40:18 +01:00
|
|
|
|
Speak("This is the default voice with default volume $DefaultVolume and speed $DefaultRate")
|
2020-12-31 11:10:45 +01:00
|
|
|
|
|
|
|
|
|
$Voice.rate = -10
|
2021-01-02 13:40:18 +01:00
|
|
|
|
Speak("Let's speak very, very slow")
|
2020-12-31 11:25:41 +01:00
|
|
|
|
$Voice.rate = -5
|
2021-01-02 13:40:18 +01:00
|
|
|
|
Speak("Let's speak very slow")
|
|
|
|
|
$Voice.rate = -3
|
|
|
|
|
Speak("Let's speak slow")
|
|
|
|
|
$Voice.rate = 0
|
|
|
|
|
Speak("Let's speak normal")
|
2020-12-31 11:25:41 +01:00
|
|
|
|
$Voice.rate = 2
|
2021-01-02 13:40:18 +01:00
|
|
|
|
Speak("Let's speak fast")
|
2020-12-31 11:25:41 +01:00
|
|
|
|
$Voice.rate = 5
|
2021-01-02 13:40:18 +01:00
|
|
|
|
Speak("Let's speak very fast")
|
2020-12-31 11:25:41 +01:00
|
|
|
|
$Voice.rate = 10
|
2021-01-02 13:40:18 +01:00
|
|
|
|
Speak("Let's speak very, very fast")
|
2020-12-31 11:25:41 +01:00
|
|
|
|
$Voice.rate = $DefaultRate
|
2020-12-31 11:10:45 +01:00
|
|
|
|
|
|
|
|
|
$Voice.volume = 100
|
2021-01-02 13:40:18 +01:00
|
|
|
|
Speak("Let's try 100% volume")
|
2020-12-31 11:25:41 +01:00
|
|
|
|
$Voice.volume = 75
|
2021-01-02 13:40:18 +01:00
|
|
|
|
Speak("Let's try 75% volume")
|
2020-12-31 11:10:45 +01:00
|
|
|
|
$Voice.volume = 50
|
2021-01-02 13:40:18 +01:00
|
|
|
|
Speak("Let's try 50% volume")
|
2020-12-31 11:25:41 +01:00
|
|
|
|
$Voice.volume = 25
|
2021-01-02 13:40:18 +01:00
|
|
|
|
Speak("Let's try 25% volume")
|
2020-12-31 11:25:41 +01:00
|
|
|
|
$Voice.volume = $DefaultVolume
|
2020-12-31 11:02:08 +01:00
|
|
|
|
|
|
|
|
|
$Voices = $Voice.GetVoices()
|
|
|
|
|
foreach ($OtherVoice in $Voices) {
|
|
|
|
|
$Voice.Voice = $OtherVoice
|
2021-01-02 13:40:18 +01:00
|
|
|
|
$Description = $OtherVoice.GetDescription()
|
|
|
|
|
Speak("Hi, I'm the voice called $Description")
|
2020-12-31 11:02:08 +01:00
|
|
|
|
}
|
2021-09-27 10:09:45 +02:00
|
|
|
|
exit 0 # success
|
2020-12-31 11:02:08 +01:00
|
|
|
|
} catch {
|
2022-04-13 12:06:32 +02:00
|
|
|
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
2020-12-31 11:02:08 +01:00
|
|
|
|
exit 1
|
|
|
|
|
}
|