Skip to content

Commit

Permalink
Initial outline of settings with UI
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel committed Nov 4, 2023
1 parent ae65df0 commit f2bc4fe
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions neon_iris/web_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ def __init__(self, lang: str = None):
self.lang = lang or self.config.get('lang', 'en-us')
self.chat_ui = gradio.Blocks()

@property
def supported_languages(self):
# TODO Implement lookup in base class
return ['en-us', 'uk-ua']

def update_profile(self, stt_lang, tts_lang, tts_lang_2):
# TODO: Per-client config
profile_update = {"speech": {"stt_language": stt_lang,
"tts_language": tts_lang,
"secondary_tts_language": tts_lang_2}}
from neon_utils.user_utils import apply_local_user_profile_updates
apply_local_user_profile_updates(profile_update, self._user_config)

def on_user_input(self, utterance: str, *args, **kwargs):
LOG.info(args)
LOG.info(kwargs)
Expand All @@ -63,14 +76,41 @@ def run(self):
audio_input = gradio.Audio(source="microphone", type="filepath")
chatbot = gradio.Chatbot(label=description)
textbox = gradio.Textbox(placeholder=placeholder)

with self.chat_ui as blocks:
# Define primary UI
gradio.ChatInterface(self.on_user_input,
chatbot=chatbot,
textbox=textbox,
additional_inputs=audio_input,
title=title,
retry_btn=None,
undo_btn=None)
# Define settings UI
with gradio.Row():
submit = gradio.Button("Update User Settings")
with gradio.Row():
with gradio.Column():
stt_lang = gradio.Radio(label="Input Language",
choices=self.supported_languages,
value=self.lang)
tts_lang = gradio.Radio(label="Response Language",
choices=self.supported_languages,
value=self.lang)
tts_lang_2 = gradio.Radio(label="Secondary Response Language",
choices=[None] + self.supported_languages,
value=None)
with gradio.Column():
# TODO: Unit settings
pass
with gradio.Column():
# TODO: Location settings
pass
with gradio.Column():
# TODO Name settings
pass
submit.click(self.update_profile,
inputs=[stt_lang, tts_lang, tts_lang_2])
blocks.launch(server_name="0.0.0.0", server_port=7860)

def handle_klat_response(self, message: Message):
Expand Down

0 comments on commit f2bc4fe

Please sign in to comment.