Answers for "How to convert text into audio file in python?"

1

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)
Posted by: Guest on April-21-2022
1

text to audio in python

import pyttsx3  
s = pyttsx3.init()  
data = "Sample Text"  
s.say(data)  
s.runAndWait()
Posted by: Guest on April-15-2022

Code answers related to "How to convert text into audio file in python?"

Python Answers by Framework

Browse Popular Code Answers by Language