0
Is there any other way to play sound in pyton from gtts?
I was working on a little project, and I am using google text to speech (gtts) module to convert words to sound, then I had to save that sound as mp3 then play it and delete it after, is there any idea to make it work faster? import os import gtts from playsound import playsound def say(text) : file = "x.mp3" tts = gtts.gTTS(text) tts.save(file) playsound(file) os.remove(file)
4 Respuestas
+ 1
You want to directly play the sound without saving it.
+ 1
Read documentation of gtts you will probably find function for that use that one instead of gtts.gTTS()
+ 1
Will this work?
```py
def say(text):
playsound(gtts.gTTS(text))
```
+ 1
KUMAR SHANU I actually tried doing directly using playsound, It didn't work. I saw the documentation and they use the same way that I did there, unless if we were talking about gtts-cli, but I don't think it is better than the ordinary way.