Spaces:
Runtime error
Runtime error
File size: 628 Bytes
b6204d2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# 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()
|