Add the Flutter video editing application with project management, media import, timeline editing, preview, AI assistance, diagnostics and settings. Include shared UI and native host packages, platform runners, application tests and release tooling. Provide usage and contribution guides, the MIT license and third-party notices. Exclude local credentials, build outputs and validation data.
101 lines
3.8 KiB
Dart
101 lines
3.8 KiB
Dart
import 'dart:convert';
|
|
import 'dart:io';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'support/processing_fixture.dart';
|
|
|
|
import 'package:cutdex/integrations/runtime/processing_configuration.dart';
|
|
|
|
void main() {
|
|
for (var mask = 0; mask < 16; mask++) {
|
|
test('processing capabilities are independent: $mask', () async {
|
|
final root = await Directory.systemTemp.createTemp('processing-matrix-');
|
|
addTearDown(() => root.delete(recursive: true));
|
|
final config = await processingFixture(root, mask);
|
|
expect(config.transcriptionModel != null, mask & 1 != 0);
|
|
expect(config.translationModel != null, mask & 2 != 0);
|
|
expect(config.vocalSeparationModel != null, mask & 4 != 0);
|
|
expect(config.backgroundRemovalModel != null, mask & 8 != 0);
|
|
});
|
|
}
|
|
test(
|
|
'stale model paths and missing runtime disable optional capabilities',
|
|
() async {
|
|
final root = await Directory.systemTemp.createTemp('processing-stale-');
|
|
addTearDown(() => root.delete(recursive: true));
|
|
final config = await processingFixture(root, 7, stale: true);
|
|
expect(config.transcriptionModel, isNull);
|
|
expect(config.translationModel, isNull);
|
|
expect(config.vocalSeparationModel, isNull);
|
|
expect(config.backgroundRemovalModel, isNull);
|
|
expect(
|
|
ProcessingConfiguration.fromPaths(
|
|
root: '${root.path}/missing',
|
|
transcriptionPath: '${root.path}/asr',
|
|
translationPath: '${root.path}/translation',
|
|
vocalPath: '${root.path}/audio/melband.pt',
|
|
),
|
|
isNull,
|
|
);
|
|
},
|
|
);
|
|
|
|
test('translation configuration is independent of ASR, audio models and FFmpeg', () async {
|
|
final suffix = Platform.isWindows ? '.exe' : '';
|
|
final root = await Directory.systemTemp.createTemp('cutdex configuration ');
|
|
try {
|
|
for (final path in [
|
|
'runtime/bin/cutdex-processing-worker$suffix',
|
|
'runtime/workers/translation/cutdex-m2m100-worker$suffix',
|
|
'Documents/Cutdex/Resources/Processing/Translation/m2m100-418m/1/model.bin',
|
|
'Documents/Cutdex/Resources/Processing/Translation/m2m100-418m/1/config.json',
|
|
'Documents/Cutdex/Resources/Processing/Translation/m2m100-418m/1/shared_vocabulary.json',
|
|
'Documents/Cutdex/Resources/Processing/Translation/m2m100-418m/1/sentencepiece.bpe.model',
|
|
]) {
|
|
final file = File('${root.path}/$path');
|
|
await file.parent.create(recursive: true);
|
|
await file.writeAsString('fixture');
|
|
}
|
|
final script = File('${root.path}/configuration.dart');
|
|
await script.writeAsString('''
|
|
import 'dart:convert';
|
|
import 'package:cutdex/integrations/runtime/processing_configuration.dart';
|
|
void main() {
|
|
final config = ProcessingConfiguration.configured()!;
|
|
print(jsonEncode({
|
|
'translation': config.translationModel != null,
|
|
'transcription': config.transcriptionModel != null,
|
|
'vocals': config.vocalSeparationModel != null,
|
|
'inheritsEnvironment': config.backend.includeParentEnvironment,
|
|
'provider': config.backend.environment['CUTDEX_ORT_PROVIDER'],
|
|
}));
|
|
}
|
|
''');
|
|
final result = await Process.run(
|
|
'dart',
|
|
[
|
|
'--packages=${File('.dart_tool/package_config.json').absolute.path}',
|
|
script.path,
|
|
],
|
|
runInShell: Platform.isWindows,
|
|
environment: {
|
|
'HOME': root.path,
|
|
'USERPROFILE': root.path,
|
|
'CUTDEX_PROCESSING_ROOT': '${root.path}/runtime',
|
|
},
|
|
);
|
|
expect(result.exitCode, 0, reason: result.stderr.toString());
|
|
expect(jsonDecode(result.stdout as String), {
|
|
'translation': true,
|
|
'transcription': false,
|
|
'vocals': false,
|
|
'inheritsEnvironment': false,
|
|
'provider': 'cpu',
|
|
});
|
|
} finally {
|
|
await root.delete(recursive: true);
|
|
}
|
|
}, skip: !(Platform.isMacOS || Platform.isWindows));
|
|
}
|