A neural network voice model that executes commands on demand, like a voice assistant, but very crude
Clone the project
git clone https://github.com/xsvebmx/VoiceBot.git
Go to the project directory
cd VoiceBot
Install requirements
pip3 install -r requirements.txt
Start main.py
python3 main.py
import json, pyaudio
from vosk import Model, KaldiRecognizer
model = Model('vosk-model-small-ru-0.4')
rec = KaldiRecognizer(model, 16000)
p = pyaudio.PyAudio()
stream = p.open(format=pyaudio.paInt16, channels=1, rate=16000, input=True, frames_per_buffer=8000)
stream.start_stream()
def listen():
while True:
data = stream.read(4000, exception_on_overflow=False)
if (rec.AcceptWaveform(data)) and (len(data) > 0):
answer = json.loads(rec.Result())
if answer["text"]:
yield answer["text"]
for text in listen():
if text == "кеша":
print("Hello")
elif text == "пока":
quit()
else:
print(text)
Client: Mem usage 6-8gb