2021-04-07 11:53:57 +02:00
|
|
|
#!/usr/bin/pwsh
|
2020-12-29 15:14:21 +01:00
|
|
|
<#
|
2021-04-14 14:16:15 +02:00
|
|
|
.SYNTAX convert-txt2wav.ps1
|
2021-03-22 20:10:18 +01:00
|
|
|
.DESCRIPTION converts the given text into an audio .WAV file
|
|
|
|
.LINK https://github.com/fleschutz/PowerShell
|
|
|
|
.NOTES Author: Markus Fleschutz / License: CC0
|
2020-12-29 15:14:21 +01:00
|
|
|
#>
|
2020-11-06 15:30:14 +01:00
|
|
|
|
|
|
|
$Text = "Hello, my name ist Bond, James Bond"
|
|
|
|
$Speed = -1 # -10 is slowest, 10 is fastest
|
|
|
|
$TargetWavFile = "spoken.wav"
|
|
|
|
|
|
|
|
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
|
2020-12-09 10:30:55 +01:00
|
|
|
} catch {
|
2021-02-16 10:03:20 +01:00
|
|
|
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
2020-12-09 10:30:55 +01:00
|
|
|
exit 1
|
|
|
|
}
|