Add speak-spanish.ps1

This commit is contained in:
Markus Fleschutz
2021-08-19 12:11:22 +02:00
parent 917825b5a7
commit 415d4a339d
7 changed files with 40 additions and 6 deletions

View File

@ -22,13 +22,11 @@ try {
foreach ($OtherVoice in $Voices) {
$Description = $OtherVoice.GetDescription()
if ($Description -notlike "*- English*") { continue }
# write-progress "$Text"
$Voice.Voice = $OtherVoice
[void]$Voice.Speak($Text)
# write-progress -complete "$Text"
exit 0
}
write-error "Sorry, no English text-to-speech (TTS) voice found"
write-error "No English text-to-speech voice found - please install one"
exit 1
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -26,7 +26,7 @@ try {
[void]$Voice.Speak($Text)
exit 0
}
write-error "Sorry, no French text-to-speech (TTS) voice found"
write-error "No French text-to-speech voice found - please install one"
exit 1
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -26,7 +26,7 @@ try {
[void]$Voice.Speak($Text)
exit 0
}
write-error "No German text-to-speech (TTS) voice found"
write-error "No German text-to-speech voice found - please install one"
exit 1
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -26,7 +26,7 @@ try {
[void]$Voice.Speak($Text)
exit 0
}
write-error "No Italian text-to-speech (TTS) voice found"
write-error "No Italian text-to-speech voice found - please install one"
exit 1
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

34
Scripts/speak-spanish.ps1 Executable file
View File

@ -0,0 +1,34 @@
<#
.SYNOPSIS
speak-spanish.ps1 [<text>]
.DESCRIPTION
Speaks the given text with a Spanish text-to-speech (TTS) voice
.EXAMPLE
PS> .\speak-spanish.ps1 Hola
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz
License: CC0
#>
param([string]$Text = "")
try {
if ($Text -eq "") { $Text = read-host "Enter the text to speak" }
$Voice = new-object -ComObject SAPI.SPVoice
$Voices = $Voice.GetVoices()
foreach ($OtherVoice in $Voices) {
$Description = $OtherVoice.GetDescription()
if ($Description -notlike "*- Spanish*") { continue }
$Voice.Voice = $OtherVoice
[void]$Voice.Speak($Text)
exit 0
}
write-error "No Spanish text-to-speech voice found - please install one"
exit 1
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}