Skip to content

Commit

Permalink
Fix web_client language handling to respect configured input language
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel committed Nov 9, 2023
1 parent ea9ce3e commit fe2a0a4
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions neon_iris/web_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ def __init__(self, lang: str = None):
LOG.name = "iris"
LOG.init(self.config.get("logs"))

@property
def lang(self):
def get_lang(self, session_id: str):
if session_id and session_id in self._profiles:
return self._profiles[session_id]['speech']['stt_language']
return self.user_config['speech']['stt_language'] or self.default_lang

@property
Expand Down Expand Up @@ -169,14 +170,15 @@ def on_user_input(self, utterance: str, *args, **kwargs) -> str:
self._await_response.clear()
self._response = None
gradio_id = args[2]
lang = self.get_lang(gradio_id)
if utterance:
LOG.info(f"Sending utterance: {utterance} with lang: {self.lang}")
self.send_utterance(utterance, self.lang, username=gradio_id,
LOG.info(f"Sending utterance: {utterance} with lang: {lang}")
self.send_utterance(utterance, lang, username=gradio_id,
user_profiles=[self._profiles[gradio_id]],
context={"gradio": {"session": gradio_id}})
else:
LOG.info(f"Sending audio: {args[1]} with lang: {self.lang}")
self.send_audio(args[1], self.lang, username=gradio_id,
LOG.info(f"Sending audio: {args[1]} with lang: {lang}")
self.send_audio(args[1], lang, username=gradio_id,
user_profiles=[self._profiles[gradio_id]],
context={"gradio": {"session": gradio_id}})
self._await_response.wait(30)
Expand Down Expand Up @@ -228,12 +230,13 @@ def run(self):
# Define settings UI
with gradio.Row():
with gradio.Column():
lang = self.get_lang(client_session.value)
stt_lang = gradio.Radio(label="Input Language",
choices=self.supported_languages,
value=self.lang)
value=lang)
tts_lang = gradio.Radio(label="Response Language",
choices=self.supported_languages,
value=self.lang)
value=lang)
tts_lang_2 = gradio.Radio(label="Second Response Language",
choices=[None] +
self.supported_languages,
Expand Down

0 comments on commit fe2a0a4

Please sign in to comment.