Added speak-english.ps1

This commit is contained in:
Markus Fleschutz 2021-02-08 19:32:45 +01:00
parent d362968965
commit a5ba0c2d34
3 changed files with 31 additions and 0 deletions

View File

@ -77,6 +77,7 @@ SHA256.ps1, prints the SHA256 checksum of the given file
simulate-matrix.ps1, simulates the Matrix (fun)
simulate-presence.ps1, simulates the human presence against burglars
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)
speak-file.ps1, speaks the content of the given text file by text-to-speech (TTS)
speak-joke.ps1, speaks the next joke by text-to-speech (TTS)

1 Filename Description
77 simulate-matrix.ps1 simulates the Matrix (fun)
78 simulate-presence.ps1 simulates the human presence against burglars
79 speak-date.ps1 speaks the current date by text-to-speech (TTS)
80 speak-english.ps1 speaks the given text with an English text-to-speech (TTS) voice
81 speak-epub.ps1 speaks the content of the given Epub file by text-to-speech (TTS)
82 speak-file.ps1 speaks the content of the given text file by text-to-speech (TTS)
83 speak-joke.ps1 speaks the next joke by text-to-speech (TTS)

View File

@ -85,6 +85,7 @@ The following PowerShell scripts can be found in the [Scripts/](Scripts/) subfol
* [simulate-matrix.ps1](Scripts/simulate-matrix.ps1) - simulates the Matrix (fun)
* [simulate-presence.ps1](Scripts/simulate-presence.ps1) - simulates the human presence against burglars
* [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)
* [speak-file.ps1](Scripts/speak-file.ps1) - speaks the content of the given text file by text-to-speech (TTS)
* [speak-joke.ps1](Scripts/speak-joke.ps1) - speaks the next joke by text-to-speech (TTS)

29
Scripts/speak-english.ps1 Executable file
View File

@ -0,0 +1,29 @@
#!/snap/bin/powershell
<#
.SYNTAX ./speak-english.ps1 [<text>]
.DESCRIPTION speaks the given text with an English text-to-speech (TTS) voice
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
param($Text = "")
try {
$Voice = new-object -ComObject SAPI.SPVoice
$Voices = $Voice.GetVoices()
foreach ($OtherVoice in $Voices) {
$Description = $OtherVoice.GetDescription()
if ($Description -like "*- English*") {
write-progress "$Text"
$Voice.Voice = $OtherVoice
[void]$Voice.Speak($Text)
write-progress -complete ""
exit 0
}
}
write-error "Sorry, no English text-to-speech (TTS) voice found"
exit 1
} catch {
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}