getFormattedTranscriptToSave static method

String getFormattedTranscriptToSave(
  1. List<TranscriptionModel> transcriptions
)

Implementation

static String getFormattedTranscriptToSave(
    List<TranscriptionModel> transcriptions) {
  final StringBuffer contentBuffer = StringBuffer();

  for (var entry in transcriptions) {
    if (!entry.isFinal) continue;

    final String caption = entry.transcription.trim();

    final String translatedCaption =
    (entry.translatedTranscription != null &&
        entry.translatedTranscription!.trim().isNotEmpty)
        ? entry.translatedTranscription!.trim()
        : caption;

    contentBuffer.writeln('${entry.name} ${entry.timestamp}');
    contentBuffer.writeln('Caption:');
    contentBuffer.writeln(caption);
    contentBuffer.writeln('Translated Caption:');
    contentBuffer.writeln(translatedCaption);
    contentBuffer.writeln(); // spacing between entries
  }

  return contentBuffer.toString();
}