import json
import os
import struct
import time
import pvporcupine
import simpleaudio as sa
import vosk
from pvrecorder import PvRecorder
import config
from llm_models.mini_4o_model import ModelClient

# some consts
CDIR = os.getcwd()

# PORCUPINE
porcupine = pvporcupine.create(
    access_key=config.PICOVOICE_TOKEN,
    keyword_paths=['Sonya_en_windows_v3_0_0.ppn'],
    sensitivities=[1]
)
# print(pvporcupine.KEYWORDS)

# VOSK
model = vosk.Model("model_small")
samplerate = 16000
device = config.MICROPHONE_INDEX
kaldi_rec = vosk.KaldiRecognizer(model, samplerate)

client = ModelClient()


def play(phrase, wait_done=True):
    global recorder
    filename = f"{CDIR}\\sound\\"

    if phrase == "greet":
        filename += f"start.wav"

    if wait_done:
        recorder.stop()

    wave_obj = sa.WaveObject.from_wave_file(filename)
    play_obj = wave_obj.play()

    if wait_done:
        play_obj.wait_done()
        # time.sleep((len(wave_obj.audio_data) / wave_obj.sample_rate) + 0.5)
        # print("END")
        # time.sleep(0.5)
        recorder.start()


def va_respond(voice: str):
    if voice:
        print(f"Распознано: {voice}")

        response_generator = client.get_response(
            message=voice,
            history=[],
            sys_prompt="Ты голосовой ассистент"
        )

        full_response = []  # Список для хранения частей ответа
        last = ''

        for response in response_generator:
            part = response.replace(last, '')
            print(part, end='', flush=True)
            full_response.append(part)  # Добавляем часть ответа в список
            last = response

        print()

        # Объединяем все части в одну строку
        complete_response = ''.join(full_response)

    return False


recorder = PvRecorder(device_index=config.MICROPHONE_INDEX, frame_length=porcupine.frame_length)
recorder.start()
print('Using device: %s' % recorder.selected_device)

print(f"Sonya (v1.0) к твоим услугам ...")

ltc = time.time() - 1000

while True:
    try:
        pcm = recorder.read()
        keyword_index = porcupine.process(pcm)

        if keyword_index >= 0:
            recorder.stop()
            play("greet", True)
            print("Yes, sir.")
            recorder.start()
            ltc = time.time()

        while time.time() - ltc <= 10:
            pcm = recorder.read()
            sp = struct.pack("h" * len(pcm), *pcm)

            if kaldi_rec.AcceptWaveform(sp):
                if va_respond(json.loads(kaldi_rec.Result())["text"]):
                    ltc = time.time()

                break

    except Exception as err:
        print(f"Unexpected {err=}, {type(err)=}")
        raise



Почему когда я останавливаю выполнение в pycharm у меня возникает ошибка в консоли?
Traceback (most recent call last):
  File "C:\Developing\Python\Sonya\app.py", line 90, in <module>
    pcm = recorder.read()
  File "C:\Users\crazy\.conda\envs\sonya_env\lib\site-packages\pvrecorder\_pvrecorder.py", line 176, in read
    status = self._read_func(self._handle, pcm)
  File "C:\Users\crazy\.conda\envs\sonya_env\lib\enum.py", line 359, in __call__
    def __call__(cls, value, names=None, *, module=None, qualname=None, type=None, start=1):
KeyboardInterrupt