small fixes
This commit is contained in:
@@ -5,6 +5,7 @@ from faster_whisper import WhisperModel
|
||||
import torch
|
||||
import time
|
||||
import numpy as np
|
||||
import re
|
||||
|
||||
|
||||
|
||||
@@ -84,7 +85,7 @@ class Core:
|
||||
|
||||
self.assistant_running = True
|
||||
|
||||
while self.assistant_running:
|
||||
while True:
|
||||
if self.vad_rec.speech:
|
||||
last_recog_time = time.perf_counter()
|
||||
|
||||
@@ -114,8 +115,6 @@ class Core:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
elif time.perf_counter() - last_recog_time > self.speech_recog_timeout and len(speech_recog_text) > 0:
|
||||
speech_recog_text = speech_recog_text.strip()
|
||||
|
||||
@@ -130,6 +129,18 @@ class Core:
|
||||
|
||||
gpt_response = self.gpt_wrap.get_response(speech_recog_text)
|
||||
|
||||
# separate long sequences of numbers in text string (for example 123456789) into packets of 3 (123 456 789)
|
||||
gpt_response = re.sub(r"(\d{3})(?=\d)", r"\1 ", gpt_response)
|
||||
|
||||
# Add space on the right side of numbers
|
||||
gpt_response = re.sub(r'(\d)([^\d\s])', r'\1 \2', gpt_response)
|
||||
# Add space on the left side of numbers
|
||||
gpt_response = re.sub(r'([^\d\s])(\d)', r'\1 \2', gpt_response)
|
||||
|
||||
# replace "ul." with "ulica" (non case sensitive)
|
||||
gpt_response = re.sub(r"ul\.", "ulica", gpt_response, flags=re.IGNORECASE)
|
||||
|
||||
|
||||
print("-----------------------------------------")
|
||||
if self.use_chatgpt_placeholder:
|
||||
print("!!!!! CHATGPT PLACEHOLDER RESPONSE !!!!!!")
|
||||
@@ -159,6 +170,9 @@ class Core:
|
||||
|
||||
time.sleep(0.01)
|
||||
|
||||
if not self.assistant_running:
|
||||
break
|
||||
|
||||
# set assistant_running back to True to indicate that the loop has exited
|
||||
|
||||
def assistant_stop(self):
|
||||
|
||||
Reference in New Issue
Block a user