I have exactly Python 2.7 installed on my machine, the dots and comma did not affect the functioning, the only mistake I ever made was:
No module named gtts
This is because I didn’t have the module installed, so I installed it via pip
cmd (I am using Windows):
pip install gTTS
the result was:
See possible errors
Files are being saved in another folder
Your script if executed for example:
c:\Users\user> python c:\exemplos\python\script.py
Will save the .mp3
in the briefcase c:\Users\user
and not in the folder c:\exemplos\python
Or so (Unix-like):
eu@debian:~$ python /home/usuario/exemplos/python/script.py
Will save the .mp3
in the briefcase /home/[usuario]
(~$
indicates the home
user) and not in the folder /home/usuario/exemplos/python
So he saves from where he executed.
Lack of written permission
Maybe the location where you are trying to save the files does not have write permission, it depends a lot on where you are trying to run and the operating system, whether your .py
for example in the folder c:\Programs and Files
will not record the .mp3
unless it has administrative mode, of course if you are trying to run from that folder.
Coding
If your .py
is saved with a different encoding than utf-8
may cause this error:
Traceback (most recent call last):
File "tests/n.py", line 12, in <module>
audio_br("Segundo ao portal New York times sobre polÝtica no Brazil temos","
padrÒo_");
File "tests/n.py", line 9, in audio_br
teste= gtts(text=words,lang=language);
File "C:\Python27\lib\site-packages\gtts\tts.py", l
ine 94, in __init__
if self._len(text) <= self.MAX_CHARS:
File "C:\Python27\lib\site-packages\gtts\tts.py", l
ine 154, in _len
return len(text.decode('utf8'))
File "C:\Python27\lib\encodings\utf_8.py", line 16,
in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xed in position 42: invalid
continuation byte
This is because the lib apparently works with utf-8.
What do you mean, "It doesn’t rotate"? Answer the questions in the order and answer none: 1 - Is there an error? 2 - Or just open it in the text editor? 3 - Is it linux or Windows? ... I wait 3 answers to be able to help you.
– Guilherme Nascimento
And a possible fourth question: what changed from when it worked to when it stopped working? What changed in the code? What changed in the computer? What else have you installed? What have you uninstalled? Changed your computer? Changed the Python version?
– Woss
– Kaike Wesley Reis
1)The program shows no error, but does not create mp3. I generated some prints on the screen and only those that came before Reload were shown. 2) It opens the shell does not run anything 3) windows 4) I did not install or change anything, I was just testing to see how the mp3 files would be generated. In case if I don’t use this (turn to utf-8) gives some ascii Encode error
– Kaike Wesley Reis
And what is the function of
reload
in that code?– Woss
basically not to give error of encounter when I go to do the audio . mp3 using gtts
– Kaike Wesley Reis
– Guilherme Nascimento
@Andersoncarloswoss I believe that this is the function of
reload
in his script: https://stackoverflow.com/a/17628350/1518921– Guilherme Nascimento