Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix web_client language handling to respect configured input language #32

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading