diff --git a/src/main/java/org/jitsi/jigasi/stats/Statistics.java b/src/main/java/org/jitsi/jigasi/stats/Statistics.java index b99babee..ddf046ea 100644 --- a/src/main/java/org/jitsi/jigasi/stats/Statistics.java +++ b/src/main/java/org/jitsi/jigasi/stats/Statistics.java @@ -129,6 +129,26 @@ public class Statistics */ public static final String TOTAL_TRANSCRIBER_G_MINUTES = "total_transcriber_g_minutes"; + /** + * The total number of milliseconds submitted to Google API for transcription. + */ + public static final String TOTAL_TRANSCRIBER_GGL_MILLIS = "total_transcriber_ggl_millis"; + + /** + * The total number of milliseconds submitted to Oracle API for transcription. + */ + public static final String TOTAL_TRANSCRIBER_OCI_MILLIS = "total_transcriber_oci_millis"; + + /** + * The total number of milliseconds submitted to Skynet/Whisper for transcription. + */ + public static final String TOTAL_TRANSCRIBER_WSP_MILLIS = "total_transcriber_wsp_millis"; + + /** + * The total number of milliseconds submitted to Vosk for transcription. + */ + public static final String TOTAL_TRANSCRIBER_VSK_MILLIS = "total_transcriber_vsk_millis"; + /** * The total number of requests submitted to the Google Cloud Speech API. */ @@ -317,6 +337,34 @@ public class Statistics TOTAL_TRANSCRIBER_G_REQUESTS, "Total number of transcriber requests."); + /** + * The total number of milliseconds submitted to Google API for transcription. + */ + private static LongGaugeMetric totalTranscriberGoogleMillis = JigasiMetricsContainer.INSTANCE.registerLongGauge( + TOTAL_TRANSCRIBER_GGL_MILLIS, + "Total number of milliseconds sent to Google's API."); + + /** + * The total number of milliseconds submitted to Oracle Cloud API for transcription. + */ + private static LongGaugeMetric totalTranscriberOracleMillis = JigasiMetricsContainer.INSTANCE.registerLongGauge( + TOTAL_TRANSCRIBER_OCI_MILLIS, + "Total number of milliseconds sent to OCI API."); + + /** + * The total number of milliseconds submitted to Skynet Whisper for transcription. + */ + private static LongGaugeMetric totalTranscriberWhisperMillis = JigasiMetricsContainer.INSTANCE.registerLongGauge( + TOTAL_TRANSCRIBER_WSP_MILLIS, + "Total number of milliseconds sent to Skynet Whisper."); + + /** + * The total number of milliseconds submitted to Vosk for transcription. + */ + private static LongGaugeMetric totalTranscriberVoskMillis = JigasiMetricsContainer.INSTANCE.registerLongGauge( + TOTAL_TRANSCRIBER_VSK_MILLIS, + "Total number of milliseconds sent to Vosk."); + /** * Cumulative number of seconds of all conferences. */ @@ -407,6 +455,10 @@ public static synchronized void sendJSON( stats.put(TOTAL_TRANSCRIBER_G_REQUESTS, totalTrasnscriberRequests.get()); stats.put(TOTAL_TRANSCRIBER_G_MINUTES, totalTranscriberMinutes.get()); + stats.put(TOTAL_TRANSCRIBER_GGL_MILLIS, totalTranscriberGoogleMillis.get()); + stats.put(TOTAL_TRANSCRIBER_OCI_MILLIS, totalTranscriberOracleMillis.get()); + stats.put(TOTAL_TRANSCRIBER_WSP_MILLIS, totalTranscriberWhisperMillis.get()); + stats.put(TOTAL_TRANSCRIBER_VSK_MILLIS, totalTranscriberVoskMillis.get()); stats.put(TOTAL_TRANSCRIBER_STARTED, totalTrasnscriberStarted.get()); stats.put(TOTAL_TRANSCRIBER_STOPPED, totalTrasnscriberStopped.get()); @@ -636,6 +688,38 @@ public static void incrementTotalTranscriberMinutes(long value) totalTranscriberMinutes.addAndGet(value); } + /** + * Increment the value of total number of milliseconds sent to Google API for transcription. + */ + public static void incrementTotalTranscriberGoogleMillis(long value) + { + totalTranscriberGoogleMillis.addAndGet(value); + } + + /** + * Increment the value of total number of milliseconds sent to Oracle API for transcription. + */ + public static void incrementTotalTranscriberOracleMillis(long value) + { + totalTranscriberOracleMillis.addAndGet(value); + } + + /** + * Increment the value of total number of milliseconds sent to Skynet Whisper for transcription. + */ + public static void incrementTotalTranscriberWhisperMillis(long value) + { + totalTranscriberWhisperMillis.addAndGet(value); + } + + /** + * Increment the value of total number of milliseconds sent to Vosk for transcription. + */ + public static void incrementTotalTranscriberVoskMillis(long value) + { + totalTranscriberVoskMillis.addAndGet(value); + } + /** * Increment the value of total number of transcriber request. */ diff --git a/src/main/java/org/jitsi/jigasi/transcription/Participant.java b/src/main/java/org/jitsi/jigasi/transcription/Participant.java index aa244bb1..f8486c45 100644 --- a/src/main/java/org/jitsi/jigasi/transcription/Participant.java +++ b/src/main/java/org/jitsi/jigasi/transcription/Participant.java @@ -23,6 +23,7 @@ import org.jitsi.xmpp.extensions.jitsimeet.*; import org.jitsi.utils.logging.*; import org.jivesoftware.smack.packet.*; +import org.jitsi.jigasi.stats.*; import javax.media.format.*; import java.nio.*; @@ -152,6 +153,8 @@ public class Participant */ private SilenceFilter silenceFilter = null; + private String transcriptionServiceName; + /** * Create a participant with a given name and audio stream * @@ -173,6 +176,7 @@ public class Participant { this.transcriber = transcriber; this.identifier = identifier; + this.transcriptionServiceName = transcriber.getTranscriptionService().getClass().getSimpleName(); if (filterAudio) { @@ -661,6 +665,35 @@ else if (silenceFilter.newSpeech()) }); } + private void incrementSentStats(int byteCount) + { + int divider = EXPECTED_AUDIO_LENGTH; + + if (transcriptionServiceName.equals("WhisperTranscriptionService") + || transcriptionServiceName.equals("OracleTranscriptionService")) + { + // the byte count for each 20ms packet if the audio format is 16kHz mono + divider = 640; + } + + long millis = byteCount / divider * 20; + + switch (transcriptionServiceName) { + case "WhisperTranscriptionService": + Statistics.incrementTotalTranscriberWhisperMillis(millis); + break; + case "OracleTranscriptionService": + Statistics.incrementTotalTranscriberOracleMillis(millis); + break; + case "VoskTranscriptionService": + Statistics.incrementTotalTranscriberVoskMillis(millis); + break; + case "GoogleCloudTranscriptionService": + Statistics.incrementTotalTranscriberGoogleMillis(millis); + break; + } + } + /** * Send the specified audio to the TranscriptionService. *
@@ -681,6 +714,7 @@ private void sendRequest(byte[] audio) if (session != null && !session.ended()) { session.sendRequest(request); + incrementSentStats(audio.length); } else if (transcriber.getTranscriptionService().supportsStreamRecognition()) // re-establish prematurely ended streaming session @@ -704,6 +738,7 @@ else if (transcriber.getTranscriptionService().supportsStreamRecognition()) transcriber.getTranscriptionService().sendSingleRequest( request, this::notify); + incrementSentStats(audio.length); } }); }