Moxie Moosers
Moxie Moosers

Reputation: 11

python code error for gTTS (google text to speech) module

when I enter the command from

.gtts import gTTS

tts = gets.tts.gTTS(text='Hello', lang='en')
tts.save("hello.mp3")'

it comes up with an error code saying

ValueError: Attempted relative import in non-package

I have tried to fix my gtts for a while now as before I got an error code saying

no module named 'gtts'

but I had it installed. so I went to this and found out if I use .gtts it will come up with the other error code that I believe is better than the last error code I got

Upvotes: 1

Views: 513

Answers (1)

bipin_s
bipin_s

Reputation: 465

from gtts import gTTS
myobj = gTTS(text="Hello', lang='en')
myobj.save('hello.mp3')

the above should work. gtts version should be 1.1.2

Upvotes: 1

Related Questions