Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
rpurdel committed Aug 22, 2024
1 parent ad49156 commit fb54676
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/main/java/org/jitsi/jigasi/transcription/WhisperWebsocket.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package org.jitsi.jigasi.transcription;

import com.fasterxml.uuid.*;
import org.eclipse.jetty.websocket.api.*;
import org.eclipse.jetty.websocket.api.annotations.*;
import org.eclipse.jetty.websocket.client.*;
Expand Down Expand Up @@ -44,10 +45,12 @@ public class WhisperWebsocket

private Map<String, Instant> participantTranscriptionStarts = new ConcurrentHashMap<>();

private Map<String, UUID> participantTranscriptionIds= new ConcurrentHashMap<>();

private static final int maxRetryAttempts = 10;


/* Transcription language requested by the user who requested the transcription */
/* Transcription language requested by the user who started the transcription */
public String transcriptionTag = "en-US";

private final static Logger logger
Expand Down Expand Up @@ -212,6 +215,7 @@ public void onClose(int statusCode, String reason)
participants = null;
participantListeners = null;
participantTranscriptionStarts = null;
participantTranscriptionIds = null;
try
{
if (ws != null)
Expand Down Expand Up @@ -242,18 +246,21 @@ public void onMessage(String msg)
}

result = obj.getString("text");
UUID id = UUID.fromString(obj.getString("id"));
float stability = obj.getFloat("variance");
if (logger.isDebugEnabled())
{
logger.debug("Received result: " + result);
}

Instant startTranscription = participantTranscriptionStarts.getOrDefault(participantId, null);
UUID transcriptionId = participantTranscriptionIds.getOrDefault(participantId, null);

if (startTranscription == null)
{
Date now = new Date();
startTranscription = now.toInstant();
transcriptionId = Generators.timeBasedReorderedGenerator().generate();
participantTranscriptionIds.put(participantId, transcriptionId);
participantTranscriptionStarts.put(participantId, startTranscription);
}

Expand All @@ -272,18 +279,19 @@ public void onMessage(String msg)
}
TranscriptionResult tsResult = new TranscriptionResult(
participant,
id,
transcriptionId,
startTranscription,
partial,
getLanguage(participant),
stability,
new TranscriptionAlternative(result));
l.notify(tsResult);
}
if (!partial)
{
participantTranscriptionStarts.remove(participantId);
}
}
if (!partial)
{
participantTranscriptionStarts.remove(participantId);
participantTranscriptionIds.remove(participantId);
}
}

Expand Down

0 comments on commit fb54676

Please sign in to comment.