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!
Asked
Active
Viewed 4,129 times
4
-
as I remeber this question was few times on Stackoverflow and first you should find them. You can use `io.Bytes` to create file-like object in memory - and this method is used to work with images without saving on disk - but as I rember problem is that modules which can play audio can't work with file-like object but they need filename. – furas Aug 11 '20 at 17:04
2 Answers
5
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.

thisisnotshort
- 342
- 3
- 11
1
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)

Roshin Raphel
- 2,612
- 4
- 22
- 40

Andreistolo
- 11
- 1