Advertisement
dyeske

powershell text to voice

Jul 3rd, 2024 (edited)
613
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. Param(
  3.   [Parameter(Mandatory = $False)]
  4.   [string]$text
  5. )
  6.  
  7. if (!($text)) {
  8.   $text = "no text was provided to the script"
  9. }
  10.  
  11. Write-Output $text
  12. $spk = New-Object -ComObject SAPI.SpVoice
  13. $spk.Speak($text)
  14. Add-Type -AssemblyName System.Speech
  15. $speech = New-Object System.Speech.Synthesis.SpeechSynthesizer
  16.  
  17. Foreach ($voice in $speech.GetInstalledVoices()) {
  18.   $Voice.VoiceInfo | Select-Object Gender, Name, Culture, Description
  19. }
  20.  
  21. $speech.SelectVoice("Microsoft Zira Desktop")
  22. $speech.Speak($text)
  23.  
  24.  
  25.  
  26.  
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement