0

So, I've been using Google Assistant on my Raspberry Pi 3 to make a sort of home assistant. The speech recognition works perfectly with Google Assistant and I'm able to say my commands and convert them to text.

For Text to Speech, I've been using, gTTS with my own commands. So, I feed the gTTS with my own lines and it converts it to an mp3 file and plays it. However, it being an online service, it seems to take a couple of seconds to convert. Around 8-9 to be exact. I was wondering if there was any way of reducing that time, as it seems to be a huge gap of me waiting there for the text to convert. I've tried using other TTS services such as espeak but do not find their voice appealing.

I've been using pretty basic code for gTTS, just for calling it and saving the file import os from gtts import gTTS

import sys
def speak(audioString):
    print(audioString)
    tts = gTTS(text=audioString, lang='en')
    tts.save("audio.mp3")
    os.system("mpg321 -q  audio.mp3")


if (len(sys.argv)>=1):
    if (sys.argv[1] !=""):
        speak(sys.argv[1])
    else: 
        print ("No arguments found")
else: 
    print ("No Url path found")
LordTyrion
  • 1
  • 1
  • 3

0 Answers0