python-3.xspeech-recognitionspeech

Speech text-to-speech with python 3.5


is that possible somehow to use text to speech for python 3.5

import speech
import time

response = speech.input("Say something, please.")
speech.say("You said " + response)

def callback(phrase, listener):
    if phrase == "goodbye":
        listener.stoplistening()
    speech.say(phrase)

listener = speech.listenforanything(callback)
while listener.islistening():
    time.sleep(.5)

error:

Traceback (most recent call last):
  File "D:/project/prog_2.py", line 1, in <module>
    import speech
  File "C:\Users\User\AppData\Roaming\Python\Python35\site-packages\speech.py", line 157
    print prompt
               ^
SyntaxError: Missing parentheses in call to 'print'

I have problem with gTTS maybe some advice here:

gTTS HTTPError: 403 Client Error: Forbidden for url


Solution

  • The Traceback shows that code from the installed speech module is causing the Missing parentheses in call to print error. This shows that the module has been written to work in Python 2 – but not Python 3.

    The two alternatives are:

    1. Find a Python 3 compatible package; this may prove to be difficult

    2. Rewrite your code in Python 2.