Spaces:
Runtime error
Runtime error
# Import the required module | |
import pyttsx3 | |
from numpy.ma.core import concatenate | |
def generateMp3(text, number): | |
# Initialize the Pyttsx3 engine | |
pyttsx3.init(driverName='sapi5') | |
engine = pyttsx3.init() | |
voices = engine.getProperty('voices') | |
engine.setProperty('voice', voices[2].id) | |
newVoiceRate = 145 | |
engine.setProperty('rate', newVoiceRate) | |
# We can use file extension as mp3 and wav, both will work | |
fileName = "Ttldr - " + str(number) + ".mp3" | |
engine.save_to_file(text, fileName) | |
# Wait until above command is not finished. | |
engine.runAndWait() | |