1

I am trying to use the SpeechRecognition STT module for an AI i am coding and i'm also using Pyttsx but i get this error.

 File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pyttsx/__init__.py", line 18, in <module>
 from engine import Engine
 ImportError: No module named 'engine'

Alot of people have tried to answer this problem, for all the people having this problem but the answers aren't explained or don't work!

Here's my code

import speech_recognition
import pyttsx

speech_engine = pyttsx.init('sapi5') # see     http://pyttsx.readthedocs.org/en/latest/engine.html#pyttsx.init
speech_engine.setProperty('rate', 150)

def speak(text):
    speech_engine.say(text)
    speech_engine.runAndWait()

recognizer = speech_recognition.Recognizer()

def listen():
    with speech_recognition.Microphone() as source:
        recognizer.adjust_for_ambient_noise(source)
        audio = recognizer.listen(source)

    try:
        return recognizer.recognize_sphinx(audio) 
        # or: return recognizer.recognize_google(audio)
    except speech_recognition.UnknownValueError:
        print("Could not understand audio")
    except speech_recognition.RequestError as e:
        print("Recog Error; {0}".format(e))

    return ""



speak("Say something!")
speak("I heard you say " + listen())

if someone can explain and fix my problem that would be helpful thank you!

Sergei Glimis
  • 390
  • 2
  • 5
  • 17

1 Answers1

1

Follow this link. It has all the updates compatible with python 3. https://github.com/jpercent/pyttsx

Shreshtha Garg
  • 165
  • 1
  • 2
  • 10
  • please add some content from the link – Robert Apr 20 '17 at 08:14
  • 2
    This is a Python3 port of pyttsx, which is a cross-platform Python wrapper for text-to-speech synthesis. import pyttsx engine = pyttsx.init() engine.say('Greetings!') engine.say('How are you today?') engine.runAndWait() See http://pyttsx.readthedocs.org/ for documentation of the full API. – Shreshtha Garg Apr 20 '17 at 10:11