However, using the latest and functional version of gtts raises a problem as it now saves an mp3 file, instead of a wave file as it previously did.
This is due to the current speech implementation that is using play_wav to play the TTS file retrieved from the 3rd party service -- to fix this _playwav should be substituted for _playmp3.
Here's the current state of gtts 1.0.6:
$ mkvirtualenv gtts-test
[...]
(gtts-test) $ pip install gtts==1.0.6
Collecting gtts==1.0.6
Downloading gTTS-1.0.6.tar.gz
Collecting requests (from gtts==1.0.6)
Using cached requests-2.11.1-py2.py3-none-any.whl
Building wheels for collected packages: gtts
Running setup.py bdist_wheel for gtts ... done
Stored in directory: /home/<redacted>/.cache/pip/wheels/78/fa/32/75896791efd0f0de28ded4db03f9be223659c08467eb2b50db
Successfully built gtts
Installing collected packages: requests, gtts
Successfully installed gtts-1.0.6 requests-2.11.1
(gtts-test) $ python
Python 2.7.9 (default, Jun 29 2016, 13:08:31)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gtts
>>> tts = gtts.gTTS(text='Hello', lang='en')
>>> tts.save('hello.wav')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/<redacted>/.virtualenvs/gtts-test/local/lib/python2.7/site-packages/gtts/tts.py", line 90, in save
self.write_to_fp(f)
File "/home/<redacted>/.virtualenvs/gtts-test/local/lib/python2.7/site-packages/gtts/tts.py", line 108, in write_to_fp
r.raise_for_status()
File "/home/<redacted>/.virtualenvs/gtts-test/local/lib/python2.7/site-packages/requests/models.py", line 862, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: http://translate.google.com/translate_tts?textlen=5&idx=0&q=Hello&tl=en&client=t&total=1&ie=UTF-8
>>>
(gtts-test) $ file hello.wav
hello.wav: empty
Here's a shell session showing gtts 1.1.6 works, and outputs mp3:
(gtts-test) $ pip install -U gtts
Collecting gtts
Collecting gtts-token (from gtts)
Requirement already up-to-date: requests in ./.virtualenvs/gtts-test/lib/python2.7/site-packages (from gtts)
Installing collected packages: gtts-token, gtts
Found existing installation: gTTS 1.0.6
Uninstalling gTTS-1.0.6:
Successfully uninstalled gTTS-1.0.6
Successfully installed gtts-1.1.6 gtts-token-1.1.1
(gtts-test) $ python
Python 2.7.9 (default, Jun 29 2016, 13:08:31)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gtts
>>> tts = gtts.gTTS(text='Hello', lang='en')
>>> tts.save('hello.mp3')
>>>
(gtts-test) $ file hello.mp3
hello.mp3: MPEG ADTS, layer III, v2, 32 kbps, 24 kHz, Monaural
The gtts version enforced in requirements.txt (1.0.6) is broken.
However, using the latest and functional version of gtts raises a problem as it now saves an mp3 file, instead of a wave file as it previously did.
This is due to the current speech implementation that is using play_wav to play the TTS file retrieved from the 3rd party service -- to fix this _playwav should be substituted for _playmp3.
Here's the current state of gtts 1.0.6:
Here's a shell session showing gtts 1.1.6 works, and outputs mp3: