python-3.x - 进程以退出代码 139 结束(被信号 11 中断:SIGSEGV)。Mac Apple 硅片中的 Pycharm 错误。直到现在在这个项目中没有使用 opencv
问题描述
import sys
import pyttsx3
import datetime
import speech_recognition as sr
# import pyaudio
import os
import webbrowser
from keyboard import press_and_release
# from pynput.keyboard import Key, Controller
import pywhatkit as kt
import osascript
# from wappdriver import Whatsapp
# from selenium import webdriver
# from selenium.webdriver.support.ui import WebDriverWait
# from selenium.webdriver.support import expected_conditions as EC
# from selenium.webdriver.common.keys import Keys
# from selenium.webdriver.common.by import By
# import time
engine = pyttsx3.init()
# voices = engine.getProperty('voices')
# print(voices)
# engine.setProperty('voice',voices[16].id)
engine.setProperty("rate", 180)
def speak(audio):
engine.say(audio)
engine.runAndWait()
def wishme():
h = int(datetime.datetime.now().hour)
if h >= 0 and h < 12:
speak("Good Morning ! ")
elif h >= 12 and h < 18:
speak("Good Afternoon ! ")
else:
speak("Good Evening ")
speak("I am jarvis your assistant! How may I help you?")
def takecommand():
# takes microphone input and return string as output
r = sr.Recognizer()
# with sr.Microphone() as source:
# r.adjust_for_ambient_noise(source)
# r.adjust_for_ambient_noise(source, duration=0.2)
# print("Listening...")
# r.pause_threshold = 1
# audio = r.listen(source)
with sr.Microphone(device_index=0) as source:
print("Listening...")
r.pause_threshold = 1
audio = r.listen(source, timeout=1 , phrase_time_limit=4)
try:
print("Recognizing...")
query = r.recognize_google(audio, language='en-in')
print(f"You said: {query}")
except Exception as e:
print(e)
print("Say that again please...")
return "none"
return query
if __name__ == '__main__':
print('-------Code Running------')
speak("Hello Siddhant Sir!")
# wishme()
x=2
while x > 1:
listen = takecommand().lower()
if 'wake up jarvis' in listen or 'hello jarvis'in listen:
speak('Hello and Ready sir')
while 1:
if 1:
query = takecommand().lower()
if 'open whatsapp'in query:
speak('Opening whatsapp sir')
os.system("open /Applications/WhatsApp.app")
elif 'open vs code' in query:
speak('Opening visual studio code sir ')
os.system("open /Applications/Visual\ Studio\ Code.app")
elif 'open Pycharm' in query:
speak('Opening Pycharm sir ')
os.system("open /Applications/PyCharm\ CE.app")
elif 'open chrome' in query:
speak('Opening chorme sir')
os.system("open /Applications/Google\ Chrome.app")
elif 'open youtube' in query:
speak('Sure sir! Opening sir')
webbrowser.open('https://www.youtube.com/')
elif 'open new tab' in query:
webbrowser.open_new_tab('https://www.google.co.in/')
elif 'open discord' in query:
speak('opening Discord sir')
os.system("open /Applications/Discord.app")
elif 'give me something to write my notes on' in query:
speak('Opening word sir')
os.system("open /Applications/Microsoft\ Word.app")
elif 'it is my class time' in query:
speak('Opening M S Teams sir')
os.system("open /Applications/Microsoft\ Teams.app")
elif 'open my facebook account' in query:
speak('Sure sir')
webbrowser.open("https://www.facebook.com/")
elif 'want to see my professional account' in query:
speak('opening sir')
webbrowser.open_new_tab("https://www.linkedin.com/feed/")
elif ' open new tab ' in query:
press_and_release('command +t')
# elif 'open settings' in query:
# speak('opening sir')
# # os.system("open /Applications/System\ Preferences.app")
# os.system("open /Applications/System\ Preferences.app")
# elif 'spotlight search' in query:
# speak('sure sir')
# keyboard=Controller()
# key="command"+" "
# keyboard.press(key)
# keyboard.release(key)
elif 'volume mute' in query:
speak('Muting the volume sir ')
target_volume = 0
vol = "set volume output volume " + str(0)
osascript.osascript(vol)
elif 'volume 10' in query:
target_volume = 10
vol = "set volume output volume " + str(10)
osascript.osascript(vol)
speak('volume 10 ')
elif 'volume 25' in query:
target_volume = 25
vol = "set volume output volume " + str(25)
osascript.osascript(vol)
speak('volume 25')
elif 'volume 50' in query:
target_volume = 50
vol = "set volume output volume " + str(50)
osascript.osascript(vol)
speak('volume 50')
elif 'volume 75' in query:
target_volume = 75
vol = "set volume output volume " + str(75)
speak('volume now is 75 sir!')
osascript.osascript(vol)
speak('volume 75')
elif 'volume 90' in query:
target_volume = 90
vol = "set volume output volume " + str(90)
osascript.osascript(vol)
speak('volume now is 90 sir!')
elif 'volume full' in query:
speak('not gonna do that sir')
target_volume = 100
vol = "set volume output volume " + str(100)
speak('volume now is 100 sir!')
osascript.osascript(vol)
elif 'want to search something on google' in query:
speak('what do you want to search sir?')
ques = takecommand().lower()
kt.search(ques)
elif 'play song from youtube' in query:
speak('which song you want me to play sir?')
ques=takecommand().lower()
kt.playonyt(f"{ques}")
if 'then sleep' in query:
speak('Going to sleep mode sir')
break
elif 'send message on whatsapp' in query:
speak('whom do you want to message sir ?')
recipent = takecommand().lower()
speak('what is the message sir?')
message = takecommand().lower()
# with Whatsapp() as bot:
# bot.send(f"{recipent}", f"{message}")
elif 'sleep ' in query :
speak('Good bye sir')
break
else:
speak('did not get that sir ')
elif 'Plug off' in listen:
x=0
sys.exit()
一段时间后运行相同的代码并给我这个输出或者我已经做了一些事情。以前它运行得很好。试图编写一个虚拟助手并在一天后打开代码,运行程序后它给了我这个错误. 我想知道为什么会出现这个问题。
解决方案
推荐阅读
- react-native - NativeUIManager.getConstantsForViewManager('Text') 抛出异常。Chrome aaa 不支持在本机模块上调用同步方法
- vue.js - 分叉的 VueJS 应用程序在 npm 安装时出错
- java - 仅通过可运行的 jar 在使用 java 的 pdf 加密期间出现错误,但使用 eclipse
- python - Kivy:所有屏幕上的导航栏
- php - Woo-com Rest api 订单更新不起作用
- r - 嵌套应用连接
- metadata - InnoDB 何时以及如何访问其元数据或索引?
- python - 关于合并图像的python和opencv的问题
- jetbrains-ide - 今天在我昨天运行的应用程序上出现新错误。意外的错误
- qt - 为什么在这个程序中接收数据丢失(使用QSerialPort)?