This commit is contained in:
Looki2000 2023-12-06 01:19:49 +01:00
parent 8a7573f169
commit 26118e4898
2 changed files with 78 additions and 19 deletions

View File

@ -1,21 +1,80 @@
import gradio as gr import gradio as gr
from core import Core
import os import os
def start_assistant(phone_number, order_items, delivery_address, payment_method):
global assistant
assistant.set_order_settings(
phone_number,
order_items,
delivery_address,
payment_method
)
assistant.assistant_start()
def proceed():
print("ok") def stop_assistant():
assistant.assistant_stop()
def set_advanced_settings(speech_recog_timeout, window_size_sec, vad_threshold, min_silence_duration_ms, speech_pad_ms):
assistant.set_speech_recog_settings(
speech_recog_timeout,
window_size_sec,
vad_threshold,
min_silence_duration_ms,
speech_pad_ms
)
def set_voice_wav(speaker_wav):
speaker_wav = os.path.join(cwd, "voices", speaker_wav)
assistant.set_tts_settings(speaker_wav)
assistant = Core(
use_chatgpt_placeholder = True
)
cwd = os.path.dirname(os.path.realpath(__file__))
with gr.Blocks() as demo: with gr.Blocks() as demo:
txt_2 = gr.Textbox(label="Podaj Twój nr telefonu", lines=1) with gr.Tab("Basic Settings"):
txt_2 = gr.Textbox(label="Co chcesz zamówić?", lines=2) with gr.Row():
txt_3 = gr.Textbox(label="Na jaki adres?") phone_number = gr.Textbox(label="Twój Nr. Telefonu")
txt_4 = gr.Textbox(label="Dodatkowe informacje", lines=2) order_items = gr.Textbox(label="Zamówienie", lines=5)
gr.Dropdown(["Wejściowe", "Wyjściowe"], label="Urządzenie", info="Wybierz urządzenie audio!"), delivery_address = gr.Textbox(label="Adres dostawy")
gr.Radio(["inteigentna osoba", "50/50", "głupek"], label="Jaki rodzaj osoby udawać"), payment_method = gr.Dropdown(label="Metoda płatności", choices=["Gotówka", "Karta"])
gr.Radio(["hitler", "stuu", "lektor","belmondawg","sasza", "villager"], label="Głos", info="Jakiego głosu użyć?"), with gr.Column():
btn = gr.Button(value="Submit") speaker_wav = gr.Textbox(label="Wav głosu", value="lector.wav")
btn.click(proceed) set_voice = gr.Button("Ustaw głos")
if __name__ == "__main__": # init settings
demo.launch() #assistant.set_tts_settings(speaker_wav.value)
set_voice_wav(speaker_wav.value)
#set_voice.click(assistant.set_tts_settings, inputs=[speaker_wav], outputs=[])
set_voice.click(set_voice_wav, inputs=[speaker_wav], outputs=[])
with gr.Row():
start_btn = gr.Button("Start Pizzobota")
stop_btn = gr.Button("Stop Pizzobota")
start_btn.click(start_assistant, inputs=[phone_number, order_items, delivery_address, payment_method], outputs=[])
stop_btn.click(stop_assistant, inputs=[])
with gr.Tab("Advanced Settings"):
speech_recog_timeout = gr.Number(label="Speech Recog Timeout (sec)", value=1)
window_size_sec = gr.Number(label="Window Size (sec)", value=0.1)
vad_threshold = gr.Number(label="VAD Threshold", value=0.65)
min_silence_duration_ms = gr.Number(label="Min Silence Duration (ms)", value=250)
speech_pad_ms = gr.Number(label="Speech Pad (ms)", value=0)
# init settings
set_advanced_settings(speech_recog_timeout.value, window_size_sec.value, vad_threshold.value, min_silence_duration_ms.value, speech_pad_ms.value)
set_adv_btn = gr.Button("Ustaw")
set_adv_btn.click(set_advanced_settings, inputs=[speech_recog_timeout, window_size_sec, vad_threshold, min_silence_duration_ms, speech_pad_ms], outputs=[])
demo.launch()

View File

@ -10,7 +10,7 @@
"\n", "\n",
"core = Core(\n", "core = Core(\n",
" whisper_model_name = \"large-v3\",\n", " whisper_model_name = \"large-v3\",\n",
" use_chatgpt_placeholder = False\n", " use_chatgpt_placeholder = False,\n",
")" ")"
] ]
}, },
@ -22,18 +22,18 @@
"source": [ "source": [
"core.set_order_settings(\n", "core.set_order_settings(\n",
" phone_number = \"123456789\",\n", " phone_number = \"123456789\",\n",
" order_items = \"2x margherita\\n3x sos czosnkowy\\n2x pepsi 1.5l\",\n", " order_items = \"1x pizza margheritta 42 centrymetrów\\n1x sos pomidorowy\\n1x sos czosnkowy\",\n",
" delivery_address = \"ulica Kielecka 16A, Opole\",\n", " delivery_address = \"ul. Amogusowa 16A\",\n",
" payment_method = \"gotówka\"\n", " payment_method = \"gotówka\"\n",
")\n", ")\n",
"\n", "\n",
"core.set_speech_recog_settings(\n", "core.set_speech_recog_settings(\n",
" speech_recog_timeout = 2.5,\n", " speech_recog_timeout = 1.0,\n",
" #audio_input_device_name = \"Virtual\",\n", " #audio_input_device_name = \"Virtual\",\n",
" #audio_output_device_name = \"placeholder\",\n", " #audio_output_device_name = \"placeholder\",\n",
" window_size_sec = 0.1,\n", " window_size_sec = 0.1,\n",
" vad_threshold = 0.6,\n", " vad_threshold = 0.65,\n",
" min_silence_duration_ms = 150,\n", " min_silence_duration_ms = 250,\n",
" speech_pad_ms = 0\n", " speech_pad_ms = 0\n",
")" ")"
] ]