Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

How to convert text into audio file in python?

"""
Convert text into audio file.
"""
# pip install playsound
from playsound import playsound
# pip install gtts
from gtts import gTTS

audio_file = "speech.mp3"
text_to_convert = "Sample text to convert"
language = "en"
speech = gTTS(text=text_to_convert, lang=language, slow=False)

speech.save(audio_file)
playsound(audio_file)
 
PREVIOUS NEXT
Tagged: #How #convert #text #audio #file
ADD COMMENT
Topic
Name
3+2 =