in src/main/java/com/amazonaws/kvstranscribestreaming/publisher/DynamoDBTranscriptionPublisher.java [117:152]
private Item toDynamoDbItem(Result result) {
Item ddbItem = null;
Instant now = Instant.now();
if (result.alternatives().size() > 0) {
if (!result.alternatives().get(0).transcript().isEmpty()) {
ddbItem = new Item()
.withKeyComponent(TRANSACTION_ID, this.transactionId)
.withKeyComponent(START_TIME, result.startTime())
.withString(CALL_ID, this.callId)
.withString(SPEAKER, getSpeakerLabel())
.withDouble(END_TIME, result.endTime())
.withString(SEGMENT_ID, result.resultId())
.withString(TRANSCRIPT, result.alternatives().get(0).transcript())
// LoggedOn is an ISO-8601 string representation of when the entry was created
.withString(LOGGED_ON, now.toString())
.withBoolean(IS_PARTIAL, result.isPartial())
.withBoolean(IS_FINAL, Boolean.FALSE);
if (consoleLogTranscriptFlag) {
NumberFormat nf = NumberFormat.getInstance();
nf.setMinimumFractionDigits(3);
nf.setMaximumFractionDigits(3);
logger.info(String.format("Thread %s %d: [%s, %s] %s - %s",
Thread.currentThread().getName(),
System.currentTimeMillis(),
nf.format(result.startTime()),
nf.format(result.endTime()),
getSpeakerLabel(),
result.alternatives().get(0).transcript()));
}
}
}
return ddbItem;
}