Update the speak-*.ps1 scripts

This commit is contained in:
Markus Fleschutz
2023-08-06 11:27:49 +02:00
parent 33a42c2547
commit 001c19a2b3
21 changed files with 88 additions and 88 deletions

View File

@ -16,17 +16,17 @@
param([string]$text = "")
try {
if ($text -eq "") { $text = read-host "Enter the Danish text to speak" }
if ($text -eq "") { $text = Read-Host "Enter the Danish text to speak" }
$TTS = New-Object -ComObject SAPI.SPVoice
foreach ($Voice in $TTS.GetVoices()) {
if ($Voice.GetDescription() -like "*- Danish*") {
$TTS.Voice = $Voice
foreach ($voice in $TTS.GetVoices()) {
if ($voice.GetDescription() -like "*- Danish*") {
$TTS.Voice = $voice
[void]$TTS.Speak($text)
exit 0 # success
}
}
throw "No Danish voice for text-to-speech (TTS) found - please install one"
throw "No Danish text-to-speech voice found - please install one"
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1