gTTS (Google Text-to-Speech), a Python library and CLI tool to interface with Google Translate's text-to-speech API. Write spoken mp3 data to a file, a file-like object (bytestring) for further audio manipulation.
Implementation:
#Step 1:importing the required libraries
from gtts import gTTS
import os
#Step2:store the text into text1 variable.
text1= "Sant Baba Bhag Singh University"
#Step3:"en" is the code for English language,Set the language type
language="en"
#Step4:gTTS function take 3 parameters=input text,language type,speed
obj = gTTS(text=text1,lang=language,slow=True)
#step5:save the audio file
obj.save("audio.mp3")
#step6:os automatically play the audio
os.system("audio.mp3")
Learn More: Speech to Text
0 Comments