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