Skip to content

Commit

Permalink
fix: prefer setting the timestamps from jigasi
Browse files Browse the repository at this point in the history
  • Loading branch information
rpurdel committed Aug 20, 2024
1 parent 9953c9a commit f51d347
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class WhisperWebsocket

private Map<String, Set<TranscriptionListener>> participantListeners = new ConcurrentHashMap<>();

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

private static final int maxRetryAttempts = 10;


Expand Down Expand Up @@ -271,6 +273,15 @@ public void onMessage(String msg)
{
logger.debug("Received final: " + result);
}

Instant startTranscription = participantTranscriptionStarts.getOrDefault(participantId, null);
if (startTranscription == null)
{
Date now = new Date();
startTranscription = now.toInstant();
participantTranscriptionStarts.put(participantId, startTranscription);
}

Set<TranscriptionListener> partListeners = participantListeners.getOrDefault(participantId, null);
if (!result.isEmpty() && partListeners != null)
{
Expand All @@ -287,13 +298,17 @@ public void onMessage(String msg)
TranscriptionResult tsResult = new TranscriptionResult(
participant,
id,
transcriptionStart,
startTranscription,
partial,
getLanguage(participant),
stability,
new TranscriptionAlternative(result));
l.notify(tsResult);
}
if (!partial)
{
participantTranscriptionStarts.remove(participantId);
}
}
}

Expand Down

0 comments on commit f51d347

Please sign in to comment.