Update speak-english.ps1

This commit is contained in:
Markus Fleschutz 2021-09-16 08:36:43 +02:00 committed by GitHub
parent d0edecd0ea
commit c13936a65f
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 English 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 "*- English*") { continue }
$Voice.Voice = $OtherVoice
[void]$Voice.Speak($Text)
[void]$Voice.Speak($text)
exit 0
}
write-error "No English text-to-speech voice found - please install one"
write-error "Sorry, no English text-to-speech voice found - please install one"
exit 1
} catch {
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"