python-3.x - Errno 24 打开的文件太多
问题描述
我正在Raspberry Pi 4(使用Thonny)上用Python编写一个虚拟助手程序,我遇到了上述错误。我的程序相对简单,但我无法理解为什么在运行程序大约 30 分钟后不断弹出错误。我的代码如下:
def speak(text):
text = ("<prosody rate='+0.20'><prosody volume='loud'>" + text + "</prosody>")
subprocess.call(['swift', '-o', '/home/pi/response', text], shell=False)
os.system('aplay /home/pi/response')
def greeting():
hour = int(datetime.datetime.now().hour)
if hour >= 0 and hour < 12:
speak("Initializing... Starting program. I am on line. Good morning.")
elif hour >= 12 and hour < 18:
speak("Initializing... Starting program. I am on line. Good afternoon.")
else:
speak("Initializing... Starting program. I am on line. Good evening.")
def listen_wakeWord():
r = sr.Recognizer()
with sr.Microphone() as source:
print("Listening...")
r.adjust_for_ambient_noise(source, duration=0.1)
audio = r.listen(source, phrase_time_limit=7)
try:
data = r.recognize_google(audio, language='en-US')
print(f"You said: {data}\n")
except Exception as e:
#print(e)
print("Input Not Recognized...")
greeting()
while True:
try:
listen_wakeWord()
except Exception as e:
print(e)
解决方案
推荐阅读
- php - 在 Apache 服务器的 Codeigniter 上获取 503 服务不可用
- mysql - 带有 JOIN 的 SELECT 查询返回每行的重复项
- javascript - 如何存储数据库结果的特定列?
- java - 如何访问 TextField 并将其设置为字符串?我正在使用场景构建器和日食
- python - python从yyy-mm-dd到dd-mm-yyy的正确日期格式
- angular - 当我使用 mat-inputs 时,数据不在 FormArray 中呈现
- php - 将 wordpress 项目部署到服务器后不加载 wordpress
- pine-script - 为什么我的 pine 脚本代码不起作用?
- javascript - 在数据库中存储营业时间:如何检查商店是否营业?
- postgresql - 如何使用 postgis 函数填充多边形之间的间隙