// Şarkı analizi: BeatAnalyzer + Whisper + Exporter → beat_json — app kodu. import 'dart:convert'; import 'dart:io'; import 'package:dio/dio.dart'; import '../lib/comfy/workflow/sarki_analiz_workflow.dart'; Future main() async { const base = 'http://127.0.0.1:8188'; final dio = Dio(BaseOptions(baseUrl: base, receiveTimeout: const Duration(minutes: 8))); const ad = 'test_analiz.mp3'; // ComfyUI input'ta mevcut final wf = sarkiAnalizWorkflowOlustur(ad, barsPerSection: 4, sozCikar: true); final r = await dio.post('/prompt', data: {'prompt': wf, 'client_id': 'fikoyt-an3'}); final pid = r.data['prompt_id'] as String; stdout.writeln('pid $pid — analiz çalışıyor...'); for (var i = 0; i < 160; i++) { await Future.delayed(const Duration(seconds: 3)); final h = (await dio.get('/history/$pid')).data as Map; if (h[pid] != null) { final st = (h[pid] as Map)['status'] as Map?; if (st?['status_str'] == 'error') { stdout.writeln('HATA'); exit(1); } if (st?['completed'] == true) { final out = (h[pid] as Map)['outputs'] as Map; final bj = ((out['4'] as Map?)?['beat_json'] as List?)?.first; if (bj == null) { stdout.writeln('beat_json boş: ${out.keys}'); exit(1); } final d = jsonDecode(bj as String) as Map; final a = d['analysis'] as Map; final secs = d['sections'] as List; stdout.writeln('BASARILI: BPM=${a['bpm']} key=${a['key']} bölüm=${secs.length}'); for (final s in secs) { final m = s as Map; stdout.writeln(' bölüm ${m['index']}: ${(m['duration'] as num).toStringAsFixed(1)}sn vocal=${m['has_vocal']} söz="${m['lyrics']}"'); } exit(0); } } } exit(1); }