Text to Speech Conversion in Python through gtts module



# pip install gTTS to install the required module
# gTTS is Google Text to Speech API

from gtts import gTTS
import os

mytext="hi, this is abdur rehmaan."

mylanguage="en"

obj = gTTS(text=mytext, lang=mylanguage, slow=False)

obj.save("hi.mp3") # saves the text as mp3 file

os.system("hi.mp3") # play the converted mp3 file



Comments

Popular posts from this blog

Quotation marks to wrap an element in HTML

What is the difference between iostream and iostream.h in cpp?

The Basic Structure of a Full-Stack Web App