
// recognition event type
enum RecognitionEventType {
  // partial
  partial,
  // final result
  finalResult,
  // wakeword
  wakeword,
  // error
  error
}

// recognition event
class RecognitionEvent {
  final RecognitionEventType type;
  final String? text;

  RecognitionEvent({required this.type, this.text});

  factory RecognitionEvent.fromJson(Map<String, dynamic> json) {
    return RecognitionEvent(
      type: RecognitionEventType.values.firstWhere((e) => e.name == json['type']),
      text: json['text'],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'type': type.name,
      'text': text,
    };
  }

  @override
  String toString() {
    return 'RecognitionEvent{type: $type, text: $text}';
  }
}