diff --git a/Editor/StreamingRecognizerEditor.cs b/Editor/StreamingRecognizerEditor.cs index 11432c7..ca372ca 100644 --- a/Editor/StreamingRecognizerEditor.cs +++ b/Editor/StreamingRecognizerEditor.cs @@ -15,6 +15,7 @@ public override void OnInspectorGUI() { serializedObject.Update(); + SerializedProperty language_code = serializedObject.FindProperty("language_code"); SerializedProperty startOnAwake = serializedObject.FindProperty("startOnAwake"); SerializedProperty returnInterimResults = serializedObject.FindProperty("returnInterimResults"); SerializedProperty enableDebugLogging = serializedObject.FindProperty("enableDebugLogging"); @@ -33,7 +34,7 @@ public override void OnInspectorGUI() { listener.microphoneName = microphoneNames[EditorGUILayout.Popup("Microphone", microphoneIndex, microphoneNames)]; - + EditorGUILayout.PropertyField(language_code); EditorGUILayout.PropertyField(startOnAwake); EditorGUILayout.PropertyField(returnInterimResults); EditorGUILayout.PropertyField(enableDebugLogging); diff --git a/Runtime/StreamingRecognizer.cs b/Runtime/StreamingRecognizer.cs index bebeb4f..3abbfbe 100644 --- a/Runtime/StreamingRecognizer.cs +++ b/Runtime/StreamingRecognizer.cs @@ -32,6 +32,7 @@ public string microphoneName { } } + public string language_code; public bool startOnAwake = true; public bool returnInterimResults = true; public bool enableDebugLogging = false; @@ -61,6 +62,7 @@ public string microphoneName { private const double NormalizedFloatTo16BitConversionFactor = 0x7FFF + 0.4999999999999999; private const float MicInitializationTimeout = 1; private const int StreamingLimit = 290000; // almost 5 minutes + public void StartListening() { if (!_initialized) { @@ -279,6 +281,7 @@ private async void RestartAfterStreamingLimit() { } private async void StreamingMicRecognizeAsync() { + SpeechClient speech = SpeechClient.Create(); _streamingCall = speech.StreamingRecognize(); @@ -290,7 +293,7 @@ await _streamingCall.WriteAsync(new StreamingRecognizeRequest() { Config = new RecognitionConfig() { Encoding = RecognitionConfig.Types.AudioEncoding.Linear16, SampleRateHertz = audioConfiguration.sampleRate, - LanguageCode = "en", + LanguageCode = language_code, MaxAlternatives = 1 }, InterimResults = returnInterimResults,