in src/backend/transcriber/src/main/java/com/amazonaws/transcriber/ResponseHandler.java [89:107]
public void onStream(TranscriptResultStream event) {
Transcript transcript = ((TranscriptEvent) event).transcript();
transcript.results().stream()
.filter(not(result ->result.isPartial() && shouldDebounce()))
.flatMap(result -> result.alternatives().stream().limit(1)
.map(Alternative::transcript)
.filter(not(Strings::isNullOrEmpty))
.map(transcriptText -> new TranscribeStreamData(result, transcriptText)))
.peek(this::logResult)
.forEach(streamData -> {
Result result = streamData.getResult();
logger.info(streamData.getTranscript());
long startTimestamp = responseTime.plusMillis(Math.round(1000 * result.startTime())).toEpochMilli();
writer.writeToDynamoDB(startTimestamp, streamData.getTranscript(), result);
// if we've got here we need to reset the debounce timer
debounceTime = System.currentTimeMillis();
});
}