Skip to content

Commit

Permalink
Moved ENABLE_INTERIM_RESULTS parameter from GoogleCloudTranscriptionS…
Browse files Browse the repository at this point in the history
…ervice to RemotePublisherTranscriptionHandler
  • Loading branch information
kratu92 committed Jun 14, 2022
1 parent 40d7fb2 commit 886a387
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 34 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,9 @@ By default, the properties
`org.jitsi.jigasi.transcription.ENABLE_GOOGLE_AUTOMATIC_PUNCTUATION=false`
and
`org.jitsi.jigasi.transcription.ENABLE_GOOGLE_PROFANITY_FILTER=false`
and
`org.jitsi.jigasi.transcription.ENABLE_GOOGLE_INTERIM_RESULTS=false`
in
`jigasi-home/sip-communicator.properties`
disable automatic punctuation, profanity filter and interim results for the transcription.
disable automatic punctuation, profanity filter results for the transcription.
To change this, simply set the desired property to `true` or `false`.

Vosk configuration
Expand Down Expand Up @@ -217,6 +215,11 @@ XMPP account must also be set to make Jigasi be able to join a conference room.
in plain text. Note that this will result in the chat being somewhat
spammed.</td>
</tr>
<tr>
<td>org.jitsi.jigasi.transcription.ENABLE_INTERIM_RESULTS</td>
<td>false</td>
<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>
</tr>
</table>

Call control MUCs (brewery)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,6 @@ public class GoogleCloudTranscriptionService
private final static String P_NAME_USE_VIDEO_MODEL
= "org.jitsi.jigasi.transcription.USE_VIDEO_MODEL";

/**
* Property name to determine whether to send the interim results
*/
private final static String P_NAME_ENABLE_GOOGLE_INTERIM_RESULTS
= "org.jitsi.jigasi.transcription.ENABLE_GOOGLE_INTERIM_RESULTS";

/**
* Property name to determine whether the Google Speech API should get
* automatic punctuation
Expand All @@ -209,11 +203,6 @@ public class GoogleCloudTranscriptionService
*/
private final static boolean DEFAULT_VALUE_USE_VIDEO_MODEL = false;

/**
* The default value for the property ENABLE_GOOGLE_INTERIM_RESULTS
*/
private final static boolean DEFAULT_VALUE_ENABLE_GOOGLE_INTERIM_RESULTS = false;

/**
* The default value for the property ENABLE_GOOGLE_AUTOMATIC_PUNCTUATION
*/
Expand Down Expand Up @@ -259,11 +248,6 @@ private static void validateLanguageTag(String tag)
*/
private boolean useVideoModel;

/**
* Whether to send interim non-final results
*/
private boolean enableInterimResults;

/**
* Whether to get automatic punctuation
*/
Expand Down Expand Up @@ -341,9 +325,6 @@ public GoogleCloudTranscriptionService()
useVideoModel = JigasiBundleActivator.getConfigurationService()
.getBoolean(P_NAME_USE_VIDEO_MODEL, DEFAULT_VALUE_USE_VIDEO_MODEL);

enableInterimResults = JigasiBundleActivator.getConfigurationService()
.getBoolean(P_NAME_ENABLE_GOOGLE_INTERIM_RESULTS, DEFAULT_VALUE_ENABLE_GOOGLE_INTERIM_RESULTS);

enableAutomaticPunctuation = JigasiBundleActivator.getConfigurationService()
.getBoolean(P_NAME_ENABLE_GOOGLE_AUTOMATIC_PUNCTUATION, DEFAULT_VALUE_ENABLE_GOOGLE_AUTOMATIC_PUNCTUATION);

Expand Down Expand Up @@ -745,8 +726,7 @@ private ApiStreamObserver<StreamingRecognizeRequest> createObserver(
new ResponseApiStreamingObserver<StreamingRecognizeResponse>(
this,
config.getLanguageCode(),
debugName,
enableInterimResults);
debugName);

// StreamingRecognitionConfig which will hold information
// about the streaming session, including the RecognitionConfig
Expand Down Expand Up @@ -927,11 +907,6 @@ private static class ResponseApiStreamingObserver
*/
private UUID messageID;

/**
* Whether to send interim results
*/
private Boolean enableInterimResults;

/**
* Google provides multiple results per API response where the first one
* contains the most stable part of the sentence and freshly transcribed
Expand All @@ -951,13 +926,11 @@ private static class ResponseApiStreamingObserver
*/
ResponseApiStreamingObserver(RequestApiStreamObserverManager manager,
String languageTag,
String debugName,
Boolean enableInterimResults)
String debugName)
{
this.requestManager = manager;
this.languageTag = languageTag;
this.debugName = debugName;
this.enableInterimResults = enableInterimResults;

messageID = UUID.randomUUID();
}
Expand Down Expand Up @@ -1091,7 +1064,7 @@ private void handleResult(StreamingRecognitionResult result)
TranscriptionResult transcriptionResult = new TranscriptionResult(
null,
this.messageID,
!enableInterimResults && !result.getIsFinal(),
!result.getIsFinal(),
this.languageTag,
result.getStability(),
new TranscriptionAlternative(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package org.jitsi.jigasi.transcription;

import org.jitsi.jigasi.*;
import net.java.sip.communicator.service.protocol.*;
import org.json.*;

Expand All @@ -31,11 +32,27 @@ public class RemotePublisherTranscriptionHandler
extends LocalJsonTranscriptHandler
implements TranscriptionEventListener
{
/**
* Property name to determine whether to send the interim results
*/
private final static String P_NAME_ENABLE_INTERIM_RESULTS
= "org.jitsi.jigasi.transcription.ENABLE_INTERIM_RESULTS";

/**
* The default value for the property ENABLE_INTERIM_RESULTS
*/
private final static boolean DEFAULT_VALUE_ENABLE_INTERIM_RESULTS = false;

/**
* List of remote services to notify for transcriptions.
*/
private List<String> urls = new ArrayList<>();

/**
* Whether to send interim non-final results
*/
private boolean enableInterimResults;

/**
* Constructs RemotePublisherTranscriptionHandler, initializing its config.
*
Expand All @@ -52,12 +69,15 @@ public RemotePublisherTranscriptionHandler(String urlsStr)
{
urls.add(tokens.nextToken().trim());
}

enableInterimResults = JigasiBundleActivator.getConfigurationService()
.getBoolean(P_NAME_ENABLE_INTERIM_RESULTS, DEFAULT_VALUE_ENABLE_INTERIM_RESULTS);
}

@Override
public void publish(ChatRoom room, TranscriptionResult result)
{
if (result.isInterim())
if (!enableInterimResults && result.isInterim())
return;

JSONObject eventObject = createTranscriptionJSONObject(result);
Expand Down

0 comments on commit 886a387

Please sign in to comment.