Search code examples
python-3.xgtts

Google text- to-Speech gTTs not working as expected


I installed gtts using "pip3 install gTTs", but I am getting this error whenever I run the program.

from gtts import gTTs. ImportError: cannot import name 'gTTs'

This is the part of the code which is generating the error.I am using speak() as a module.

from os import system
from gtts import gTTs



def speak(text):
   tts = gTTS(text,lang = 'en')
   tts.save("speech.mp3")
   system("mpg321 speech.mp3")

I checked whether gtts is installed or not using "pip3 freeze" and it shows gtts amongst the packages


Solution

  • Replace from gtts import gTTs with from gtts import gTTS