Updated speak-countdown.ps1 and speak-english.ps1

This commit is contained in:
Markus Fleschutz 2024-11-20 11:50:21 +01:00
parent 5fb74da197
commit 2301e9a226
2 changed files with 7 additions and 7 deletions

View File

@ -3,24 +3,25 @@
Speaks a countdown by text-to-speech
.DESCRIPTION
This PowerShell script speaks a countdown by text-to-speech (TTS) starting from a given number.
.PARAMETER StartNumber
.PARAMETER startNumber
Specifies the number to start from (10 by default)
.EXAMPLE
PS> ./speak-countdown.ps1 60
(listen and enjoy)
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
param([int]$StartNumber = 10)
param([int]$startNumber = 10)
try {
for ([int]$i = $StartNumber; $i -gt 0; $i--) {
for ([int]$i = $startNumber; $i -gt 0; $i--) {
& "$PSScriptRoot/speak-english.ps1" $i
Start-Sleep -milliseconds 200
}
& "$PSScriptRoot/speak-english.ps1" "zero"
& "$PSScriptRoot/speak-english.ps1" "Zero and lift-off!"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -22,11 +22,10 @@ try {
foreach ($voice in $TTS.GetVoices()) {
if ($voice.GetDescription() -like "*- English*") {
$TTS.Voice = $voice
}
}
[void]$TTS.Speak($text)
exit 0 # success
}
}
throw "No English text-to-speech voice found - please install one."
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1