GithubHelp home page GithubHelp logo

Comments (23)

jhoelzl avatar jhoelzl commented on May 18, 2024 3

Maybe this is related to http://stackoverflow.com/questions/16981921/relative-imports-in-python-3.
What is the name of your script file? It should no be gtts.py.

Maybe try something like this:

import gtts

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

or remove the dots in the import command in __init__.py

from gtts.

RohitKumar2511 avatar RohitKumar2511 commented on May 18, 2024 2

Brother, @ajayprajapat171, when I can't find out what's the error is... I just unistalled and reinstalled... finally error got solved

from gtts.

jhoelzl avatar jhoelzl commented on May 18, 2024 1

How have you installed the module?

Verify with pip list if gTTS is installed in your environment.

When you have activated your virtual environment, run

pip install gTTS without sudo, otherwise it will be installed in your main python folder of your operating system.

from gtts.

philipposslicher avatar philipposslicher commented on May 18, 2024 1

Ok so it I didn't know that the script shouldnt be named after the module. I have fixed it and now it seems to run. Now I'm wondering, is it possible for gTTS to speak the text without needing to write to a file, then playing it back?

from gtts.

 avatar commented on May 18, 2024 1

@philipposslicher
I am also having the same problem with gtts module how did you corrected can you pls explain it.
AttributeError: module 'gtts_1' has no attribute 'gTTs'

from gtts.

redixhumayun avatar redixhumayun commented on May 18, 2024 1

Hi, this seems to still be an issue.

I am using
-macOS Mojave 10.14.3
-Python 3.7
-gTTs 2.0.3
-gTTs-token 1.1.3

from gtts.

philipposslicher avatar philipposslicher commented on May 18, 2024

I installed it with pip install gTTS. I have checked its installed in the virtualenv, running import gtts (I ran this just to test if its installed) shows thats its installed.
Output of pip list

gTTS (1.1.6)
gTTS-token (1.1.1)
pip (9.0.1)
PyAudio (0.2.9)
requests (2.11.1)
setuptools (28.8.0)
SpeechRecognition (3.4.6)
wheel (0.30.0a0)

from gtts.

jhoelzl avatar jhoelzl commented on May 18, 2024

and in your environment, the module files exist under lib/python3.5/site-packages/gtts ?

from gtts.

philipposslicher avatar philipposslicher commented on May 18, 2024

Yep, both gtts, gtts_token, gTTS_token-1.1.1.dist-info, and gTTS-1.1.6.dist-info

from gtts.

jhoelzl avatar jhoelzl commented on May 18, 2024

Could you try the command from gtts import gTTS using python -i in your environment?

from gtts.

philipposslicher avatar philipposslicher commented on May 18, 2024

It gives me this:
Traceback (most recent call last):
File "", line 1, in
ImportError: cannot import name 'gTTS'

from gtts.

jhoelzl avatar jhoelzl commented on May 18, 2024

You could try this instead:

import gtts

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

from gtts.

philipposslicher avatar philipposslicher commented on May 18, 2024

That gives this though:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'gtts' has no attribute 'gTTS'

from gtts.

jhoelzl avatar jhoelzl commented on May 18, 2024

Currently not, i also requested this feature in #26

from gtts.

philipposslicher avatar philipposslicher commented on May 18, 2024

What would be recommended for playing a file, and also deleting (cause it would be temp)

from gtts.

jhoelzl avatar jhoelzl commented on May 18, 2024

You can do this to play the file and then remove it:

from gtts import gTTS
import os

filename = "temp"
tts = gTTS(text='Hello', lang='en')
tts.save(filename + ".mp3")

# Convert MP3 to Wav and Play
os.system('avconv -i ' + filename + '.mp3 -ac 1 -ar 44100 '  + filename + '.wav' )
os.system('aplay ' + filename+'.wav')

os.remove(filename+'.wav')
os.remove(filename+'.mp3')

from gtts.

JaiSh12345 avatar JaiSh12345 commented on May 18, 2024

I wrote >>import gtts
I am getting:
Traceback (most recent call last): File "<pyshell#10>", line 1, in <module> import gtts File "C:\Python34\lib\gtts\__init__.py", line 3, in <module> from .tts import gTTS, gTTSError File "C:\Python34\lib\gtts\tts.py", line 6, in <module> from gtts_token import gtts_token ImportError: No module named 'gtts_token'
What to do?

from gtts.

JaiSh12345 avatar JaiSh12345 commented on May 18, 2024

Then I tried:
>>> from gtts import gTTS
>>> gTTS('Hello')
Output? This:
Traceback (most recent call last): File "<pyshell#14>", line 1, in <module> gTTS('Hello') File "C:\Python34\lib\gtts\tts.py", line 140, in __init__ self.token = gtts_token.Token() NameError: name 'gtts_token' is not defined

from gtts.

seriadiallo avatar seriadiallo commented on May 18, 2024

hello rerun this command first

pip install gTTS
it seems that this command crashed ,
then retry

from gtts.

RohitKumar2511 avatar RohitKumar2511 commented on May 18, 2024

Traceback (most recent call last):
File "C:/python/assistant.py", line 1, in
from gtts import gTTS
ModuleNotFoundError: No module named 'gtts'

Please help with this. It says module not found I checked Its was there, but still got this error...

from gtts.

ajayprajapat171 avatar ajayprajapat171 commented on May 18, 2024

Traceback (most recent call last):
File "C:/python/assistant.py", line 1, in
from gtts import gTTS
ModuleNotFoundError: No module named 'gtts'

Please help with this. its same problem coming in my side if you have any solution please help me

from gtts.

AhmudulHassan avatar AhmudulHassan commented on May 18, 2024

Brother, @ajayprajapat171, when I can't find out what's the error is... I just unistalled and reinstalled... finally error got solved

Thanks brother.. i tried this way and finally fixed out..

from gtts.

AndresVilla123 avatar AndresVilla123 commented on May 18, 2024

Is true, I unistalled and reinstalled.
Now it works.

from gtts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.