Comments (23)
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.
Brother, @ajayprajapat171, when I can't find out what's the error is... I just unistalled and reinstalled... finally error got solved
from gtts.
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.
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.
@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.
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.
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.
and in your environment, the module files exist under lib/python3.5/site-packages/gtts
?
from gtts.
Yep, both gtts, gtts_token, gTTS_token-1.1.1.dist-info, and gTTS-1.1.6.dist-info
from gtts.
Could you try the command from gtts import gTTS
using python -i
in your environment?
from gtts.
It gives me this:
Traceback (most recent call last):
File "", line 1, in
ImportError: cannot import name 'gTTS'
from gtts.
You could try this instead:
import gtts
tts = gtts.gTTS(text='Hello', lang='en')
tts.save("hello.mp3")
from gtts.
That gives this though:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'gtts' has no attribute 'gTTS'
from gtts.
Currently not, i also requested this feature in #26
from gtts.
What would be recommended for playing a file, and also deleting (cause it would be temp)
from gtts.
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.
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.
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.
hello rerun this command first
pip install gTTS
it seems that this command crashed ,
then retry
from gtts.
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.
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.
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.
Is true, I unistalled and reinstalled.
Now it works.
from gtts.
Related Issues (20)
- 0xA0 is causing gtts-cli to send EOF. HOT 2
- Error: Unable to find token seed! Did https://translate.google.com change? HOT 2
- Cant use 'tr' language
- gTTS throws unknown error for some languages, help me find why. HOT 3
- gtts.tts.gTTSError: 200 (OK) from TTS API. Probable cause: Unknown HOT 8
- Can Any one tell me even after tld set to com why it's connecting to translate.google.en? HOT 12
- Loosen dependencies if possible or at least make `click` optional HOT 3
- test fails: test_file_ascii and test_file_utf8: AssertionError HOT 3
- No pauses if 100 characters limit HOT 6
- Timestamps of the spoken words HOT 1
- Proxy setting parameters need to be added HOT 4
- Chinese example doesn't work HOT 3
- gtts_cli breaks when text starts with '-' HOT 3
- Add ability to adjust speed HOT 4
- 2mn latency at the save step HOT 3
- Add Support for Farsi/ Persian HOT 1
- Want support for LT lithuanian lang HOT 2
- Possible to add support for neural wavenet and studio? HOT 1
- readthedocs out of date HOT 1
- GTTS is adding in a word when speaking. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gtts.