Skip to content

Instantly share code, notes, and snippets.

@lawrence-jeff
Last active March 28, 2018 18:19
Show Gist options
  • Save lawrence-jeff/c85b634df073e37b66ef14695bf61d1a to your computer and use it in GitHub Desktop.
Save lawrence-jeff/c85b634df073e37b66ef14695bf61d1a to your computer and use it in GitHub Desktop.
Takes a text file of statements and converts each to a wav file via speech synthesis
#Based on https://gist.github.com/lazywinadmin/51619a0e47f4c8e7a8b7
Add-Type -AssemblyName System.speech
mkdir C:\users\$env:username\Desktop\Compliments
#Populate list of statements/compliments to read
$Statements=Get-Content "C:\users\$env:username\Desktop\Compliments.txt"
$FileName= 1
foreach ($Statement in $Statements)
{
$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer
$speak.SelectVoice('Microsoft Zira Desktop')
$speak.rate = 0
$speak.Volume = 100
$speak.SetOutputToWaveFile("C:\users\$env:username\Desktop\Compliments\" + $FileName + "-Compliment.wav")
$speak.Speak($Statement)
$speak.Dispose() # this stop and save the wav file
++$FileName
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment