I have exactly Python 2.7 installed on my machine, the semicolons did not affect the operation , the only error I had was:
No module named gtts
This is because I did not have the module installed, so I installed it via pip
in cmd (I'm using Windows):
pip install gTTS
The result was:
Seethepossibleerrors
Thefilesarebeingsavedinanotherfolder
Yourscriptifitisrunforexample:
c:\Users\user>pythonc:\exemplos\python\script.py
Itwillsavethe.mp3
inthec:\Users\user
folderandnotinthec:\exemplos\python
folder
Orso(unix-like):
eu@debian:~$python/home/usuario/exemplos/python/script.py
Itwillsavethe.mp3
inthe/home/[usuario]
folder(~$
indicatesthehome
oftheuser)andnotinthe/home/usuario/exemplos/python
folder
Thenitsavesfromwhereitexecuted.
Lackofwritingpermission
Maybethelocationwhereyouaretryingtosavethefilesdoesnothavewritepermission,itdependsalotonwhereyouaretryingtorunandtheoperatingsystem,ifyour.py
isforexampleinthec:\ProgramsandFiles
folderitwillnotwritethe.mp3
unlessyouhaveadministrativemode,ofcourseifyouaretryingtorunfromthatfolder.
Coding
Ifyour.py
issavedwithanencodingotherthanutf-8
itmightcausethiserror:
Traceback(mostrecentcalllast):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 lib apparently works with utf-8.