diff --git a/README.md b/README.md index bac2c60e5..8d2bb10d2 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,15 @@ sudo apt-get update && sudo apt-get install google-cloud-sdk google-cloud-sdk-ap gcloud init gcloud auth application-default login ``` +It is possible to enable or disable the functionality of Google Cloud Speech to Text. +By default, the properties +`org.jitsi.jigasi.transcription.ENABLE_GOOGLE_AUTOMATIC_PUNCTUATION=false` +and +`org.jitsi.jigasi.transcription.ENABLE_GOOGLE_PROFANITY_FILTER=false` +in +`jigasi-home/sip-communicator.properties` +disable automatic punctuation, profanity filter results for the transcription. +To change this, simply set the desired property to `true` or `false`. Vosk configuration ================== @@ -206,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. + + org.jitsi.jigasi.transcription.ENABLE_INTERIM_RESULTS + false + 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. + Call control MUCs (brewery) diff --git a/src/main/java/org/jitsi/jigasi/transcription/GoogleCloudTranscriptionService.java b/src/main/java/org/jitsi/jigasi/transcription/GoogleCloudTranscriptionService.java index 3894ae4d7..67bb28176 100644 --- a/src/main/java/org/jitsi/jigasi/transcription/GoogleCloudTranscriptionService.java +++ b/src/main/java/org/jitsi/jigasi/transcription/GoogleCloudTranscriptionService.java @@ -184,11 +184,35 @@ public class GoogleCloudTranscriptionService private final static String P_NAME_USE_VIDEO_MODEL = "org.jitsi.jigasi.transcription.USE_VIDEO_MODEL"; + /** + * Property name to determine whether the Google Speech API should get + * automatic punctuation + */ + private final static String P_NAME_ENABLE_GOOGLE_AUTOMATIC_PUNCTUATION + = "org.jitsi.jigasi.transcription.ENABLE_GOOGLE_AUTOMATIC_PUNCTUATION"; + + /** + * Property name to determine whether the Google Speech API should censor + * profane words + */ + private final static String P_NAME_ENABLE_GOOGLE_PROFANITY_FILTER + = "org.jitsi.jigasi.transcription.ENABLE_GOOGLE_PROFANITY_FILTER"; + /** * The default value for the property USE_VIDEO_MODEL */ private final static boolean DEFAULT_VALUE_USE_VIDEO_MODEL = false; + /** + * The default value for the property ENABLE_GOOGLE_AUTOMATIC_PUNCTUATION + */ + private final static boolean DEFAULT_VALUE_ENABLE_GOOGLE_AUTOMATIC_PUNCTUATION = false; + + /** + * The default value for the property ENABLE_GOOGLE_PROFANITY_FILTER + */ + private final static boolean DEFAULT_VALUE_ENABLE_GOOGLE_PROFANITY_FILTER = false; + /** * Check whether the given string contains a supported language tag * @@ -224,6 +248,16 @@ private static void validateLanguageTag(String tag) */ private boolean useVideoModel; + /** + * Whether to get automatic punctuation + */ + private boolean enableAutomaticPunctuation; + + /** + * Wheteher to enable profanity filter + */ + private boolean enableProfanityFilter; + /** * Creates the RecognitionConfig the Google service uses based * on the TranscriptionRequest @@ -263,6 +297,12 @@ private RecognitionConfig getRecognitionConfig(TranscriptionRequest request) builder.setModel("video"); } + // set punctuation mode + builder.setEnableAutomaticPunctuation(enableAutomaticPunctuation); + + // set profanity filter + builder.setProfanityFilter(enableProfanityFilter); + // set the Language tag String languageTag = request.getLocale().toLanguageTag(); validateLanguageTag(languageTag); @@ -284,6 +324,12 @@ public GoogleCloudTranscriptionService() { useVideoModel = JigasiBundleActivator.getConfigurationService() .getBoolean(P_NAME_USE_VIDEO_MODEL, DEFAULT_VALUE_USE_VIDEO_MODEL); + + enableAutomaticPunctuation = JigasiBundleActivator.getConfigurationService() + .getBoolean(P_NAME_ENABLE_GOOGLE_AUTOMATIC_PUNCTUATION, DEFAULT_VALUE_ENABLE_GOOGLE_AUTOMATIC_PUNCTUATION); + + enableProfanityFilter = JigasiBundleActivator.getConfigurationService() + .getBoolean(P_NAME_ENABLE_GOOGLE_PROFANITY_FILTER, DEFAULT_VALUE_ENABLE_GOOGLE_PROFANITY_FILTER); } /** diff --git a/src/main/java/org/jitsi/jigasi/transcription/RemotePublisherTranscriptionHandler.java b/src/main/java/org/jitsi/jigasi/transcription/RemotePublisherTranscriptionHandler.java index c8c975ac6..6a1f401e8 100644 --- a/src/main/java/org/jitsi/jigasi/transcription/RemotePublisherTranscriptionHandler.java +++ b/src/main/java/org/jitsi/jigasi/transcription/RemotePublisherTranscriptionHandler.java @@ -17,6 +17,7 @@ */ package org.jitsi.jigasi.transcription; +import org.jitsi.jigasi.*; import net.java.sip.communicator.service.protocol.*; import org.json.*; @@ -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 urls = new ArrayList<>(); + /** + * Whether to send interim non-final results + */ + private boolean enableInterimResults; + /** * Constructs RemotePublisherTranscriptionHandler, initializing its config. * @@ -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);