RealtimeTranslationInputAudioBufferAppendEvent.fromJson constructor

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

Creates from JSON.

Implementation

factory RealtimeTranslationInputAudioBufferAppendEvent.fromJson(
  Map<String, dynamic> json,
) {
  if (json['type'] != 'session.input_audio_buffer.append') {
    throw FormatException(
      'RealtimeTranslationInputAudioBufferAppendEvent.fromJson expected type '
      '"session.input_audio_buffer.append", got ${json['type']}',
    );
  }
  if (json['audio'] == null) {
    throw const FormatException(
      'RealtimeTranslationInputAudioBufferAppendEvent.fromJson missing '
      'required "audio" field',
    );
  }
  return RealtimeTranslationInputAudioBufferAppendEvent(
    audio: json['audio'] as String,
    eventId: json['event_id'] as String?,
  );
}