mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-08 00:54:04 +01:00
Improve the speak-*.ps1 scripts
This commit is contained in:
parent
71b72611b7
commit
81edcadf1f
@ -20,12 +20,13 @@ try {
|
||||
|
||||
$TTSVoice = New-Object -ComObject SAPI.SPVoice
|
||||
foreach ($Voice in $TTSVoice.GetVoices()) {
|
||||
if ($Voice.GetDescription() -notlike "*- English*") { continue }
|
||||
$TTSVoice.Voice = $Voice
|
||||
[void]$TTSVoice.Speak($text)
|
||||
exit 0 # success
|
||||
if ($Voice.GetDescription() -like "*- English*") {
|
||||
$TTSVoice.Voice = $Voice
|
||||
[void]$TTSVoice.Speak($text)
|
||||
exit 0 # success
|
||||
}
|
||||
}
|
||||
throw "No English text-to-speech voice found - please install one"
|
||||
throw "No English text-to-speech voice found - please install one."
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
exit 1
|
||||
|
@ -3,7 +3,6 @@
|
||||
Speaks text with a French text-to-speech voice
|
||||
.DESCRIPTION
|
||||
This script speaks the given text with a French text-to-speech (TTS) voice.
|
||||
Requires that a French TTS voice is installed.
|
||||
.PARAMETER text
|
||||
Specifies the text to speak
|
||||
.EXAMPLE
|
||||
@ -19,15 +18,15 @@ param([string]$text = "")
|
||||
try {
|
||||
if ($text -eq "") { $text = read-host "Enter the French text to speak" }
|
||||
|
||||
$CurrentVoice = New-Object -ComObject SAPI.SPVoice
|
||||
$Voices = $CurrentVoice.GetVoices()
|
||||
foreach ($Voice in $Voices) {
|
||||
if ($Voice.GetDescription() -notlike "*- French*") { continue }
|
||||
$CurrentVoice.Voice = $Voice
|
||||
[void]$CurrentVoice.Speak($text)
|
||||
exit 0 # success
|
||||
$TTSVoice = New-Object -ComObject SAPI.SPVoice
|
||||
foreach ($Voice in $TTSVoice.GetVoices()) {
|
||||
if ($Voice.GetDescription() -like "*- French*") {
|
||||
$TTSVoice.Voice = $Voice
|
||||
[void]$TTSVoice.Speak($text)
|
||||
exit 0 # success
|
||||
}
|
||||
}
|
||||
throw "No French text-to-speech voice found - please install one"
|
||||
throw "No French text-to-speech voice found - please install one."
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
exit 1
|
||||
|
@ -3,7 +3,6 @@
|
||||
Speaks text with a German text-to-speech voice
|
||||
.DESCRIPTION
|
||||
This script speaks the given text with a German text-to-speech (TTS) voice.
|
||||
Requires that a German TTS voice is installed.
|
||||
.PARAMETER text
|
||||
Specifies the text to speak
|
||||
.EXAMPLE
|
||||
@ -19,13 +18,13 @@ param([string]$text = "")
|
||||
try {
|
||||
if ($text -eq "") { $text = read-host "Enter the German text to speak" }
|
||||
|
||||
$CurrentVoice = New-Object -ComObject SAPI.SPVoice
|
||||
$Voices = $CurrentVoice.GetVoices()
|
||||
foreach ($Voice in $Voices) {
|
||||
if ($Voice.GetDescription() -notlike "*- German*") { continue }
|
||||
$CurrentVoice.Voice = $Voice
|
||||
[void]$CurrentVoice.Speak($text)
|
||||
exit 0 # success
|
||||
$TTSVoice = New-Object -ComObject SAPI.SPVoice
|
||||
foreach ($Voice in $TTSVoice.GetVoices()) {
|
||||
if ($Voice.GetDescription() -like "*- German*") {
|
||||
$TTSVoice.Voice = $Voice
|
||||
[void]$TTSVoice.Speak($text)
|
||||
exit 0 # success
|
||||
}
|
||||
}
|
||||
throw "No German text-to-speech voice found - please install one"
|
||||
} catch {
|
||||
|
@ -3,7 +3,6 @@
|
||||
Speaks text with an Italian text-to-speech voice
|
||||
.DESCRIPTION
|
||||
This script speaks the given text with an Italian text-to-speech (TTS) voice.
|
||||
Requires that an Italian TTS voice is installed.
|
||||
.PARAMETER text
|
||||
Specifies the text to speak
|
||||
.EXAMPLE
|
||||
@ -19,15 +18,15 @@ param([string]$text = "")
|
||||
try {
|
||||
if ($text -eq "") { $text = read-host "Enter the Italian text to speak" }
|
||||
|
||||
$CurrentVoice = New-Object -ComObject SAPI.SPVoice
|
||||
$Voices = $CurrentVoice.GetVoices()
|
||||
foreach ($Voice in $Voices) {
|
||||
if ($Voice.GetDescription() -notlike "*- Italian*") { continue }
|
||||
$CurrentVoice.Voice = $Voice
|
||||
[void]$CurrentVoice.Speak($text)
|
||||
exit 0 # success
|
||||
$TTSVoice = New-Object -ComObject SAPI.SPVoice
|
||||
foreach ($Voice in $TTSVoice.GetVoices()) {
|
||||
if ($Voice.GetDescription() -like "*- Italian*") {
|
||||
$TTSVoice.Voice = $Voice
|
||||
[void]$TTSVoice.Speak($text)
|
||||
exit 0 # success
|
||||
}
|
||||
}
|
||||
throw "No Italian text-to-speech voice found - please install one"
|
||||
throw "No Italian text-to-speech voice found - please install one."
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
exit 1
|
||||
|
@ -3,7 +3,6 @@
|
||||
Speaks text with a Spanish text-to-speech voice
|
||||
.DESCRIPTION
|
||||
This script speaks the given text with a Spanish text-to-speech (TTS) voice.
|
||||
Requires that a Spanish TTS voice is installed.
|
||||
.PARAMETER text
|
||||
Specifies the text to speak
|
||||
.EXAMPLE
|
||||
@ -19,15 +18,15 @@ param([string]$text = "")
|
||||
try {
|
||||
if ($text -eq "") { $text = read-host "Enter the Spanish text to speak" }
|
||||
|
||||
$CurrentVoice = New-Object -ComObject SAPI.SPVoice
|
||||
$Voices = $CurrentVoice.GetVoices()
|
||||
foreach ($Voice in $Voices) {
|
||||
if ($Voice.GetDescription() -notlike "*- Spanish*") { continue }
|
||||
$CurrentVoice.Voice = $Voice
|
||||
[void]$CurrentVoice.Speak($text)
|
||||
exit 0 # success
|
||||
$TTSVoice = New-Object -ComObject SAPI.SPVoice
|
||||
foreach ($Voice in $TTSVoice.GetVoices()) {
|
||||
if ($Voice.GetDescription() -like "*- Spanish*") { continue }
|
||||
$TTSVoice.Voice = $Voice
|
||||
[void]$TTSVoice.Speak($text)
|
||||
exit 0 # success
|
||||
}
|
||||
}
|
||||
throw "No Spanish text-to-speech voice found - please install one"
|
||||
throw "No Spanish text-to-speech voice found - please install one."
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
exit 1
|
||||
|
Loading…
Reference in New Issue
Block a user