RealtimeTranslationOutputAudioDeltaEvent.fromJson constructor

RealtimeTranslationOutputAudioDeltaEvent.fromJson(
  1. Map<String, dynamic> json
)

Creates from JSON.

Implementation

factory RealtimeTranslationOutputAudioDeltaEvent.fromJson(
  Map<String, dynamic> json,
) {
  if (json['type'] != 'session.output_audio.delta') {
    throw FormatException(
      'RealtimeTranslationOutputAudioDeltaEvent.fromJson expected type '
      '"session.output_audio.delta", got ${json['type']}',
    );
  }
  return RealtimeTranslationOutputAudioDeltaEvent(
    eventId: json['event_id'] as String,
    delta: json['delta'] as String,
    format: json['format'] as String?,
    sampleRate: json['sample_rate'] as int?,
    channels: json['channels'] as int?,
    elapsedMs: json['elapsed_ms'] as int?,
  );
}