small fixes
This commit is contained in:
parent
345de72aa1
commit
20238a31bf
@ -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):
|
||||
|
@ -10,14 +10,21 @@
|
||||
"\n",
|
||||
"core = Core(\n",
|
||||
" whisper_model_name = \"large-v3\",\n",
|
||||
" use_chatgpt_placeholder = True\n",
|
||||
")\n",
|
||||
"\n",
|
||||
" use_chatgpt_placeholder = False\n",
|
||||
")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"core.set_order_settings(\n",
|
||||
" phone_number = \"123456789\",\n",
|
||||
" order_items = \"1x margharitta\\n2x sos majonezowy\",\n",
|
||||
" delivery_address = \"ul. Amogusowa 1337, Suski Małe\",\n",
|
||||
" payment_method = \"karta\"\n",
|
||||
" order_items = \"2x margherita\\n3x sos czosnkowy\\n2x pepsi 1.5l\",\n",
|
||||
" delivery_address = \"ulica Kielecka 16A, Opole\",\n",
|
||||
" payment_method = \"gotówka\"\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"core.set_speech_recog_settings(\n",
|
||||
@ -28,12 +35,26 @@
|
||||
" vad_threshold = 0.6,\n",
|
||||
" min_silence_duration_ms = 150,\n",
|
||||
" speech_pad_ms = 0\n",
|
||||
")\n",
|
||||
"\n",
|
||||
")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"core.set_tts_settings(\n",
|
||||
" speaker_wav = \"voices/lector.wav\"\n",
|
||||
")\n",
|
||||
"\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"try:\n",
|
||||
" core.assistant_start()\n",
|
||||
"except (KeyboardInterrupt, SystemExit):\n",
|
||||
|
@ -2,7 +2,7 @@ You are a bot that will act as a guy that orders a pizza you will be connected o
|
||||
|
||||
DATA:
|
||||
phone: {phone_number}
|
||||
delivery location: {delivery_location}
|
||||
delivery location: {delivery_location} (PIZZA IS FOR DELIVERY. NOT for dine-in.)
|
||||
paymentMethod: {payment_method}
|
||||
OrderItems:
|
||||
{order_items}
|
||||
|
@ -78,9 +78,6 @@ class TTSStream:
|
||||
def tts_speak(self, text):
|
||||
self.play_buffer_size = 512
|
||||
|
||||
# separate long sequences of numbers in text string (for example 123456789) into packets of 3 (123 456 789)
|
||||
text = re.sub(r"(\d{3})(?=\d)", r"\1 ", text)
|
||||
|
||||
|
||||
# open pyaudio stream
|
||||
p = pyaudio.PyAudio()
|
||||
|
Loading…
Reference in New Issue
Block a user