translationTranscript function

Future<void> translationTranscript(
  1. TranslationTranscriptOptions options
)

Handles the translation:transcript socket event. Called when a translation transcript (text) is available for display.

Implementation

Future<void> translationTranscript(TranslationTranscriptOptions options) async {
  try {
    final data = options.data;

    // Update transcript state
    options.updateTranscripts?.call((prev) {
      final next = [...prev, data];
      // Keep only last N transcripts
      if (next.length > options.maxTranscripts) {
        return next.sublist(next.length - options.maxTranscripts);
      }
      return next;
    });

    // Call custom callback
    options.onTranscriptReceived?.call(data);
  } catch (e) {
    // Handle error silently
  }
}