Verbesserung der Sprachsteuerung
This commit is contained in:
12
main.py
12
main.py
@@ -12,7 +12,7 @@ import sounddevice as sd
|
||||
# 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_MODEL = "de_DE-thorsten-medium.onnx"
|
||||
SAMPLE_RATE = 22050
|
||||
@@ -190,18 +190,21 @@ def vosk_listener():
|
||||
# stream.start_stream()
|
||||
|
||||
while True:
|
||||
if state != STATE_SPEAKING: #hinzugefügt um fehlerhafte eingaben zu stoppen
|
||||
data = stream.read(4000, exception_on_overflow=False)
|
||||
if rec.AcceptWaveform(data):
|
||||
result = json.loads(rec.Result())
|
||||
text = result.get("text", "")
|
||||
if text:
|
||||
audio_queue.put(text)
|
||||
else:
|
||||
rec.Reset()
|
||||
|
||||
|
||||
# =========================
|
||||
# WAKEWORD (SIMPLIFIZIERT)
|
||||
# =========================
|
||||
|
||||
"""
|
||||
def fake_wakeword_detector():
|
||||
global state
|
||||
while True:
|
||||
@@ -209,7 +212,7 @@ def fake_wakeword_detector():
|
||||
time.sleep(0.1)
|
||||
state = STATE_LISTENING
|
||||
speak("Wie kann ich helfen?")
|
||||
|
||||
"""
|
||||
# ==========================
|
||||
# WAKEWORD (PORCUPINE)
|
||||
# ==========================
|
||||
@@ -228,10 +231,11 @@ def real_wakeword_detector():
|
||||
)
|
||||
if state == STATE_IDLE:
|
||||
|
||||
def callback(indata, frames, time, status):
|
||||
def callback(indata, frames, time_info, status):
|
||||
pcm = np.frombuffer(indata, dtype=np.int16)
|
||||
result = porcupine.process(pcm)
|
||||
if result >= 0:
|
||||
time.sleep(1) #verbesserung der spracheingabe: wurde hinzugefügt weil es sonst worte halluziniert (wie "eine", "jarvis")
|
||||
state = STATE_LISTENING
|
||||
print("WAKE WORD DETECTED")
|
||||
speak("Ja, wie kann ich helfen?")
|
||||
|
||||
Reference in New Issue
Block a user