Live Example
Go to text-to-audio Exampleimport pyttsx3
def text_to_audio(text, output_file):
# Initialize the pyttsx3 engine
engine = pyttsx3.init()
# Save the audio to a file
engine.save_to_file(text, output_file)
# Run the engine in the background
engine.runAndWait()
# Example usage
text = '''Good moring, how are you, '''
output_file = "saveFile.mp3"
text_to_audio(text, output_file)
Tags:
PYTHON
.png)