16/02/2024, 19:55
Buonasera tutti , sono da poco entrato a far parte del mondo di RP e avrei bisogno di una mano. Sto cercando di creare un assistente vocale su pi 3b+ che ascolti quello che dico lo traduca in testo e mi accenda e spenga un led collegato sulla gpio. Vedendo un po su internet ho installato le librerie richieste però quando vado ad eseguire il programma mi tira fuori questi errori Potete darmi una mano? Grazie mille a tutti Questo è il programma che ho scritto:
import pyttsx3
import RPi.GPIO as GPIO
import time
# Impostare il numero del pin GPIO per il LED
LED_PIN = 17
# Configurare il sistema di sintesi vocale
engine = pyttsx3.init()
# Funzione per accendere il LED
def accendi_led():
GPIO.output(LED_PIN, GPIO.HIGH)
engine.say("Il LED è acceso")
engine.runAndWait()
# Funzione per spegnere il LED
def spegni_led():
GPIO.output(LED_PIN, GPIO.LOW)
engine.say("Il LED è spento")
engine.runAndWait()
# Configurare il GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(LED_PIN, GPIO.OUT)
try:
while True:
comando = input("Inserisci un comando (accendi/spegni/esci): ").lower()
if comando == "accendi":
accendi_led()
elif comando == "spegni":
spegni_led()
elif comando == "esci":
break
else:
engine.say("Comando non valido")
engine.runAndWait()
except KeyboardInterrupt:
pass
finally:
GPIO.cleanup()
engine.stop()
Traceback (most recent call last): File home/pi/- Local/lib/pythons.9/site-packages/pyttsx3/ eng = activeEngines [driverNamel File "fusr/lib/python3.9/weakref.py" Line 134, in getatem o = self.data[key]() KeyError: None -Py", Line 20, in init During handling of the above exception, another exception occurred: Traceback (most recent call last): File M/home/pi/Desktop/file.txt". line 9, in ‹module> engine = pyttsx3.init() File home/pi/local/lib/python3.9/site-packages/pyttsx3/. initi Ipy", line 22, in init eng = Engine(driverName, debug) File home pil. Local/Lib/python3.3/site-packages/pyttsx3/engine.py", line 30, in init self. proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug) File home/pil. Local/Lib/python3.9/site-packages/pyttsx3/driver-py". Line 50, in init self-_module = importlib. import_module (name) File Musr lib/python3.9/importlib/init Line 127, in import module return _bootstrap._god_import (name[level:], package, level) File "«frozen importlib. bootstrap>" , line 1030, in god import FiLe Nefrozen importLib. bootstrapy" line 1007, in find and load File afrozen importlib. bootstrappi File "«frozen importlib. bootstrap»", Line 980, in toad unlocked unlocked Line 680, in load unlocked File "«frozen importlib. bootstrap external>'" , Line 790, in exec module File "«frozen importlib. bootstrap›" , line 228, in call with frames removed File /home/pi/.local/lib/python3.9/site-packages/pyttsx3/drivers/espeak.pl line 9. in <module? fron. import _espeak, toutf8, fromutf8 File home/pi/.local/lib/python3.9/site-packages/pyttsx3/drivers/ espeak.py • Line 18, in smodule dil = cdIl. LoadLibrary('Libespeak.so.1') File Wusr/Lib/python3.9/otypes/ init.py", line 452, in LoadLibrary return self._dlltype (name ) File #/usr/lib/pythons.9/ctypes/ init -py". Line 374, init self._handle = _lopen (self-_name, mode) OSError: Libespeak.so.1: cannot open shared object file: No such file or directory
import pyttsx3
import RPi.GPIO as GPIO
import time
# Impostare il numero del pin GPIO per il LED
LED_PIN = 17
# Configurare il sistema di sintesi vocale
engine = pyttsx3.init()
# Funzione per accendere il LED
def accendi_led():
GPIO.output(LED_PIN, GPIO.HIGH)
engine.say("Il LED è acceso")
engine.runAndWait()
# Funzione per spegnere il LED
def spegni_led():
GPIO.output(LED_PIN, GPIO.LOW)
engine.say("Il LED è spento")
engine.runAndWait()
# Configurare il GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(LED_PIN, GPIO.OUT)
try:
while True:
comando = input("Inserisci un comando (accendi/spegni/esci): ").lower()
if comando == "accendi":
accendi_led()
elif comando == "spegni":
spegni_led()
elif comando == "esci":
break
else:
engine.say("Comando non valido")
engine.runAndWait()
except KeyboardInterrupt:
pass
finally:
GPIO.cleanup()
engine.stop()
Traceback (most recent call last): File home/pi/- Local/lib/pythons.9/site-packages/pyttsx3/ eng = activeEngines [driverNamel File "fusr/lib/python3.9/weakref.py" Line 134, in getatem o = self.data[key]() KeyError: None -Py", Line 20, in init During handling of the above exception, another exception occurred: Traceback (most recent call last): File M/home/pi/Desktop/file.txt". line 9, in ‹module> engine = pyttsx3.init() File home/pi/local/lib/python3.9/site-packages/pyttsx3/. initi Ipy", line 22, in init eng = Engine(driverName, debug) File home pil. Local/Lib/python3.3/site-packages/pyttsx3/engine.py", line 30, in init self. proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug) File home/pil. Local/Lib/python3.9/site-packages/pyttsx3/driver-py". Line 50, in init self-_module = importlib. import_module (name) File Musr lib/python3.9/importlib/init Line 127, in import module return _bootstrap._god_import (name[level:], package, level) File "«frozen importlib. bootstrap>" , line 1030, in god import FiLe Nefrozen importLib. bootstrapy" line 1007, in find and load File afrozen importlib. bootstrappi File "«frozen importlib. bootstrap»", Line 980, in toad unlocked unlocked Line 680, in load unlocked File "«frozen importlib. bootstrap external>'" , Line 790, in exec module File "«frozen importlib. bootstrap›" , line 228, in call with frames removed File /home/pi/.local/lib/python3.9/site-packages/pyttsx3/drivers/espeak.pl line 9. in <module? fron. import _espeak, toutf8, fromutf8 File home/pi/.local/lib/python3.9/site-packages/pyttsx3/drivers/ espeak.py • Line 18, in smodule dil = cdIl. LoadLibrary('Libespeak.so.1') File Wusr/Lib/python3.9/otypes/ init.py", line 452, in LoadLibrary return self._dlltype (name ) File #/usr/lib/pythons.9/ctypes/ init -py". Line 374, init self._handle = _lopen (self-_name, mode) OSError: Libespeak.so.1: cannot open shared object file: No such file or directory