Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # Script to play a sound file and make the computer speak at various intervals
- #
- # Skip down to the part labeled MODIFY THIS PART to change what the script does.
- # To run the script, you will need to use the following command on most systems:
- # powershell -ExecutionPolicy Unrestricted texttospeech.ps1
- #
- # You can run this command from a command prompt, create a shortcut to the script
- # or run it as a scheduled task.
- #
- #
- # Generate speech from text
- #
- function Say-Text {
- param(
- [Parameter(Mandatory=$true)]
- $Text,
- [switch]
- $Slow
- )
- $object = New-Object -ComObject SAPI.SpVoice
- if ($Slow) { $object.Rate = -5 }
- $object.Speak($text) | Out-Null
- }
- ##################
- # MODIFY THIS PART
- # Replace the part after wmplayer.exe with the path to your sound file
- &"C:\Program Files (x86)\Windows Media Player\wmplayer.exe" "C:\Path\To\File.mp3"
- # Use SayText to have the computer speak and Start-Sleep to change the timing between speech.
- Say-Text "Testing One, Two, Three."
- Start-Sleep -s 5 # Wait for 5 seconds before saying the next thing.
- Say-Text "Testing Four and Five." -Slow
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement