Saying something
The following simple
PowerShell statements make the computer say
hello world.
$sapi = new-object -comObject sapi.spVoice
$null = $sapi.speak('Hello world')
It is also possible to say something with
VBScript:
option explicit
dim sapi
set sapi = createObject("sapi.spVoice")
sapi.speak("Hello world.")
Speak text in German
The following PowerShell snippet says something in German:
$text = 'Guten tag'
$sapi = new-object -comObject sapi.spVoice
$germanWasFound = $false
foreach ($voice in $sapi.getVoices()) {
if ($voice.GetDescription() -like "*- German*") {
$sapi.voice = $voice
$null = $sapi.speak($text)
$germanWasFound = $true
break
}
}
if (-not $germanWasFound) {
write-host "The german voice does not seem to be installed"
}