Guest User

Untitled

a guest
May 20th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #import below module for text to speech conversion.
  2. from gtts import gTTS
  3.  
  4. #import below module to play saved audio files
  5. import os
  6.  
  7. #text to be converted
  8. mytxt = 'Hello Python..! This is text to speech conversion'
  9.  
  10. #specifying the language
  11. language = 'en'
  12.  
  13. #creating an object of gTTS with required parameters
  14. myobj = gTTS(text=mytxt, lang=language, slow=False)
  15.  
  16. # Saving the converted audio in a mp3 file named 'example'
  17. myobj.save("example.mp3")
  18.  
  19. # Playing the converted file
  20. os.system("mpg321 example.mp3")
Add Comment
Please, Sign In to add comment