Update speak-english.ps1

This commit is contained in:
Markus Fleschutz 2022-12-19 08:34:10 +01:00 committed by GitHub
parent 4bb056654f
commit e6ef816d5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,12 +16,12 @@
param([string]$text = "")
try {
if ("$text" -eq "") { $text = read-host "Enter the English text to speak" }
if ("$text" -eq "") { $text = Read-Host "Enter the English text to speak" }
$TTS = New-Object -ComObject SAPI.SPVoice
foreach ($Voice in $TTS.GetVoices()) {
if ($Voice.GetDescription() -like "*- English*") {
$TTS.Voice = $Voice
foreach ($voice in $TTS.GetVoices()) {
if ($voice.GetDescription() -like "*- English*") {
$TTS.Voice = $voice
[void]$TTS.Speak($text)
exit 0 # success
}