Improve the scripts

This commit is contained in:
Markus Fleschutz 2021-04-08 13:27:03 +02:00
parent f18ff005f6
commit bb5bb64827
5 changed files with 18 additions and 19 deletions

View File

@ -129,7 +129,7 @@ SHA256.ps1, prints the SHA256 checksum of the given file
show-dir-tree.ps1, visualizes the given/current directory tree
simulate-matrix.ps1, simulates the Matrix (fun)
simulate-presence.ps1, simulates the human presence against burglars
speak-countdown.ps1, speaks a countdown by text-to-speech (TTS)
speak-countdown.ps1, starts a countdown by text-to-speech (TTS)
speak-date.ps1, speaks the current date by text-to-speech (TTS)
speak-english.ps1, speaks the given text with an English text-to-speech (TTS) voice
speak-epub.ps1, speaks the content of the given Epub file by text-to-speech (TTS)

1 Script Description
129 show-dir-tree.ps1 visualizes the given/current directory tree
130 simulate-matrix.ps1 simulates the Matrix (fun)
131 simulate-presence.ps1 simulates the human presence against burglars
132 speak-countdown.ps1 speaks a countdown by text-to-speech (TTS) starts a countdown by text-to-speech (TTS)
133 speak-date.ps1 speaks the current date by text-to-speech (TTS)
134 speak-english.ps1 speaks the given text with an English text-to-speech (TTS) voice
135 speak-epub.ps1 speaks the content of the given Epub file by text-to-speech (TTS)

View File

@ -12,7 +12,7 @@ Mega Collection of PowerShell Scripts
* [play-mp3.ps1](Scripts/play-mp3.ps1) - plays the given sound file (MP3 file format)
* [play-super-mario.ps1](Scripts/play-super-mario.ps1) - plays the Super Mario Intro
* [play-the-imperial-march.ps1](Scripts/play-the-imperial-march.ps1) - plays the Imperial March (Star Wars)
* [speak-countdown.ps1](Scripts/speak-countdown.ps1) - speaks a countdown by text-to-speech (TTS)
* [speak-countdown.ps1](Scripts/speak-countdown.ps1) - starts a countdown by text-to-speech (TTS)
* [speak-date.ps1](Scripts/speak-date.ps1) - speaks the current date by text-to-speech (TTS)
* [speak-english.ps1](Scripts/speak-english.ps1) - speaks the given text with an English text-to-speech (TTS) voice
* [speak-epub.ps1](Scripts/speak-epub.ps1) - speaks the content of the given Epub file by text-to-speech (TTS)

View File

@ -1,7 +1,7 @@
#!/usr/bin/pwsh
<#
.SYNTAX speak-countdown.ps1 [start-number]
.DESCRIPTION speaks a countdown by text-to-speech (TTS)
.DESCRIPTION starts a countdown by text-to-speech (TTS)
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
@ -11,8 +11,9 @@ param([int]$StartNumber = 10)
try {
for ([int]$i = $StartNumber; $i -gt 0; $i--) {
& "$PSScriptRoot/speak-english.ps1" $i
start-sleep -milliseconds 1000
start-sleep -milliseconds 200
}
& "$PSScriptRoot/speak-english.ps1" "zero"
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -7,21 +7,20 @@
#>
param($Text = "")
if ($Text -eq "") { $Text = read-host "Enter the text to speak" }
if ("$Text" -eq "") { $Text = read-host "Enter the text to speak" }
try {
$Voice = new-object -ComObject SAPI.SPVoice
$Voices = $Voice.GetVoices()
foreach ($OtherVoice in $Voices) {
$Description = $OtherVoice.GetDescription()
if ($Description -like "*- English*") {
write-progress "$Text"
if ($Description -notlike "*- English*") { continue }
# write-progress "$Text"
$Voice.Voice = $OtherVoice
[void]$Voice.Speak($Text)
write-progress -complete "$Text"
# write-progress -complete "$Text"
exit 0
}
}
write-error "Sorry, no English text-to-speech (TTS) voice found"
exit 1
} catch {

View File

@ -14,14 +14,13 @@ try {
$Voices = $Voice.GetVoices()
foreach ($OtherVoice in $Voices) {
$Description = $OtherVoice.GetDescription()
if ($Description -like "*- German*") {
write-progress "$Text"
if ($Description -notlike "*- German*") { continue }
# write-progress "$Text"
$Voice.Voice = $OtherVoice
[void]$Voice.Speak($Text)
write-progress -complete "$Text"
# write-progress -complete "$Text"
exit 0
}
}
write-error "No German text-to-speech (TTS) voice found"
exit 1
} catch {