how to record pyttsx3 file using python 1

how to record pyttsx3 file using python

import pyttsx3
from gtts import gTTS

engine = pyttsx3.init(driverName='sapi5')
infile = "tanjil.txt"
f = open(infile, 'r')
theText =

#Saving part starts from here 
tts = gTTS(text=theText, lang='en')"saved_file.mp3")
print("File saved!")

Here is what the above code is Doing:
1. We are importing the gTTS module.
2. We are creating a variable called tts.
3. We are passing the text we want to convert to speech to the gTTS module.
4. We are saving the converted audio to a file called saved_file.mp3.
5. We are printing a message to let us know that the file has been saved.

Similar Posts