mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-02 10:59:14 +01:00
Add speak-spanish.ps1
This commit is contained in:
parent
917825b5a7
commit
415d4a339d
@ -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-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-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-text.ps1, speaks the given text 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.
|
@ -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-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-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-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)
|
||||
|
@ -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])"
|
||||
|
@ -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])"
|
||||
|
@ -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])"
|
||||
|
@ -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
34
Scripts/speak-spanish.ps1
Executable 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user