NameError on coding

0 votes

Traceback (most recent call last):
  File "C:/Users/orfao/PycharmProjects/jarvis2/Main.py", line 35, in <module>
    speak("Initializing Jarvis...")
  File "C:/Users/orfao/PycharmProjects/jarvis2/Main.py", line 18, in speak
    engine.runAndWait()
  File "C:\Users\orfao\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyttsx3\engine.py", line 180, in runAndWait
    self.proxy.runAndWait()
  File "C:\Users\orfao\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyttsx3\driver.py", line 192, in runAndWait
    self._driver.startLoop()
  File "C:\Users\orfao\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyttsx3\drivers\sapi5.py", line 127, in startLoop
    pythoncom.PumpWaitingMessages()
NameError: name 'pythoncom' is not defined

the code i am using is the following

import pyttsx3
import speech_recognition as sr
import datetime
import wikipedia
import os
import smtplib

print("Initializing Jarvis")

MASTER = "Miguel"
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[0].id)


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


def wishMe():
    hour = int(datetime.datetime.now().hour)
    print(hour)

    if hour>=0 and hour<12:
        speak("Good Morning" + MASTER)

    elif hour>=12 and hour<18:
        speak("Good Afternoon" + MASTER)

    else:
        speak("Good Evening" + MASTER)


speak("Initializing Jarvis...")
wishMe()
Jun 22, 2020 in Python by Miguel
• 120 points
788 views

1 answer to this question.

0 votes
well i think the sapi5 is not working so either you should use some other engine or try running it in another IDE.
answered Jun 28, 2020 by Shaurya Thapliyal
• 340 points

Related Questions In Python

+1 vote
2 answers

Measuring the distance between pixels on OpenCv with Python

You can try this: Mat pts1(nPts, 1, CV_8UC2), ...READ MORE

answered Aug 24, 2018 in Python by Omkar
• 69,220 points
10,555 views
0 votes
1 answer

Difference between del, remove and pop on lists

es, remove removes the first matching value, ...READ MORE

answered Aug 1, 2018 in Python by Priyaj
• 58,020 points
1,065 views
0 votes
1 answer

When I create and remove files rapidly on windows using python I get WindowsError (Error 5)

Here's the short answer: disable any antivirus or ...READ MORE

answered Aug 31, 2018 in Python by charlie_brown
• 7,720 points
1,917 views
0 votes
2 answers

NameError: name 'raw_input' is not defined

Hi, There may a problem with your python ...READ MORE

answered Jun 25, 2020 in Python by MD
• 95,460 points
32,674 views
0 votes
1 answer

Python: how to print long text on different lines?

replace with a newline char. file.write(response.read().decode('utf-8').replace(";","\n")) In [72]: ...READ MORE

answered Sep 5, 2018 in Python by slayer
• 29,370 points
1,484 views
0 votes
1 answer

How to evaluate a soft Voting classifier being trained on some data

VotingClassifier does not have a best_score_ attribute. ...READ MORE

answered Sep 6, 2018 in Python by Priyaj
• 58,020 points
1,175 views
0 votes
1 answer

Start an iteration on first row of a group Pandas

For anyone needing this information in the ...READ MORE

answered Sep 6, 2018 in Python by Priyaj
• 58,020 points
2,272 views
0 votes
1 answer

1 Year Rolling mean pandas on column date

I believe this should work for you: # ...READ MORE

answered Sep 6, 2018 in Python by Priyaj
• 58,020 points
14,645 views
0 votes
1 answer

How can I rename files on the fly using Python?

You could simply use a wrapper object ...READ MORE

answered Sep 7, 2018 in Python by aryya
• 7,460 points
788 views
0 votes
1 answer

GAE: python code to check if i'm on dev_appserver or deployed to appspot

I don't know if you still need ...READ MORE

answered Sep 11, 2018 in Python by anonymous
898 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP