Verbesserung der Sprachsteuerung
This commit is contained in:
26
main.py
26
main.py
@@ -12,7 +12,7 @@ import sounddevice as sd
|
|||||||
# KONFIGURATION
|
# KONFIGURATION
|
||||||
# =========================
|
# =========================
|
||||||
|
|
||||||
VOSK_MODEL_PATH = "/home/tino/Documents/_Documents/Schule/4 Wilhelm Maybach Schule/2BKI Jahr 2/Abschlussprojekt/test assistant/assistant_all_in_one/vosk-model-de-0.21/"
|
VOSK_MODEL_PATH = "/home/tino/Desktop/Abschlussprojekt/test assistant/cloneAssistantAllInOne/RasPi_Voice_Assistant--WIP/vosk-model-de-0.21"
|
||||||
PIPER_BIN = "piper"
|
PIPER_BIN = "piper"
|
||||||
PIPER_MODEL = "de_DE-thorsten-medium.onnx"
|
PIPER_MODEL = "de_DE-thorsten-medium.onnx"
|
||||||
SAMPLE_RATE = 22050
|
SAMPLE_RATE = 22050
|
||||||
@@ -190,18 +190,21 @@ def vosk_listener():
|
|||||||
# stream.start_stream()
|
# stream.start_stream()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
data = stream.read(4000, exception_on_overflow=False)
|
if state != STATE_SPEAKING: #hinzugefügt um fehlerhafte eingaben zu stoppen
|
||||||
if rec.AcceptWaveform(data):
|
data = stream.read(4000, exception_on_overflow=False)
|
||||||
result = json.loads(rec.Result())
|
if rec.AcceptWaveform(data):
|
||||||
text = result.get("text", "")
|
result = json.loads(rec.Result())
|
||||||
if text:
|
text = result.get("text", "")
|
||||||
audio_queue.put(text)
|
if text:
|
||||||
|
audio_queue.put(text)
|
||||||
|
else:
|
||||||
|
rec.Reset()
|
||||||
|
|
||||||
|
|
||||||
# =========================
|
# =========================
|
||||||
# WAKEWORD (SIMPLIFIZIERT)
|
# WAKEWORD (SIMPLIFIZIERT)
|
||||||
# =========================
|
# =========================
|
||||||
|
"""
|
||||||
def fake_wakeword_detector():
|
def fake_wakeword_detector():
|
||||||
global state
|
global state
|
||||||
while True:
|
while True:
|
||||||
@@ -209,7 +212,7 @@ def fake_wakeword_detector():
|
|||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
state = STATE_LISTENING
|
state = STATE_LISTENING
|
||||||
speak("Wie kann ich helfen?")
|
speak("Wie kann ich helfen?")
|
||||||
|
"""
|
||||||
# ==========================
|
# ==========================
|
||||||
# WAKEWORD (PORCUPINE)
|
# WAKEWORD (PORCUPINE)
|
||||||
# ==========================
|
# ==========================
|
||||||
@@ -226,12 +229,13 @@ def real_wakeword_detector():
|
|||||||
access_key=ACCESS_KEY,
|
access_key=ACCESS_KEY,
|
||||||
keywords=[WAKEWORD]
|
keywords=[WAKEWORD]
|
||||||
)
|
)
|
||||||
if state == STATE_IDLE:
|
if state == STATE_IDLE:
|
||||||
|
|
||||||
def callback(indata, frames, time, status):
|
def callback(indata, frames, time_info, status):
|
||||||
pcm = np.frombuffer(indata, dtype=np.int16)
|
pcm = np.frombuffer(indata, dtype=np.int16)
|
||||||
result = porcupine.process(pcm)
|
result = porcupine.process(pcm)
|
||||||
if result >= 0:
|
if result >= 0:
|
||||||
|
time.sleep(1) #verbesserung der spracheingabe: wurde hinzugefügt weil es sonst worte halluziniert (wie "eine", "jarvis")
|
||||||
state = STATE_LISTENING
|
state = STATE_LISTENING
|
||||||
print("WAKE WORD DETECTED")
|
print("WAKE WORD DETECTED")
|
||||||
speak("Ja, wie kann ich helfen?")
|
speak("Ja, wie kann ich helfen?")
|
||||||
|
|||||||
Reference in New Issue
Block a user