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

@ -196,6 +196,7 @@ speak-german.ps1, speaks the given text with a German text-to-speech (TTS) voice
speak-italian.ps1, speaks the given text with an Italian text-to-speech (TTS) voice speak-italian.ps1, speaks the given text with an Italian text-to-speech (TTS) voice
speak-joke.ps1, speaks a random Chuck Norris joke by text-to-speech (TTS) speak-joke.ps1, speaks a random Chuck Norris joke by text-to-speech (TTS)
speak-quote.ps1, speaks a random quote by text-to-speech (TTS) speak-quote.ps1, speaks a random quote by text-to-speech (TTS)
speak-spanish.ps1, speaks the given text with a Spanish text-to-speech (TTS) voice
speak-test.ps1, performs a speak test by text-to-speech (TTS) speak-test.ps1, performs a speak test by text-to-speech (TTS)
speak-text.ps1, speaks the given text by text-to-speech (TTS) speak-text.ps1, speaks the given text by text-to-speech (TTS)
speak-time.ps1, speaks the current time by text-to-speech (TTS) speak-time.ps1, speaks the current time by text-to-speech (TTS)

Can't render this file because it has a wrong number of fields in line 82.

View File

@ -31,6 +31,7 @@ Mega Collection of PowerShell Scripts
* [speak-italian.ps1](Scripts/speak-italian.ps1) - speaks the given text with an Italian text-to-speech (TTS) voice * [speak-italian.ps1](Scripts/speak-italian.ps1) - speaks the given text with an Italian text-to-speech (TTS) voice
* [speak-joke.ps1](Scripts/speak-joke.ps1) - speaks a random Chuck Norris joke by text-to-speech (TTS) * [speak-joke.ps1](Scripts/speak-joke.ps1) - speaks a random Chuck Norris joke by text-to-speech (TTS)
* [speak-quote.ps1](Scripts/speak-quote.ps1) - speaks a random quote by text-to-speech (TTS) * [speak-quote.ps1](Scripts/speak-quote.ps1) - speaks a random quote by text-to-speech (TTS)
* [speak-spanish.ps1](Scripts/speak-spanish.ps1) - speaks the given text with a Spanish text-to-speech (TTS) voice
* [speak-test.ps1](Scripts/speak-test.ps1) - performs a speak test by text-to-speech (TTS) * [speak-test.ps1](Scripts/speak-test.ps1) - performs a speak test by text-to-speech (TTS)
* [speak-text.ps1](Scripts/speak-text.ps1) - speaks the given text by text-to-speech (TTS) * [speak-text.ps1](Scripts/speak-text.ps1) - speaks the given text by text-to-speech (TTS)
* [speak-time.ps1](Scripts/speak-time.ps1) - speaks the current time by text-to-speech (TTS) * [speak-time.ps1](Scripts/speak-time.ps1) - speaks the current time by text-to-speech (TTS)

View File

@ -22,13 +22,11 @@ try {
foreach ($OtherVoice in $Voices) { foreach ($OtherVoice in $Voices) {
$Description = $OtherVoice.GetDescription() $Description = $OtherVoice.GetDescription()
if ($Description -notlike "*- English*") { continue } if ($Description -notlike "*- English*") { continue }
# write-progress "$Text"
$Voice.Voice = $OtherVoice $Voice.Voice = $OtherVoice
[void]$Voice.Speak($Text) [void]$Voice.Speak($Text)
# write-progress -complete "$Text"
exit 0 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 exit 1
} catch { } catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -26,7 +26,7 @@ try {
[void]$Voice.Speak($Text) [void]$Voice.Speak($Text)
exit 0 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 exit 1
} catch { } catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -26,7 +26,7 @@ try {
[void]$Voice.Speak($Text) [void]$Voice.Speak($Text)
exit 0 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 exit 1
} catch { } catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

View File

@ -26,7 +26,7 @@ try {
[void]$Voice.Speak($Text) [void]$Voice.Speak($Text)
exit 0 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 exit 1
} catch { } catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" 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
}