Update speak-spanish.ps1

This commit is contained in:
Markus Fleschutz 2021-09-16 08:40:58 +02:00 committed by GitHub
parent 0fb338466f
commit 443a762a70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,21 +11,21 @@
https://github.com/fleschutz/PowerShell
#>
param([string]$Text = "")
param([string]$text = "")
try {
if ($Text -eq "") { $Text = read-host "Enter the text to speak" }
if ($text -eq "") { $text = read-host "Enter the Spanish text to speak" }
$Voice = new-object -ComObject SAPI.SPVoice
$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)
[void]$Voice.Speak($text)
exit 0
}
write-error "No Spanish text-to-speech voice found - please install one"
write-error "Sorry, no Spanish text-to-speech voice found - please install one"
exit 1
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"