mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-16 07:38:15 +02:00
Added try and catch
This commit is contained in:
@ -12,11 +12,14 @@ $Speed = -1 # -10 is slowest, 10 is fastest
|
||||
$TargetWavFile = "spoken.wav"
|
||||
|
||||
# Run:
|
||||
Add-Type -AssemblyName System.Speech
|
||||
$SpeechSynthesizer = New-Object System.Speech.Synthesis.SpeechSynthesizer
|
||||
# $SpeechSynthesizer.SelectVoice("Microsoft Eva Mobile")
|
||||
$SpeechSynthesizer.Rate = $Speed
|
||||
$SpeechSynthesizer.SetOutputToWaveFile($TargetWavFile)
|
||||
$SpeechSynthesizer.Speak($Text)
|
||||
$SpeechSynthesizer.Dispose()
|
||||
exit 0
|
||||
try {
|
||||
Add-Type -AssemblyName System.Speech
|
||||
$SpeechSynthesizer = New-Object System.Speech.Synthesis.SpeechSynthesizer
|
||||
# $SpeechSynthesizer.SelectVoice("Microsoft Eva Mobile")
|
||||
$SpeechSynthesizer.Rate = $Speed
|
||||
$SpeechSynthesizer.SetOutputToWaveFile($TargetWavFile)
|
||||
$SpeechSynthesizer.Speak($Text)
|
||||
$SpeechSynthesizer.Dispose()
|
||||
exit 0
|
||||
} catch { Write-Error $Error[0] }
|
||||
exit 1
|
||||
|
Reference in New Issue
Block a user