-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting_mic.py
More file actions
39 lines (27 loc) · 909 Bytes
/
testing_mic.py
File metadata and controls
39 lines (27 loc) · 909 Bytes
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
import time
import webbrowser
import pyautogui
import whisper
import sounddevice as sd
import numpy as np
model = whisper.load_model("base")
def send_a_msg ():
webbrowser.open("https://www.facebook.com/messages/e2ee/t/7418173101605052")
time.sleep(10)
pyautogui.write("Hi, This is my first Siri-like automation", interval=0.2)
pyautogui.press("enter")
def listen_for_command():
print("Say something bai....")
samplerate = 16000 #16khz
duration = 5
audio = sd.rec(int(samplerate * duration), samplerate=samplerate, channels=1, dtype=np.float32)
sd.wait()
audio = audio.flatten()
result = model.transcribe(audio)
command = result["text"].lower()
if "send my message" in command:
send_a_msg()
else:
print("No commands for that request bai. Try again")
while True:
listen_for_command()