mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-03-26 14:26:10 +01:00
Update convert-txt2wav.ps1
This commit is contained in:
parent
e0a8a3b53b
commit
df7cbfab55
@ -1,21 +1,19 @@
|
|||||||
#!/usr/bin/pwsh
|
#!/usr/bin/pwsh
|
||||||
<#
|
<#
|
||||||
.SYNTAX convert-txt2wav.ps1
|
.SYNTAX convert-txt2wav.ps1 [<text>] [<wav-file>]
|
||||||
.DESCRIPTION converts the given text into an audio .WAV file
|
.DESCRIPTION converts the given text to a .WAV audio file
|
||||||
.LINK https://github.com/fleschutz/PowerShell
|
.LINK https://github.com/fleschutz/PowerShell
|
||||||
.NOTES Author: Markus Fleschutz / License: CC0
|
.NOTES Author: Markus Fleschutz / License: CC0
|
||||||
#>
|
#>
|
||||||
|
|
||||||
$Text = "Hello, my name ist Bond, James Bond"
|
param($Text = "", $WavFile = "")
|
||||||
$Speed = -1 # -10 is slowest, 10 is fastest
|
if ($Text -eq "") { $Text = read-host "Enter text to speak" }
|
||||||
$TargetWavFile = "spoken.wav"
|
if ($WavFile -eq "") { $WavFile = read-host "Enter .WAV file to save to" }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Add-Type -AssemblyName System.Speech
|
Add-Type -AssemblyName System.Speech
|
||||||
$SpeechSynthesizer = New-Object System.Speech.Synthesis.SpeechSynthesizer
|
$SpeechSynthesizer = New-Object System.Speech.Synthesis.SpeechSynthesizer
|
||||||
# $SpeechSynthesizer.SelectVoice("Microsoft Eva Mobile")
|
$SpeechSynthesizer.SetOutputToWaveFile($tWavFile)
|
||||||
$SpeechSynthesizer.Rate = $Speed
|
|
||||||
$SpeechSynthesizer.SetOutputToWaveFile($TargetWavFile)
|
|
||||||
$SpeechSynthesizer.Speak($Text)
|
$SpeechSynthesizer.Speak($Text)
|
||||||
$SpeechSynthesizer.Dispose()
|
$SpeechSynthesizer.Dispose()
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
Reference in New Issue
Block a user