mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-21 15:33:15 +01:00
Updated speak-countdown.ps1 and speak-english.ps1
This commit is contained in:
parent
5fb74da197
commit
2301e9a226
@ -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])"
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user