added chatgpt wrap, tts phone number splitting
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from vad_recorder import VADRecorder
|
||||
from tts_stream import TTSStream
|
||||
from chatgpt_wrap import ChatGPTWrap
|
||||
from faster_whisper import WhisperModel
|
||||
import torch
|
||||
import time
|
||||
@@ -8,7 +9,9 @@ import numpy as np
|
||||
|
||||
|
||||
class Core:
|
||||
def __init__(self, whisper_model_name = "large-v3"):
|
||||
def __init__(self, whisper_model_name = "large-v3", use_chatgpt_placeholder = False):
|
||||
self.use_chatgpt_placeholder = use_chatgpt_placeholder
|
||||
|
||||
self.device = "cuda" if torch.cuda.is_available() else "cpu"
|
||||
print("\n=======================================")
|
||||
print(f"Using {self.device.capitalize()} for:")
|
||||
@@ -16,19 +19,21 @@ class Core:
|
||||
print(" - TTS")
|
||||
print("=======================================\n")
|
||||
|
||||
print("Loading Whisper model... ", end="")
|
||||
print("Loading Faster Whisper model... ", end="")
|
||||
self.whisper_model = WhisperModel(whisper_model_name, device=self.device, compute_type="float16")
|
||||
print("Done!")
|
||||
|
||||
# VADRecorder and TTSStream have their own console loading messages
|
||||
# VADRecorder, TTSStream and ChatGPTWrap have their own console loading messages
|
||||
self.vad_rec = VADRecorder()
|
||||
self.tts = TTSStream(device=self.device)
|
||||
self.gpt_wrap = ChatGPTWrap(use_chatgpt_placeholder)
|
||||
|
||||
|
||||
def set_order_settings(self, phone_number, order_items, delivery_address):
|
||||
def set_order_settings(self, phone_number, order_items, delivery_address, payment_method):
|
||||
self.phone_number = phone_number
|
||||
self.order_items = order_items
|
||||
self.delivery_address = delivery_address
|
||||
self.payment_method = payment_method
|
||||
|
||||
|
||||
def set_speech_recog_settings(self, speech_recog_timeout, audio_input_device_name, audio_output_device_name, window_size_sec, vad_threshold, min_silence_duration_ms, speech_pad_ms):
|
||||
@@ -62,7 +67,12 @@ class Core:
|
||||
)
|
||||
print("Done!")
|
||||
|
||||
|
||||
self.gpt_wrap.init_order(
|
||||
self.phone_number,
|
||||
self.order_items,
|
||||
self.delivery_address,
|
||||
self.payment_method
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -116,9 +126,19 @@ class Core:
|
||||
print(speech_recog_text)
|
||||
print("-----------------------------------------\n\n")
|
||||
|
||||
time.sleep(1) # fake chatgpt delay
|
||||
|
||||
|
||||
gpt_response = self.gpt_wrap.get_response(speech_recog_text)
|
||||
|
||||
print("-----------------------------------------")
|
||||
if self.use_chatgpt_placeholder:
|
||||
print("!!!!! CHATGPT PLACEHOLDER RESPONSE !!!!!!")
|
||||
else:
|
||||
print("!!!!!!!!!!! CHATGPT RESPONSE !!!!!!!!!!!!")
|
||||
print("-----------------------------------------")
|
||||
print(gpt_response)
|
||||
print("-----------------------------------------\n\n")
|
||||
|
||||
gpt_response = "czat dżi pi ti plejsholder 1 2 3"
|
||||
if not self.assistant_running:
|
||||
break
|
||||
|
||||
@@ -127,7 +147,11 @@ class Core:
|
||||
|
||||
# tts
|
||||
print("Speech synthesis stream started!")
|
||||
self.tts.tts_speak(gpt_response)
|
||||
self.tts.tts_speak(gpt_response.replace(" CALLEND", ""))
|
||||
|
||||
|
||||
if "CALLEND" in gpt_response:
|
||||
self.assistant_stop()
|
||||
|
||||
|
||||
#print(len(audios_for_whisper), time.perf_counter() - last_recog_time, len(speech_recog_text))
|
||||
|
||||
Reference in New Issue
Block a user