Advertisement
Guest User

Untitled

a guest
Jun 27th, 2014
397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #
  2. # Script to play a sound file and make the computer speak at various intervals
  3. #
  4. # Skip down to the part labeled MODIFY THIS PART to change what the script does.
  5. # To run the script, you will need to use the following command on most systems:
  6. #   powershell -ExecutionPolicy Unrestricted texttospeech.ps1
  7. #
  8. # You can run this command from a command prompt, create a shortcut to the script
  9. # or run it as a scheduled task.
  10. #
  11.  
  12. #
  13. # Generate speech from text
  14. #
  15. function Say-Text {
  16.     param(
  17.         [Parameter(Mandatory=$true)]
  18.         $Text,
  19.  
  20.         [switch]
  21.         $Slow
  22.     )
  23.  
  24.     $object = New-Object -ComObject SAPI.SpVoice
  25.     if ($Slow) { $object.Rate = -5 }
  26.     $object.Speak($text) | Out-Null
  27. }
  28.  
  29. ##################
  30. # MODIFY THIS PART
  31.  
  32. # Replace the part after wmplayer.exe with the path to your sound file
  33. &"C:\Program Files (x86)\Windows Media Player\wmplayer.exe" "C:\Path\To\File.mp3"
  34.  
  35. # Use SayText to have the computer speak and Start-Sleep to change the timing between speech.
  36. Say-Text "Testing One, Two, Three."
  37. Start-Sleep -s 5        # Wait for 5 seconds before saying the next thing.
  38. Say-Text "Testing Four and Five." -Slow
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement