79 lines
2.0 KiB
Dart
79 lines
2.0 KiB
Dart
class VoiceSession {
|
|
final String id;
|
|
final String userId;
|
|
final String? title;
|
|
final String status;
|
|
final int messageCount;
|
|
final DateTime createdAt;
|
|
final DateTime updatedAt;
|
|
|
|
VoiceSession({
|
|
required this.id,
|
|
required this.userId,
|
|
this.title,
|
|
required this.status,
|
|
this.messageCount = 0,
|
|
required this.createdAt,
|
|
required this.updatedAt,
|
|
});
|
|
|
|
factory VoiceSession.fromJson(Map<String, dynamic> json) => VoiceSession(
|
|
id: json['id'] as String,
|
|
userId: json['user_id'] as String,
|
|
title: json['title'] as String?,
|
|
status: json['status'] as String? ?? 'active',
|
|
messageCount: json['message_count'] as int? ?? 0,
|
|
createdAt: DateTime.parse(json['created_at'] as String),
|
|
updatedAt: DateTime.parse(json['updated_at'] as String),
|
|
);
|
|
}
|
|
|
|
class VoiceCommand {
|
|
final String id;
|
|
final String sessionId;
|
|
final String command;
|
|
final String? result;
|
|
final DateTime createdAt;
|
|
|
|
VoiceCommand({
|
|
required this.id,
|
|
required this.sessionId,
|
|
required this.command,
|
|
this.result,
|
|
required this.createdAt,
|
|
});
|
|
|
|
factory VoiceCommand.fromJson(Map<String, dynamic> json) => VoiceCommand(
|
|
id: json['id'] as String,
|
|
sessionId: json['session_id'] as String,
|
|
command: json['command'] as String,
|
|
result: json['result'] as String?,
|
|
createdAt: DateTime.parse(json['created_at'] as String),
|
|
);
|
|
}
|
|
|
|
class TranscribeRequest {
|
|
final String audioBase64;
|
|
final String? sessionId;
|
|
|
|
TranscribeRequest({required this.audioBase64, this.sessionId});
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'audio_base64': audioBase64,
|
|
if (sessionId != null) 'session_id': sessionId,
|
|
};
|
|
}
|
|
|
|
class TranscribeResponse {
|
|
final String text;
|
|
final String? sessionId;
|
|
|
|
TranscribeResponse({required this.text, this.sessionId});
|
|
|
|
factory TranscribeResponse.fromJson(Map<String, dynamic> json) =>
|
|
TranscribeResponse(
|
|
text: json['text'] as String,
|
|
sessionId: json['session_id'] as String?,
|
|
);
|
|
}
|