From ef28d174d69d59afc83299709e355f61b3deb0c0 Mon Sep 17 00:00:00 2001 From: RazvanP Date: Mon, 18 Sep 2023 23:13:17 +0300 Subject: [PATCH 1/2] Add a way to toggle the SilenceFilter for each TranscriptionService individually --- .../transcription/AbstractTranscriptionService.java | 9 +++++++++ .../org/jitsi/jigasi/transcription/Transcriber.java | 6 ++++-- .../transcription/WhisperTranscriptionService.java | 13 +++++++++---- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/jitsi/jigasi/transcription/AbstractTranscriptionService.java b/src/main/java/org/jitsi/jigasi/transcription/AbstractTranscriptionService.java index acb604a87..ba2505d4d 100644 --- a/src/main/java/org/jitsi/jigasi/transcription/AbstractTranscriptionService.java +++ b/src/main/java/org/jitsi/jigasi/transcription/AbstractTranscriptionService.java @@ -39,4 +39,13 @@ public AudioMixerMediaDevice getMediaDevice(ReceiveStreamBufferListener listener return this.mediaDevice; } + + /** + * Returns true if the SilenceFilter should be disabled for this + * TranscriptionService. + */ + public boolean disableSilenceFilter() + { + return false; + } } diff --git a/src/main/java/org/jitsi/jigasi/transcription/Transcriber.java b/src/main/java/org/jitsi/jigasi/transcription/Transcriber.java index afada3b38..9bf14ee49 100644 --- a/src/main/java/org/jitsi/jigasi/transcription/Transcriber.java +++ b/src/main/java/org/jitsi/jigasi/transcription/Transcriber.java @@ -194,7 +194,7 @@ private enum State * Whether silenced audio should be filtered out before sending audio to * a {@link TranscriptionService}. */ - private boolean filterSilence = shouldFilterSilence(); + private boolean filterSilence; /** * Create a transcription object which can be used to add and remove @@ -218,6 +218,7 @@ public Transcriber(String roomName, } this.transcriptionService = service; addTranscriptionListener(this.transcript); + this.filterSilence = shouldFilterSilence(); configureTranslationManager(); if (isTranslationEnabled()) @@ -958,6 +959,7 @@ private boolean isTranslationEnabled() private boolean shouldFilterSilence() { return JigasiBundleActivator.getConfigurationService() - .getBoolean(P_NAME_FILTER_SILENCE, FILTER_SILENCE_DEFAULT_VALUE); + .getBoolean(P_NAME_FILTER_SILENCE, FILTER_SILENCE_DEFAULT_VALUE) + && !this.transcriptionService.disableSilenceFilter(); } } diff --git a/src/main/java/org/jitsi/jigasi/transcription/WhisperTranscriptionService.java b/src/main/java/org/jitsi/jigasi/transcription/WhisperTranscriptionService.java index 1718badee..dfd9c167d 100644 --- a/src/main/java/org/jitsi/jigasi/transcription/WhisperTranscriptionService.java +++ b/src/main/java/org/jitsi/jigasi/transcription/WhisperTranscriptionService.java @@ -17,12 +17,11 @@ */ package org.jitsi.jigasi.transcription; -import org.eclipse.jetty.websocket.api.*; import org.jitsi.impl.neomedia.device.*; -import org.jitsi.utils.logging.*; +import org.jitsi.utils.logging.Logger; -import java.nio.*; -import java.util.function.*; +import java.nio.ByteBuffer; +import java.util.function.Consumer; /** @@ -52,6 +51,12 @@ public AudioMixerMediaDevice getMediaDevice(ReceiveStreamBufferListener listener return this.mediaDevice; } + @Override + public boolean disableSilenceFilter() + { + return true; + } + /** * No configuration required yet */ From fed82f8b60040e0c798be0d3bcb629c913662c58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D1=8F=D0=BD=20=D0=9C=D0=B8=D0=BD=D0=BA?= =?UTF-8?q?=D0=BE=D0=B2?= Date: Mon, 18 Sep 2023 15:40:20 -0500 Subject: [PATCH 2/2] suash: Fix imports. --- .../jigasi/transcription/WhisperTranscriptionService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jitsi/jigasi/transcription/WhisperTranscriptionService.java b/src/main/java/org/jitsi/jigasi/transcription/WhisperTranscriptionService.java index dfd9c167d..3769de844 100644 --- a/src/main/java/org/jitsi/jigasi/transcription/WhisperTranscriptionService.java +++ b/src/main/java/org/jitsi/jigasi/transcription/WhisperTranscriptionService.java @@ -18,10 +18,10 @@ package org.jitsi.jigasi.transcription; import org.jitsi.impl.neomedia.device.*; -import org.jitsi.utils.logging.Logger; +import org.jitsi.utils.logging.*; -import java.nio.ByteBuffer; -import java.util.function.Consumer; +import java.nio.*; +import java.util.function.*; /**