HomePythonPython text to speech save file audio file - Py convert text to voice male and female Python text to speech save file audio file - Py convert text to voice male and female Makarablue June 09, 2022 0 To run the py code below you need to install pyttsx3 first.pip install pyttsx3Example : import pyttsx3 import datetime engine = pyttsx3.init() #Rate rate = engine.getProperty('rate') engine.setProperty("rate", 150) volume = engine.getProperty('volume') print("volume is {0}".format(volume)) engine.setProperty("volume",0.9) voices = engine.getProperty("voices") # Male voice : voices[0].id # Female voice : voices[1].id engine.setProperty("voice", voices[0].id) src = "your_source_file.txt" content = open(src).read() now = datetime.datetime.now().strftime('%Y%m-%d%H-%M%S-') engine.save_to_file(content, "your_audio_folder/"+now+".mp3") #run engine.runAndWait() Tags Coding Python Newer Older