-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
39 lines (28 loc) · 1 KB
/
main.py
File metadata and controls
39 lines (28 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from ears.mic import listen_until_silence
from ears.mic_small import record_chunk
from brain.tts.motorCortex import text_to_sound
from brain.cerebrum import ThinkingBrain
from brain.stt.auditoryCortex import *
WAKE_WORDS = ["hey buddy", "hey friend", "hello buddy", "hello"]
def wake_word_detected(text: str) -> bool:
text = text.lower()
return any(word in text for word in WAKE_WORDS)
print("🎧 Assistant ready. Say 'Hey Buddy'...")
while True:
audio_bytes = record_chunk()
text = sound_to_text(audio_bytes)
if not text:
continue
print("Heard:", text)
if wake_word_detected(text):
print("🎤 Listening...")
# Listen for command
command_audio = listen_until_silence()
command_text = sound_to_text(command_audio)
if not command_text:
print("No command detected")
continue
print("Command:", command_text)
reply = ThinkingBrain(command_text)
print("Bot:", reply)
text_to_sound(reply)