[Update] UI: Add error handlings and show error notifications. adjust each localization for it.

This commit is contained in:
Sakamoto Shiina
2025-03-17 15:58:16 +09:00
parent 84a116291c
commit c82a89a7fb
7 changed files with 262 additions and 67 deletions

View File

@@ -6,6 +6,24 @@
common:
go_back_button_label: "Go Back"
common_error:
no_device_mic: "No mic device detected."
no_device_speaker: "No Speaker device detected."
threshold_invalid_value: "You can set it with a value between {{min}} to {{max}}."
failed_download_weight_ctranslate2: "CTranslate2 weight download error."
failed_download_weight_whisper: "Whisper weight download error."
translation_limit: "Translation engine limit error."
deepl_auth_key_invalid_length: "DeepL auth key length is not correct."
deepl_auth_key_failed_authentication: "Authentication failure of deepL auth key."
invalid_value_mic_record_timeout: "It cannot be greater than '{{mic_phrase_timeout_label}}' with a value of 0 or more."
invalid_value_mic_phrase_timeout: "It cannot be set lower than '{{mic_record_timeout_label}}' with a value of 0 or more."
invalid_value_mic_max_phrase: "You can set a number equal to or greater than 0."
invalid_value_speaker_record_timeout: "It cannot be greater than '{{speaker_phrase_timeout_label}}' with a value of 0 or more."
invalid_value_speaker_phrase_timeout: "It cannot be set lower than '{{speaker_record_timeout_label}}' with a value of 0 or more."
invalid_value_speaker_max_phrase: "You can set a number equal to or greater than 0."
main_page:
translation: "Translation"
transcription_send: "Voice2Chatbox"
@@ -75,7 +93,6 @@ config_page:
desc_for_automatic: "Automatically determine microphone input sensitivity."
label_for_manual: "Mic Energy Threshold (Current Setting: Manual)"
desc_for_manual: "Manually determine the microphone input sensitivity using the slider. Press the microphone icon to input your voice and adjust the sensitivity while monitoring the volume."
error_message: "You can set it with a value between 0 to {{max}}."
speaker_device:
label: "Speaker Device"
label_auto_select: "Auto Select"
@@ -85,8 +102,6 @@ config_page:
desc_for_automatic: "Automatically determine speaker input sensitivity."
label_for_manual: "Speaker Energy Threshold (Current Setting: Manual)"
desc_for_manual: "Manually determine the speaker input sensitivity using the slider. Press the headphones icon to listen to the audio and adjust the sensitivity while monitoring the volume."
error_message: "You can set it with a value between 0 to {{max}}."
no_device_error_message: "No speaker device detected."
appearance:
transparency:
@@ -131,15 +146,12 @@ config_page:
mic_record_timeout:
label: "Mic Record Timeout"
desc: "Detects silence and, when the specified number of seconds has passed, considers the mic input to have ended. (Second(s))"
error_message: "It cannot be greater than '{{mic_phrase_timeout_label}}' with a value of 0 or more."
mic_phrase_timeout:
label: "Mic Phrase Timeout"
desc: "Transcription processing is performed at intervals of the specified number of seconds."
error_message: "It cannot be set lower than '{{mic_record_timeout_label}}' with a value of 0 or more."
mic_max_phrase:
label: "Mic Max Words"
desc: "It is the lower limit for the number of transcribed words, and only when this number is exceeded will the transcription results be displayed logs and send to VRChat."
error_message: "You can set a number equal to or greater than 0."
mic_word_filter:
label: "Mic Word Filter"
desc: "If a registered word is detected, the text will not be sent. To add multiple words at once, separate them with a ',' (comma).\n*Duplicate words will not be registered."
@@ -148,15 +160,12 @@ config_page:
speaker_record_timeout:
label: "Speaker Record Timeout"
desc: "Detects silence and, when the specified number of seconds has passed, considers the speaker input to have ended. (Second(s))"
error_message: "It cannot be greater than '{{speaker_phrase_timeout_label}}' with a value of 0 or more."
speaker_phrase_timeout:
label: "Speaker Phrase Timeout"
desc: "Transcription processing is performed at intervals of the specified number of seconds."
error_message: "It cannot be set lower than '{{speaker_record_timeout_label}}' with a value of 0 or more."
speaker_max_phrase:
label: "Speaker Max Words"
desc: "It is the lower limit for the number of transcribed words, and only when this number is exceeded will the transcription results be displayed logs."
error_message: "You can set a number equal to or greater than 0."
select_transcription_engine:
label: "Transcription Engine"
whisper_weight_type:

View File

@@ -6,6 +6,24 @@
common:
go_back_button_label: "戻る"
common_error:
no_device_mic: "マイクデバイスが検出されませんでした。"
no_device_speaker: "スピーカーデバイスが検出されませんでした。"
threshold_invalid_value: "{{min}} から {{max}} までの数値で設定できます。"
failed_download_weight_ctranslate2: "CTranslate2 モデルのダウンロードに失敗しました。"
failed_download_weight_whisper: "Whisper モデルのダウンロードに失敗しました。"
translation_limit: "翻訳エンジンの使用制限に達したか、一時的に制限がかけられています。"
deepl_auth_key_invalid_length: "認証キーの文字数が間違っています。"
deepl_auth_key_failed_authentication: "認証キーが間違っているか、API使用制限が上限に達しています。"
invalid_value_mic_record_timeout: "0 以上で 「{{mic_phrase_timeout_label}}」 より大きくすることはできません。"
invalid_value_mic_phrase_timeout: "0 以上で 「{{mic_record_timeout_label}}」 より小さくすることはできません。"
invalid_value_mic_max_phrase: "0以上の数値を設定できます。"
invalid_value_speaker_record_timeout: "0 以上で 「{{speaker_phrase_timeout_label}}」 より大きくすることはできません。"
invalid_value_speaker_phrase_timeout: "0 以上で 「{{speaker_record_timeout_label}}」 より小さくすることはできません。"
invalid_value_speaker_max_phrase: "0以上の数値を設定できます。"
main_page:
translation: "翻訳"
transcription_send: "音声認識(マイク)"
@@ -75,7 +93,6 @@ config_page:
desc_for_automatic: "マイクの入力感度を自動的に調節する。"
label_for_manual: "マイク入力感度の調整 (現在の設定: 手動)"
desc_for_manual: "スライダーを調整して入力感度を手動で決められます。マイクのアイコンを押すと、実際に声を入力し、音量を確認しながら調節できます。"
error_message: "0 から {{max}} までの数値で設定できます。"
speaker_device:
label: "スピーカー (デバイス)"
label_auto_select: "自動選択"
@@ -84,8 +101,6 @@ config_page:
desc_for_automatic: "スピーカーの入力感度を自動的に調節する。"
label_for_manual: "スピーカー入力感度の調整 (現在の設定: 手動)"
desc_for_manual: "スライダーを調整して入力感度を手動で決められます。ヘッドフォンのアイコンを押すと、実際に音声を聞き取り、音量を確認しながら調節できます。"
error_message: "0 から {{max}} までの数値で設定できます。"
no_device_error_message: "スピーカーデバイスが検出されませんでした。"
appearance:
transparency:
@@ -121,7 +136,6 @@ config_page:
save: "保存"
edit: "編集"
auth_key_success: "認証キーの更新が完了しました。"
auth_key_error: "認証キーが間違っているか、API使用制限が上限に達しています。"
transcription:
section_label_mic: "マイク"
@@ -130,15 +144,12 @@ config_page:
mic_record_timeout:
label: "入力が終了したとみなす無音時間"
desc: "無音を検出し、設定された秒数経過すると、音声入力が終了したとみなします。"
error_message: "0 以上で 「{{mic_phrase_timeout_label}}」より大きくすることはできません。"
mic_phrase_timeout:
label: "一度に文字起こしする時間の長さ"
desc: "設定された秒数ごとに文字起こし処理が行われます。"
error_message: "0 以上で 「{{mic_record_timeout_label}}」より小さくすることはできません。"
mic_max_phrase:
label: "送信するまでに保持する単語数"
desc: "文字起こしされた単語数の下限値で、この数値を超えた場合のみ結果をVRChatへ送信し、ログに表示します。"
error_message: "0以上の数値を設定できます。"
mic_word_filter:
label: "ワードフィルター"
desc: "登録された単語を検出すると、その文章は送信されません。\n「,」カンマで区切ると、まとめて複数の単語を追加できます。\n※重複した単語は登録されません。"
@@ -147,15 +158,12 @@ config_page:
speaker_record_timeout:
label: "入力が終了したとみなす無音時間"
desc: "無音を検出し、設定された秒数経過すると、音声入力が終了したとみなします。"
error_message: "0 以上で「{{speaker_phrase_timeout_label}}」より大きくすることはできません。"
speaker_phrase_timeout:
label: "一度に文字起こしする時間の長さ"
desc: "設定された秒数ごとに文字起こし処理が行われます。"
error_message: "0 以上で「{{speaker_record_timeout_label}}」より小さくすることはできません。"
speaker_max_phrase:
label: "ログとして表示するまでに保持する単語数"
desc: "文字起こしされた単語数の下限値で、この数値を超えた場合のみ結果をログに表示します。"
error_message: "0以上の数値を設定できます。"
select_transcription_engine:
label: "音声認識で使用するエンジン"
whisper_weight_type:

View File

@@ -6,6 +6,24 @@
common:
go_back_button_label: "돌아가기"
common_error:
no_device_mic: "마이크 디바이스를 찾지 못했습니다."
no_device_speaker: "스피커 디바이스를 찾지 못했습니다."
threshold_invalid_value:
failed_download_weight_ctranslate2:
failed_download_weight_whisper:
translation_limit:
deepl_auth_key_invalid_length:
deepl_auth_key_failed_authentication: "인증키가 잘못되었거나 API 사용 제한이 상한에 도달했습니다."
invalid_value_mic_record_timeout: "0 이상에서 '{{mic_phrase_timeout_label}}'보다 클 수 없습니다."
invalid_value_mic_phrase_timeout: "0 이상에서 '{{mic_record_timeout_label}}'보다 작을 수 없습니다."
invalid_value_mic_max_phrase: "0 이상의 숫자만 설정할 수 있습니다."
invalid_value_speaker_record_timeout: "0 이상에서 '{{speaker_phrase_timeout_label}}'보다 클 수 없습니다."
invalid_value_speaker_phrase_timeout: "0 이상에서 '{{speaker_record_timeout_label}}'보다 작을 수 없습니다."
invalid_value_speaker_max_phrase: "0 이상의 숫자만 설정할 수 있습니다."
main_page:
translation: "번역"
transcription_send: "음성인식 (마이크)"
@@ -60,7 +78,6 @@ config_page:
desc_for_automatic: "마이크의 입력 감도를 자동으로 조절합니다."
label_for_manual: "음성 입력 최소 볼륨 (현재 설정: 수동)"
desc_for_manual: "슬라이더를 움직여 입력 감도를 수동으로 조절합니다. 마이크 아이콘을 누르면 실제 음성의 볼륨을 확인하며 감도를 조절할 수 있습니다."
error_message: "0에서 {{max}}까지의 숫자로만 설정할 수 있습니다."
speaker_device:
label: "스피커 장치"
speaker_dynamic_energy_threshold:
@@ -68,8 +85,6 @@ config_page:
desc_for_automatic: "스피커의 입력 감도를 자동으로 조절합니다."
label_for_manual: "음성 입력 최소 볼륨 (현재 설정: 수동)"
desc_for_manual: "슬라이더를 움직여 입력 감도를 수동으로 조절합니다. 헤드폰 아이콘을 누르면 실제 음성의 볼륨을 확인하며 감도를 조절할 수 있습니다."
error_message: "0에서 {{max}}까지의 숫자로만 설정할 수 있습니다."
no_device_error_message: "스피커 디바이스를 찾지 못했습니다."
appearance:
transparency:
@@ -101,7 +116,6 @@ config_page:
desc: "사용시 메인화면에 있는 {{translator}}를 DeepL_API로 변경해 주세요.\n지원하지 않는 언어도 있습니다."
open_auth_key_webpage: "DeepL 계정 페이지 열기"
auth_key_success: "인증키 갱신이 완료되었습니다."
auth_key_error: "인증키가 잘못되었거나 API 사용 제한이 상한에 도달했습니다."
transcription:
section_label_mic: "마이크"
@@ -109,15 +123,12 @@ config_page:
mic_record_timeout:
label: "최대 무음 시간"
desc: "무음을 감지하고 설정된 시간(초)만큼의 시간이 지나면 음성 입력이 종료된 것으로 판단합니다."
error_message: "0 이상에서 '{{mic_phrase_timeout_label}}'보다 클 수 없습니다."
mic_phrase_timeout:
label: "최대 인식 시간"
desc: "설정된 초 단위로 음성인식 처리가 이루어집니다."
error_message: "0 이상에서 '{{mic_record_timeout_label}}'보다 작을 수 없습니다."
mic_max_phrase:
label: "최대 입력 절(phrases) 수"
desc: "인식된 단어 수의 하한값으로, 이 수치를 초과하는 경우에만 결과를 VRChat으로 전송하고 로그에 표시합니다."
error_message: "0 이상의 숫자만 설정할 수 있습니다."
mic_word_filter:
label: "단어 필터"
desc: "등록된 단어가 감지되면 해당 문장은 전송되지 않습니다.\n',' 쉼표로 구분하면 여러 단어를 추가할 수 있습니다.\n* 중복된 단어는 등록되지 않습니다."
@@ -126,15 +137,12 @@ config_page:
speaker_record_timeout:
label: "최대 무음 시간"
desc: "무음을 감지하고 설정된 시간(초)만큼의 시간이 지나면 음성 입력이 종료된 것으로 판단합니다."
error_message: "0 이상에서 '{{speaker_phrase_timeout_label}}'보다 클 수 없습니다."
speaker_phrase_timeout:
label: "최대 인식 시간"
desc: "설정된 초 단위로 음성인식 처리가 이루어집니다."
error_message: "0 이상에서 '{{speaker_record_timeout_label}}'보다 작을 수 없습니다."
speaker_max_phrase:
label: "최대 입력 절(phrases) 수"
desc: "식된 단어 수의 하한값으로, 이 수치를 초과하는 경우에만 결과를 로그에 표시합니다."
error_message: "0 이상의 숫자만 설정할 수 있습니다."
use_whisper_feature:
label: "음성 인식에 Whisper 모델을 사용"
desc: "일부 언어에서는 음성 인식의 정확도가 향상될 수 있어요. 음성 인식 중 CPU 사용률이 올라가기 때문에 사용하시는 PC의 사양을 고려하여 이 기능을 사용해주세요."

View File

@@ -6,6 +6,24 @@
common:
go_back_button_label: "返回"
common_error:
no_device_mic: # 未检测到他人语音 ?
no_device_speaker: # 未检测到他人语音 ?
threshold_invalid_value: # 数值应为 {{min}} 至 {{max}} 之间。 ? 设定的数值从 {{min}} 到 {{max}} ?
failed_download_weight_ctranslate2:
failed_download_weight_whisper:
translation_limit:
deepl_auth_key_invalid_length:
deepl_auth_key_failed_authentication: "授权密匙错误或已达API使用上限"
invalid_value_mic_record_timeout: "数值应为 0 至 「{{mic_phrase_timeout_label}}」"
invalid_value_mic_phrase_timeout: "转录间隔时间大于0秒且不能小于「{{mic_record_timeout_label}}」"
invalid_value_mic_max_phrase: "数值应为 0 以上"
invalid_value_speaker_record_timeout: "数值应为 0 至 「{{speaker_phrase_timeout_label}}」"
invalid_value_speaker_phrase_timeout: "转录间隔时间大于0秒且不能小于「{{speaker_record_timeout_label}}」"
invalid_value_speaker_max_phrase: "数值应为 0 以上"
main_page:
translation: "翻译"
transcription_send: "你的语音转文字"
@@ -60,7 +78,6 @@ config_page:
desc_for_automatic: "自动调整麦克风输入阈值"
label_for_manual: "麦克风输入阈值(当前设置:手动)"
desc_for_manual: "使用滑杆手动确定麦克风输入灵敏度。按下麦克风图标输入语音,并在监控音量的同时调节灵敏度。"
error_message: "数值应为 0 至 {{max}} 之间。"
speaker_device:
label: "他人语音 (设备)"
speaker_dynamic_energy_threshold:
@@ -68,8 +85,6 @@ config_page:
desc_for_automatic: "自动调节他人语音接收阈值"
label_for_manual: "他人语音接收阈值(当前设置:手动)"
desc_for_manual: "使用滑杆手动调整他人语音接收阈值.在按下耳机按钮时,请根据实际听到的声音调整该大小"
error_message: "设定的数值从 0 到 {{max}}"
no_device_error_message: "未检测到他人语音"
appearance:
transparency:
@@ -101,7 +116,6 @@ config_page:
desc: "在使用的时候,使用时请在主屏幕上通过 DeepL_API 选择 {{translator}}\n※某些语言可能不支持"
open_auth_key_webpage: "打开DeepL账号页面"
auth_key_success: "授权密匙认证完成。"
auth_key_error: "授权密匙错误或已达API使用上限"
transcription:
section_label_mic: "你的麦克风"
@@ -109,15 +123,12 @@ config_page:
mic_record_timeout:
label: "语音输入结束后的静音时间"
desc: "当检测到静音并经过设定的秒数后,语音输入即被视为完成。"
error_message: "数值应为 0 至 [{{mic_phrase_timeout_label}}]"
mic_phrase_timeout:
label: "转录间隔"
desc: "在经过设定的时间后执行转录"
error_message: "转录间隔时间大于0秒且不能小于「{{mic_record_timeout_label}}」"
mic_max_phrase:
label: "麦克风发送时的最小单词数"
desc: "转录字数的下限,只有超过这个数字,才会记录翻译结果并发送到VRC"
error_message: "数值应为 0 以上"
mic_word_filter:
label: "单词过滤器"
desc: "检测出被记录的单词时,不会发送这段话\n如要添加多个单词,可以用逗号来分割\n※不会记录重复的单词"
@@ -126,15 +137,12 @@ config_page:
speaker_record_timeout:
label: "语音接收结束后的静音时间"
desc: "当检测到静音并经过设定的秒数后,语音接收即被视为完成。"
error_message: "数值应为 0 至 「{{speaker_phrase_timeout_label}}」"
speaker_phrase_timeout:
label: "转录间隔"
desc: "在经过设定的时间后执行转录"
error_message: "转录间隔时间大于0秒且不能小于「{{speaker_record_timeout_label}}」"
speaker_max_phrase:
label: "语音接收时的最小单词数"
desc: "转录字数的下限,只有超过这个数字,才会记录转录结果"
error_message: "数值应为 0 以上"
use_whisper_feature:
label: "使用Whisper模型翻译"
desc: "在某些语言中,语音识别的准确性可能会提高.语音识别的过程中,CPU占有率可能会提高,请根据你的pc性能来决定是否使用它."

View File

@@ -6,6 +6,24 @@
common:
go_back_button_label: "返回"
common_error:
no_device_mic:
no_device_speaker: "未偵測到喇叭裝置。"
threshold_invalid_value: "可以設置 {{min}} 到 {{max}} 之間的值。"
failed_download_weight_ctranslate2:
failed_download_weight_whisper:
translation_limit:
deepl_auth_key_invalid_length:
deepl_auth_key_failed_authentication: "授權金鑰錯誤或已達使用上限。"
invalid_value_mic_record_timeout: "不能大於「{{mic_phrase_timeout_label}}」,應為 0 或更高。"
invalid_value_mic_phrase_timeout: "不能小於「{{mic_record_timeout_label}}」,應為 0 或更高。"
invalid_value_mic_max_phrase: "可以設置 0 或更高的數值。"
invalid_value_speaker_record_timeout: "不能大於「{{speaker_phrase_timeout_label}}」,應為 0 或更高。"
invalid_value_speaker_phrase_timeout: "不能小於「{{speaker_record_timeout_label}}」,應為 0 或更高。"
invalid_value_speaker_max_phrase: "可以設置 0 或更高的數值。"
main_page:
translation: "翻譯"
transcription_send: "麥克風轉文字"
@@ -61,7 +79,6 @@ config_page:
desc_for_automatic: "自動判定麥克風輸入靈敏度。"
label_for_manual: "麥克風能量閾值(當前設置:手動)"
desc_for_manual: "使用滑桿調整麥克風輸入靈敏度,你可以按下麥克風圖示來測試。"
error_message: "可以設置 0 到 {{max}} 之間的值。"
speaker_device:
label: "喇叭裝置"
speaker_dynamic_energy_threshold:
@@ -69,8 +86,6 @@ config_page:
desc_for_automatic: "自動確定喇叭輸入靈敏度。"
label_for_manual: "喇叭能量閾值(當前設置:手動)"
desc_for_manual: "使用滑桿調整喇叭輸入靈敏度,你可以按下喇叭圖示來測試。"
error_message: "可以設置 0 到 {{max}} 之間的值。"
no_device_error_message: "未偵測到喇叭裝置。"
appearance:
transparency:
@@ -102,7 +117,6 @@ config_page:
desc: "使用 DeepL API 時請在主螢幕選擇 {{translator}}。※可能不支援某些語言。"
open_auth_key_webpage: "打開 DeepL 帳號頁面"
auth_key_success: "授權金鑰更新完成。"
auth_key_error: "授權金鑰錯誤或已達使用上限。"
transcription:
section_label_mic: "麥克風"
@@ -110,15 +124,12 @@ config_page:
mic_record_timeout:
label: "麥克風音訊 - 判定結束時間"
desc: "麥克風未收到音訊後,結束一段話的判定時間(秒)。"
error_message: "不能大於「{{mic_phrase_timeout_label}}」,應為 0 或更高。"
mic_phrase_timeout:
label: "麥克風音訊 - 紀錄間隔時間"
desc: "每隔多久要紀錄一次音訊。"
error_message: "不能小於「{{mic_record_timeout_label}}」,應為 0 或更高。"
mic_max_phrase:
label: "麥克風音訊 - 最大單詞數量"
desc: "只有在單詞超過此數量時,才會記錄結果並發送到 VRChat。"
error_message: "可以設置為 0 或更高的數值。"
mic_word_filter:
label: "麥克風單詞過濾器"
desc: "如果偵測到清單內的單詞,則不會發送訊息。要一次新增多個詞語,請用「,」(半形逗號)分隔。\n*重複詞語會被忽略。"
@@ -127,15 +138,12 @@ config_page:
speaker_record_timeout:
label: "喇叭音訊 - 判定結束時間"
desc: "偵測到靜音並在指定秒數後認為喇叭輸入已結束。(秒)"
error_message: "不能大於「{{speaker_phrase_timeout_label}}」,應為 0 或更高。"
speaker_phrase_timeout:
label: "喇叭音訊 - 紀錄間隔時間"
desc: "以指定秒數間隔進行轉錄處理。"
error_message: "不能小於「{{speaker_record_timeout_label}}」,應為 0 或更高。"
speaker_max_phrase:
label: "喇叭音訊 - 最大單詞數量"
desc: "只有在單詞超過此數量時,才會記錄結果並發送到 VRChat。"
error_message: "可以設置 0 或更高的數值。"
use_whisper_feature:
label: "使用 Whisper 模型進行轉錄"
desc: "在某些語言中語音識別的準確性可能會提高。使用語音識別時CPU使用率會增加請根據你的PC規格考慮是否使用此功能。"

View File

@@ -0,0 +1,124 @@
import { useTranslation } from "react-i18next";
import {
useNotificationStatus,
} from "@logics_common";
import {
useMicRecordTimeout,
useMicPhraseTimeout,
useMicMaxWords,
useSpeakerRecordTimeout,
useSpeakerPhraseTimeout,
useSpeakerMaxWords,
useDeepLAuthKey,
} from "@logics_configs";
import { ui_configs } from "../ui_configs";
export const _useBackendErrorHandling = () => {
const { t } = useTranslation();
const { showNotification_Error } = useNotificationStatus();
const { updateMicRecordTimeout } = useMicRecordTimeout();
const { updateMicPhraseTimeout } = useMicPhraseTimeout();
const { updateMicMaxWords } = useMicMaxWords();
const { updateSpeakerRecordTimeout } = useSpeakerRecordTimeout();
const { updateSpeakerPhraseTimeout } = useSpeakerPhraseTimeout();
const { updateSpeakerMaxWords } = useSpeakerMaxWords();
const { updateDeepLAuthKey } = useDeepLAuthKey();
const errorHandling_Backend = ({message, data, endpoint}) => {
switch (message) {
case "No mic device detected":
showNotification_Error(t("common_error.no_device_mic"));
break;
case "No Speaker device detected":
showNotification_Error(t("common_error.no_device_speaker"));
break;
case "Mic energy threshold value is out of range":
showNotification_Error(t("common_error.threshold_invalid_value",
{ min: ui_configs.mic_threshold_min, max: ui_configs.mic_threshold_max },
));
break;
case "Speaker energy threshold value is out of range":
showNotification_Error(t("common_error.threshold_invalid_value",
{ min: ui_configs.speaker_threshold_min, max: ui_configs.speaker_threshold_max },
));
break;
case "CTranslate2 weight download error":
showNotification_Error(t("common_error.failed_download_weight_ctranslate2"));
break;
case "Whisper weight download error":
showNotification_Error(t("common_error.failed_download_weight_whisper"));
break;
case "Translation engine limit error":
showNotification_Error(t("common_error.translation_limit"));
break;
case "DeepL auth key length is not correct":
updateDeepLAuthKey(data);
showNotification_Error(t("common_error.deepl_auth_key_invalid_length"));
break;
case "Authentication failure of deepL auth key":
updateDeepLAuthKey(data);
showNotification_Error(t("common_error.deepl_auth_key_failed_authentication"));
break;
case "Mic record timeout value is out of range":
updateMicRecordTimeout(data);
showNotification_Error(
t("common_error.invalid_value_mic_record_timeout",
{ mic_phrase_timeout_label: t("config_page.transcription.mic_phrase_timeout.label") }
));
break;
case "Mic phrase timeout value is out of range":
updateMicPhraseTimeout(data);
showNotification_Error(
t("common_error.invalid_value_mic_phrase_timeout",
{ mic_record_timeout_label: t("config_page.transcription.mic_record_timeout.label") }
));
break;
case "Mic max phrases value is out of range":
updateMicMaxWords(data);
showNotification_Error(t("common_error.invalid_value_mic_max_phrase"));
break;
case "Speaker record timeout value is out of range":
updateSpeakerRecordTimeout(data);
showNotification_Error(
t("common_error.invalid_value_speaker_record_timeout",
{ speaker_phrase_timeout_label: t("config_page.transcription.speaker_phrase_timeout.label") }
));
break;
case "Speaker phrase timeout value is out of range":
updateSpeakerPhraseTimeout(data);
showNotification_Error(
t("common_error.invalid_value_speaker_phrase_timeout",
{ speaker_record_timeout_label: t("config_page.transcription.speaker_record_timeout.label") }
));
break;
case "Speaker max phrases value is out of range":
updateSpeakerMaxWords(data);
showNotification_Error(t("common_error.invalid_value_speaker_max_phrase"));
break;
default:
if (endpoint === "/set/data/deepl_auth_key") updateDeepLAuthKey(data);
showNotification_Error(message);
break;
}
}
return {
errorHandling_Backend,
}
};

View File

@@ -1,6 +1,8 @@
import { translator_status } from "@ui_configs";
import { arrayToObject } from "@utils";
import { _useBackendErrorHandling } from "./_useBackendErrorHandling";
import {
useIsVrctAvailable,
useNotificationStatus,
@@ -184,6 +186,10 @@ export const useReceiveRoutes = () => {
const { handleNetworkConnection } = useHandleNetworkConnection();
const {
errorHandling_Backend,
} = _useBackendErrorHandling();
const routes = {
// Common
"/run/feed_watchdog": () => {},
@@ -498,16 +504,25 @@ export const useReceiveRoutes = () => {
"/get/data/transcription_engines": ()=>{}, // Not implemented on UI yet. (if ai_models has not been detected, this will be blank array[]. if the ai_models are ok but just network has not connected, it'l be only ["Whisper"])
};
const error_routes = {
"/set/data/mic_record_timeout": updateMicRecordTimeout,
"/set/data/mic_phrase_timeout": updateMicPhraseTimeout,
"/set/data/mic_max_phrases": updateMicMaxWords,
const error_status_routes = {
"/run/error_device": errorHandling_Backend,
"/set/data/speaker_record_timeout": updateSpeakerRecordTimeout,
"/set/data/speaker_phrase_timeout": updateSpeakerPhraseTimeout,
"/set/data/speaker_max_phrases": updateSpeakerMaxWords,
"/run/error_ctranslate2_weight": errorHandling_Backend,
"/run/error_whisper_weight": errorHandling_Backend,
"/set/data/deepl_auth_key": updateDeepLAuthKey,
"/set/data/deepl_auth_key": errorHandling_Backend,
"/run/error_translation_engine": errorHandling_Backend,
"/set/data/mic_threshold": errorHandling_Backend,
"/set/data/mic_record_timeout": errorHandling_Backend,
"/set/data/mic_phrase_timeout": errorHandling_Backend,
"/set/data/mic_max_phrases": errorHandling_Backend,
"/set/data/speaker_threshold": errorHandling_Backend,
"/set/data/speaker_record_timeout": errorHandling_Backend,
"/set/data/speaker_phrase_timeout": errorHandling_Backend,
"/set/data/speaker_max_phrases": errorHandling_Backend,
};
@@ -519,22 +534,37 @@ export const useReceiveRoutes = () => {
}
};
const handleInvalidEndpoint = (parsed_data) => {
console.error(`Invalid endpoint: ${parsed_data.endpoint}\nresult: ${JSON.stringify(parsed_data.result)}`);
};
if (parsed_data.endpoint === "/run/initialization_complete") {
initDataSyncProcess(parsed_data.result);
updateIsBackendReady(true);
return;
};
switch (parsed_data.status) {
case 200:
if (parsed_data.endpoint === "/run/initialization_complete") {
initDataSyncProcess(parsed_data.result);
updateIsBackendReady(true);
break;
};
const route = routes[parsed_data.endpoint];
(route) ? route(parsed_data.result) : console.error(`Invalid endpoint: ${parsed_data.endpoint}\nresult: ${JSON.stringify(parsed_data.result)}`);
if (route) {
route(parsed_data.result);
} else {
handleInvalidEndpoint(parsed_data);
}
break;
case 400:
const error_route = error_routes[parsed_data.endpoint];
(error_route) ? error_route(parsed_data.result.data) : console.error(`Invalid endpoint: ${parsed_data.endpoint}\nresult: ${JSON.stringify(parsed_data.result)}`);
console.error(`status 400: ${JSON.stringify(parsed_data.result)}`);
showNotification_Error(parsed_data.result.message);
const error_route = error_status_routes[parsed_data.endpoint];
if (error_route) {
error_route({
message: parsed_data.result.message,
data: parsed_data.result.data,
endpoint: parsed_data.endpoint,
});
} else {
handleInvalidEndpoint(parsed_data);
}
break;
case 348: