import '../../core/languages.dart'; import '../../services/model_store.dart'; /// AI 자막 설정 class AiOptions { /// 원어 (undetermined = 자동 감지) final Language source; /// 만들 언어 (기본: 한국어·영어·일본어) final Set targets; final ModelSpec whisper; const AiOptions({ this.source = undetermined, required this.targets, required this.whisper, }); /// 기본값: 한국어·영어·일본어 static AiOptions defaults() => AiOptions(targets: {for (final c in defaultTargetLanguages) languageOf(c)}, whisper: whisperModels.first); /// 저장한 설정 (원어 코드 · 만들 언어 코드 · 음성인식 모델 id) 에서. 모르는 것은 처음 값으로 static AiOptions fromSaved({required String source, required List targets, required String whisper}) { final langs = { for (final c in targets) if (languageOf(c) != undetermined) languageOf(c), }; return AiOptions( source: languageOf(source), targets: langs.isEmpty ? {for (final c in defaultTargetLanguages) languageOf(c)} : langs, whisper: whisperModels.firstWhere((m) => m.id == whisper, orElse: () => whisperModels.first), ); } /// 원어와 다른 언어가 있으면 번역 모델 필요 (원어 자동이면 필요하다고 봄) bool get needsTranslation => source == undetermined || targets.any((t) => t.code != source.code); /// 259: 시작 전에 이미 번역이 필요한 것이 확실한지 - 원어를 골랐으면 다른 언어가 있을 때, /// 자동 감지면 만들 언어가 둘 이상일 때 (하나뿐이면 감지한 원어가 그 언어일 수 있어 감지한 뒤에 정한다) bool get surelyNeedsTranslation => source == undetermined ? targets.length > 1 : targets.any((t) => t.code != source.code); AiOptions copyWith({Language? source, Set? targets, ModelSpec? whisper}) => AiOptions( source: source ?? this.source, targets: targets ?? this.targets, whisper: whisper ?? this.whisper); }