mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-04-25 03:18:16 +02:00
Added speak-english.ps1
This commit is contained in:
parent
d362968965
commit
a5ba0c2d34
@ -77,6 +77,7 @@ SHA256.ps1, prints the SHA256 checksum of the given file
|
|||||||
simulate-matrix.ps1, simulates the Matrix (fun)
|
simulate-matrix.ps1, simulates the Matrix (fun)
|
||||||
simulate-presence.ps1, simulates the human presence against burglars
|
simulate-presence.ps1, simulates the human presence against burglars
|
||||||
speak-date.ps1, speaks the current date 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)
|
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-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)
|
speak-joke.ps1, speaks the next joke by text-to-speech (TTS)
|
||||||
|
|
@ -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-matrix.ps1](Scripts/simulate-matrix.ps1) - simulates the Matrix (fun)
|
||||||
* [simulate-presence.ps1](Scripts/simulate-presence.ps1) - simulates the human presence against burglars
|
* [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-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-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-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)
|
* [speak-joke.ps1](Scripts/speak-joke.ps1) - speaks the next joke by text-to-speech (TTS)
|
||||||
|
29
Scripts/speak-english.ps1
Executable file
29
Scripts/speak-english.ps1
Executable 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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user