Skip to content

Commit 59ca086

Browse files
halkratu92
hal
authored andcommitted
Moved ENABLE_INTERIM_RESULTS parameter from GoogleCloudTranscriptionService to RemotePublisherTranscriptionHandler
1 parent 40d7fb2 commit 59ca086

File tree

3 files changed

+30
-34
lines changed

3 files changed

+30
-34
lines changed

README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,9 @@ By default, the properties
131131
`org.jitsi.jigasi.transcription.ENABLE_GOOGLE_AUTOMATIC_PUNCTUATION=false`
132132
and
133133
`org.jitsi.jigasi.transcription.ENABLE_GOOGLE_PROFANITY_FILTER=false`
134-
and
135-
`org.jitsi.jigasi.transcription.ENABLE_GOOGLE_INTERIM_RESULTS=false`
136134
in
137135
`jigasi-home/sip-communicator.properties`
138-
disable automatic punctuation, profanity filter and interim results for the transcription.
136+
disable automatic punctuation, profanity filter results for the transcription.
139137
To change this, simply set the desired property to `true` or `false`.
140138

141139
Vosk configuration
@@ -217,6 +215,11 @@ XMPP account must also be set to make Jigasi be able to join a conference room.
217215
in plain text. Note that this will result in the chat being somewhat
218216
spammed.</td>
219217
</tr>
218+
<tr>
219+
<td>org.jitsi.jigasi.transcription.ENABLE_INTERIM_RESULTS</td>
220+
<td>false</td>
221+
<td>Whether or not to send interim non-final results. Note that interim results should be handled so that no repeated transcriptions are displayed to the user.</td>
222+
</tr>
220223
</table>
221224

222225
Call control MUCs (brewery)

src/main/java/org/jitsi/jigasi/transcription/GoogleCloudTranscriptionService.java

+3-30
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,6 @@ public class GoogleCloudTranscriptionService
184184
private final static String P_NAME_USE_VIDEO_MODEL
185185
= "org.jitsi.jigasi.transcription.USE_VIDEO_MODEL";
186186

187-
/**
188-
* Property name to determine whether to send the interim results
189-
*/
190-
private final static String P_NAME_ENABLE_GOOGLE_INTERIM_RESULTS
191-
= "org.jitsi.jigasi.transcription.ENABLE_GOOGLE_INTERIM_RESULTS";
192-
193187
/**
194188
* Property name to determine whether the Google Speech API should get
195189
* automatic punctuation
@@ -209,11 +203,6 @@ public class GoogleCloudTranscriptionService
209203
*/
210204
private final static boolean DEFAULT_VALUE_USE_VIDEO_MODEL = false;
211205

212-
/**
213-
* The default value for the property ENABLE_GOOGLE_INTERIM_RESULTS
214-
*/
215-
private final static boolean DEFAULT_VALUE_ENABLE_GOOGLE_INTERIM_RESULTS = false;
216-
217206
/**
218207
* The default value for the property ENABLE_GOOGLE_AUTOMATIC_PUNCTUATION
219208
*/
@@ -259,11 +248,6 @@ private static void validateLanguageTag(String tag)
259248
*/
260249
private boolean useVideoModel;
261250

262-
/**
263-
* Whether to send interim non-final results
264-
*/
265-
private boolean enableInterimResults;
266-
267251
/**
268252
* Whether to get automatic punctuation
269253
*/
@@ -341,9 +325,6 @@ public GoogleCloudTranscriptionService()
341325
useVideoModel = JigasiBundleActivator.getConfigurationService()
342326
.getBoolean(P_NAME_USE_VIDEO_MODEL, DEFAULT_VALUE_USE_VIDEO_MODEL);
343327

344-
enableInterimResults = JigasiBundleActivator.getConfigurationService()
345-
.getBoolean(P_NAME_ENABLE_GOOGLE_INTERIM_RESULTS, DEFAULT_VALUE_ENABLE_GOOGLE_INTERIM_RESULTS);
346-
347328
enableAutomaticPunctuation = JigasiBundleActivator.getConfigurationService()
348329
.getBoolean(P_NAME_ENABLE_GOOGLE_AUTOMATIC_PUNCTUATION, DEFAULT_VALUE_ENABLE_GOOGLE_AUTOMATIC_PUNCTUATION);
349330

@@ -745,8 +726,7 @@ private ApiStreamObserver<StreamingRecognizeRequest> createObserver(
745726
new ResponseApiStreamingObserver<StreamingRecognizeResponse>(
746727
this,
747728
config.getLanguageCode(),
748-
debugName,
749-
enableInterimResults);
729+
debugName);
750730

751731
// StreamingRecognitionConfig which will hold information
752732
// about the streaming session, including the RecognitionConfig
@@ -927,11 +907,6 @@ private static class ResponseApiStreamingObserver
927907
*/
928908
private UUID messageID;
929909

930-
/**
931-
* Whether to send interim results
932-
*/
933-
private Boolean enableInterimResults;
934-
935910
/**
936911
* Google provides multiple results per API response where the first one
937912
* contains the most stable part of the sentence and freshly transcribed
@@ -951,13 +926,11 @@ private static class ResponseApiStreamingObserver
951926
*/
952927
ResponseApiStreamingObserver(RequestApiStreamObserverManager manager,
953928
String languageTag,
954-
String debugName,
955-
Boolean enableInterimResults)
929+
String debugName)
956930
{
957931
this.requestManager = manager;
958932
this.languageTag = languageTag;
959933
this.debugName = debugName;
960-
this.enableInterimResults = enableInterimResults;
961934

962935
messageID = UUID.randomUUID();
963936
}
@@ -1091,7 +1064,7 @@ private void handleResult(StreamingRecognitionResult result)
10911064
TranscriptionResult transcriptionResult = new TranscriptionResult(
10921065
null,
10931066
this.messageID,
1094-
!enableInterimResults && !result.getIsFinal(),
1067+
!result.getIsFinal(),
10951068
this.languageTag,
10961069
result.getStability(),
10971070
new TranscriptionAlternative(

src/main/java/org/jitsi/jigasi/transcription/RemotePublisherTranscriptionHandler.java

+21-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818
package org.jitsi.jigasi.transcription;
1919

20+
import org.jitsi.jigasi.*;
2021
import net.java.sip.communicator.service.protocol.*;
2122
import org.json.*;
2223

@@ -31,11 +32,27 @@ public class RemotePublisherTranscriptionHandler
3132
extends LocalJsonTranscriptHandler
3233
implements TranscriptionEventListener
3334
{
35+
/**
36+
* Property name to determine whether to send the interim results
37+
*/
38+
private final static String P_NAME_ENABLE_INTERIM_RESULTS
39+
= "org.jitsi.jigasi.transcription.ENABLE_INTERIM_RESULTS";
40+
41+
/**
42+
* The default value for the property ENABLE_INTERIM_RESULTS
43+
*/
44+
private final static boolean DEFAULT_VALUE_ENABLE_INTERIM_RESULTS = false;
45+
3446
/**
3547
* List of remote services to notify for transcriptions.
3648
*/
3749
private List<String> urls = new ArrayList<>();
3850

51+
/**
52+
* Whether to send interim non-final results
53+
*/
54+
private boolean enableInterimResults;
55+
3956
/**
4057
* Constructs RemotePublisherTranscriptionHandler, initializing its config.
4158
*
@@ -52,12 +69,15 @@ public RemotePublisherTranscriptionHandler(String urlsStr)
5269
{
5370
urls.add(tokens.nextToken().trim());
5471
}
72+
73+
enableInterimResults = JigasiBundleActivator.getConfigurationService()
74+
.getBoolean(P_NAME_ENABLE_INTERIM_RESULTS, DEFAULT_VALUE_ENABLE_INTERIM_RESULTS);
5575
}
5676

5777
@Override
5878
public void publish(ChatRoom room, TranscriptionResult result)
5979
{
60-
if (result.isInterim())
80+
if (!enableInterimResults && result.isInterim())
6181
return;
6282

6383
JSONObject eventObject = createTranscriptionJSONObject(result);

0 commit comments

Comments
 (0)