Skip to content
This repository was archived by the owner on Aug 21, 2025. It is now read-only.
Open
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 Editor/StreamingRecognizerEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion Runtime/StreamingRecognizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public string microphoneName {
}
}

public string language_code;
public bool startOnAwake = true;
public bool returnInterimResults = true;
public bool enableDebugLogging = false;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -279,6 +281,7 @@ private async void RestartAfterStreamingLimit() {
}

private async void StreamingMicRecognizeAsync() {

SpeechClient speech = SpeechClient.Create();
_streamingCall = speech.StreamingRecognize();

Expand All @@ -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,
Expand Down