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
|
Speaks a countdown by text-to-speech
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script speaks a countdown by text-to-speech (TTS) starting from a given number.
|
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)
|
Specifies the number to start from (10 by default)
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./speak-countdown.ps1 60
|
PS> ./speak-countdown.ps1 60
|
||||||
|
(listen and enjoy)
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
Author: Markus Fleschutz | License: CC0
|
Author: Markus Fleschutz | License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
param([int]$StartNumber = 10)
|
param([int]$startNumber = 10)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for ([int]$i = $StartNumber; $i -gt 0; $i--) {
|
for ([int]$i = $startNumber; $i -gt 0; $i--) {
|
||||||
& "$PSScriptRoot/speak-english.ps1" $i
|
& "$PSScriptRoot/speak-english.ps1" $i
|
||||||
Start-Sleep -milliseconds 200
|
Start-Sleep -milliseconds 200
|
||||||
}
|
}
|
||||||
& "$PSScriptRoot/speak-english.ps1" "zero"
|
& "$PSScriptRoot/speak-english.ps1" "Zero and lift-off!"
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
@ -22,11 +22,10 @@ try {
|
|||||||
foreach ($voice in $TTS.GetVoices()) {
|
foreach ($voice in $TTS.GetVoices()) {
|
||||||
if ($voice.GetDescription() -like "*- English*") {
|
if ($voice.GetDescription() -like "*- English*") {
|
||||||
$TTS.Voice = $voice
|
$TTS.Voice = $voice
|
||||||
[void]$TTS.Speak($text)
|
|
||||||
exit 0 # success
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw "No English text-to-speech voice found - please install one."
|
[void]$TTS.Speak($text)
|
||||||
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
|
Loading…
Reference in New Issue
Block a user