Python text to speech

#1 : Using gtts .
first open CMD and write pip install gtts
then open python idle and start coding ;

Source-Code 


from gtts import gTTS
import os
myText = "Hello BROTHER I'm AKASH"
language = 'en'
output = gTTS(text=myText , lang=language , slow=False)
output.save("sraj.mp3")
os.system("Start sraj.mp3")





#2: using pyttsx3
first open CMD and write pip instal lpyttsx3
then open python idle and start coding ;

Source-Code 

import pyttsx3
engine = pyttsx3.init()
engine.say("Hello BROTHER I'm AKASH")
engine.runAndWait()



Python text to speech Python text to speech Reviewed by Coding Guy on November 06, 2019 Rating: 5

No comments:

Powered by Blogger.