How to directly play speech in python without saving to mp3?

Viewed 2293

I am trying into convert text to speech in Python using the gTTS module. Is there a method you can use which does not involve saving the audio to an mp3 file and instead plays the it directly? I have looked online for a while but I still can't find a method which completely avoids saving to files. Thanks!

2 Answers

Try using pyttsx3. Usage:

import pyttsx3
engine = pyttsx3.init()
engine.say("I will speak this text")
engine.runAndWait()

This does not save audio to an mp3 file and works offline.

Link to source code

You can also use this function which will give you the option to modify the speed of the spoken text, in the example below, the speed is 178:

engine.setProperty("rate", 178)
Related