Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@
"WebSocketConnectionSuccess": "WebSocket connection successful",
"FunctionExecuting": "Executing {{funcName}}",
"FunctionExecutionFailed": "Execution of {{funcName}} failed",
"FirefoxNotSupported": "This feature is not supported on Firefox"
"FirefoxNotSupported": "This feature is not supported on Firefox",
"SpeechRecognitionError": "Speech recognition error occurred"
Comment on lines +166 to +167
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

FirefoxNotSupportedキーの翻訳が必要です

SpeechRecognitionErrorは全ての言語ファイルで適切に翻訳されていますが、新しく追加されたFirefoxNotSupportedキーが他の言語ファイル(日本語、韓国語、中国語)で未翻訳となっています。

以下の翻訳の追加が必要です:

  • locales/ja/translation.json"FirefoxNotSupported": "この機能はFirefoxではサポートされていません"
  • locales/ko/translation.jsonに対応する韓国語の翻訳
  • locales/zh/translation.jsonに対応する中国語の翻訳
🔗 Analysis chain

他の言語ファイルとの整合性を確認

エラーメッセージが各言語ファイル(日本語、韓国語、中国語)で適切に翻訳されているか確認しましょう。


Let me verify the FirefoxNotSupported key as well before making the final conclusion.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 各言語ファイルでSpeechRecognitionErrorキーの存在を確認

echo "各言語ファイルのSpeechRecognitionErrorキーを確認中..."
for locale in ja ko zh; do
  if [ -f "locales/${locale}/translation.json" ]; then
    echo "=== ${locale} ==="
    jq '.Toasts.SpeechRecognitionError' "locales/${locale}/translation.json"
  fi
done

Length of output: 773


Script:

#!/bin/bash
# FirefoxNotSupportedキーの確認
echo "各言語ファイルのFirefoxNotSupportedキーを確認中..."
for locale in ja ko zh; do
  if [ -f "locales/${locale}/translation.json" ]; then
    echo "=== ${locale} ==="
    jq '.FirefoxNotSupported' "locales/${locale}/translation.json"
  fi
done

Length of output: 705

},
"UsingOpenAITTS": "Using OpenAI",
"OpenAITTSInfo": "Using OpenAI. It supports multiple languages. If you select OpenAI as the AI service, you do not need to set the API key below.",
Expand Down
3 changes: 2 additions & 1 deletion locales/ja/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@
"WebSocketConnectionSuccess": "WebSocket接続に成功しました",
"FunctionExecuting": "{{funcName}}を実行しています",
"FunctionExecutionFailed": "{{funcName}}の実行に失敗しました",
"FirefoxNotSupported": "Firefoxではこの機能はサポートされていません"
"FirefoxNotSupported": "Firefoxではこの機能はサポートされていません",
"SpeechRecognitionError": "音声認識エラーが発生しました"
},
"UsingOpenAITTS": "OpenAIを使用する",
"OpenAITTSInfo": "OpenAIを使用しています。多言語に対応可能です。AIサービスでOpenAIを選択している場合は下記のAPIキーを設定する必要はありません。",
Expand Down
3 changes: 2 additions & 1 deletion locales/ko/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@
"WebSocketConnectionSuccess": "WebSocket 연결에 성공했습니다",
"FunctionExecuting": "{{funcName}}을(를) 실행하고 있습니다",
"FunctionExecutionFailed": "{{funcName}}의 실행에 실패했습니다",
"FirefoxNotSupported": "Firefox에서는 이 기능을 지원하지 않습니다"
"FirefoxNotSupported": "Firefox에서는 이 기능을 지원하지 않습니다",
"SpeechRecognitionError": "음성 인식 오류가 발생했습니다"
},
"UsingOpenAITTS": "OpenAI 사용",
"OpenAITTSInfo": "OpenAI를 사용하고 있습니다. 다국어에 대응할 수 있습니다. AI 서비스로 OpenAI를 선택한 경우 아래 API 키를 설정할 필요는 없습니다.",
Expand Down
3 changes: 2 additions & 1 deletion locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@
"WebSocketConnectionSuccess": "WebSocket連線成功",
"FunctionExecuting": "正在執行{{funcName}}",
"FunctionExecutionFailed": "{{funcName}}執行失敗",
"FirefoxNotSupported": "Firefox不支援此功能"
"FirefoxNotSupported": "Firefox不支援此功能",
"SpeechRecognitionError": "語音認識發生錯誤"
},
"UsingOpenAITTS": "使用 OpenAI",
"OpenAITTSInfo": "使用 OpenAI。它支援多種語言。如果您選擇 OpenAI 作為 AI 服務,則不需要設定下面的 API 金鑰。",
Expand Down
35 changes: 30 additions & 5 deletions src/components/messageInputContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import webSocketStore from '@/features/stores/websocketStore'
import { useTranslation } from 'react-i18next'
import toastStore from '@/features/stores/toast'

const NO_SPEECH_TIMEOUT = 3000

// AudioContext の型定義を拡張
type AudioContextType = typeof AudioContext

Expand Down Expand Up @@ -79,6 +81,30 @@ export const MessageInputContainer = ({ onChatProcessStart }: Props) => {
newRecognition.continuous = true
newRecognition.interimResults = true

let noSpeechTimeout: NodeJS.Timeout

// 音声認識開始時のハンドラを追加
newRecognition.onstart = () => {
noSpeechTimeout = setTimeout(() => {
toastStore.getState().addToast({
message: t('Toasts.SpeechRecognitionError'),
type: 'error',
tag: 'no-speech-detected',
})
stopListening()
}, NO_SPEECH_TIMEOUT)
}

// 音声入力検出時のハンドラを追加
newRecognition.onspeechstart = () => {
clearTimeout(noSpeechTimeout)
}

// 音声認識終了時のハンドラを追加
newRecognition.onend = () => {
clearTimeout(noSpeechTimeout)
}

newRecognition.onresult = (event) => {
if (!isListeningRef.current) return

Expand All @@ -90,8 +116,7 @@ export const MessageInputContainer = ({ onChatProcessStart }: Props) => {
}

newRecognition.onerror = (event) => {
console.error('音声認識エラー:', event.error)
isListeningRef.current = false
stopListening()
}

setRecognition(newRecognition)
Expand Down Expand Up @@ -200,10 +225,10 @@ export const MessageInputContainer = ({ onChatProcessStart }: Props) => {
}, [])

const stopListening = useCallback(async () => {
if (recognition && isListeningRef.current) {
isListeningRef.current = false
setIsListening(false)
if (recognition) {
recognition.stop()
isListeningRef.current = false
setIsListening(false)

if (realtimeAPIMode) {
if (mediaRecorder) {
Expand Down