-- ============================================================
-- KTV服务 uapi/uapiio 补全迁移 Part 1
-- 输入字段使用 _file 命名规范（与 Sage image/video/audio 统一）
-- ============================================================

-- ASR语音识别
INSERT INTO uapiio (id, name, description, input_fields) VALUES (
  'ktv_asr_transcribe_io', 'KTV语音识别', '上传音频文件，返回识别文本和时间戳',
  '{"audio_file":{"type":"string","required":true,"description":"音频文件URL"},"language":{"type":"string","required":false,"default":"zh","description":"语言代码"}}'
) ON DUPLICATE KEY UPDATE description=VALUES(description), input_fields=VALUES(input_fields);

-- Demucs音频分离
INSERT INTO uapiio (id, name, description, input_fields) VALUES (
  'ktv_demucs_separate_io', 'KTV音频分离', '分离人声和伴奏',
  '{"audio_file":{"type":"string","required":true,"description":"音频文件URL"}}'
) ON DUPLICATE KEY UPDATE description=VALUES(description), input_fields=VALUES(input_fields);

-- 人脸检测
INSERT INTO uapiio (id, name, description, input_fields) VALUES (
  'ktv_face_detect_io', 'KTV人脸检测', '检测图像中的人脸位置',
  '{"image_file":{"type":"string","required":true,"description":"图像URL"}}'
) ON DUPLICATE KEY UPDATE description=VALUES(description), input_fields=VALUES(input_fields);

-- 人脸识别
INSERT INTO uapiio (id, name, description, input_fields) VALUES (
  'ktv_face_recognize_io', 'KTV人脸识别', '识别人脸身份',
  '{"image_file":{"type":"string","required":true,"description":"图像URL"},"face_id":{"type":"string","required":false,"description":"人脸ID"}}'
) ON DUPLICATE KEY UPDATE description=VALUES(description), input_fields=VALUES(input_fields);

-- 人脸比对
INSERT INTO uapiio (id, name, description, input_fields) VALUES (
  'ktv_face_compare_io', 'KTV人脸比对', '比较两张人脸的相似度',
  '{"image_file1":{"type":"string","required":true,"description":"图像1 URL"},"image_file2":{"type":"string","required":true,"description":"图像2 URL"}}'
) ON DUPLICATE KEY UPDATE description=VALUES(description), input_fields=VALUES(input_fields);

-- 字幕渲染
INSERT INTO uapiio (id, name, description, input_fields) VALUES (
  'ktv_subtitle_render_io', 'KTV字幕渲染', '将歌词时间轴渲染为ASS字幕文件',
  '{"lyrics_json":{"type":"string","required":true,"description":"歌词时间轴JSON"},"width":{"type":"integer","required":false,"default":1920,"description":"视频宽度"},"height":{"type":"integer","required":false,"default":1080,"description":"视频高度"}}'
) ON DUPLICATE KEY UPDATE description=VALUES(description), input_fields=VALUES(input_fields);

-- 视频合并
INSERT INTO uapiio (id, name, description, input_fields) VALUES (
  'ktv_merge_video_io', 'KTV视频合并', '合并视频、音频和字幕',
  '{"video_file":{"type":"string","required":false,"description":"视频URL"},"audio_file":{"type":"string","required":false,"description":"音频URL"},"subtitle_file":{"type":"string","required":false,"description":"ASS字幕URL"},"output_format":{"type":"string","required":false,"default":"mp4","description":"输出格式"}}'
) ON DUPLICATE KEY UPDATE description=VALUES(description), input_fields=VALUES(input_fields);

-- 歌曲评分
INSERT INTO uapiio (id, name, description, input_fields) VALUES (
  'ktv_songrate_evaluate_io', 'KTV歌曲评分', 'AI评估歌曲质量',
  '{"audio_file":{"type":"string","required":true,"description":"音频文件URL"},"scene":{"type":"string","required":false,"default":"pop","description":"场景类型"}}'
) ON DUPLICATE KEY UPDATE description=VALUES(description), input_fields=VALUES(input_fields);

-- 音乐合成（异步）
INSERT INTO uapiio (id, name, description, input_fields) VALUES (
  'ktv_synth_generate_io', 'KTV音乐合成', 'AI歌声合成（异步任务）',
  '{"lyrics":{"type":"string","required":true,"description":"歌词文本"},"style":{"type":"string","required":false,"default":"pop","description":"演唱风格"},"audio_file":{"type":"string","required":false,"description":"参考音频URL（声音克隆）"}}'
) ON DUPLICATE KEY UPDATE description=VALUES(description), input_fields=VALUES(input_fields);

-- 合成状态查询
INSERT INTO uapiio (id, name, description, input_fields) VALUES (
  'ktv_synth_status_io', 'KTV合成状态', '查询音乐合成任务状态',
  '{"task_id":{"type":"string","required":true,"description":"任务ID"}}'
) ON DUPLICATE KEY UPDATE description=VALUES(description), input_fields=VALUES(input_fields);

-- 超分辨率（异步）
INSERT INTO uapiio (id, name, description, input_fields) VALUES (
  'ktv_realesrgan_upscale_io', 'KTV超分辨率', '图像/视频超分辨率（异步任务）',
  '{"image_file":{"type":"string","required":true,"description":"图像URL"},"scale":{"type":"integer","required":false,"default":2,"description":"放大倍数"}}'
) ON DUPLICATE KEY UPDATE description=VALUES(description), input_fields=VALUES(input_fields);

-- 超分状态查询
INSERT INTO uapiio (id, name, description, input_fields) VALUES (
  'ktv_realesrgan_status_io', 'KTV超分状态', '查询超分任务状态',
  '{"task_id":{"type":"string","required":true,"description":"任务ID"}}'
) ON DUPLICATE KEY UPDATE description=VALUES(description), input_fields=VALUES(input_fields);

-- RVC声音转换
INSERT INTO uapiio (id, name, description, input_fields) VALUES (
  'ktv_rvc_convert_io', 'KTV声音转换', '声音克隆/变声',
  '{"audio_file":{"type":"string","required":true,"description":"输入音频URL"},"voice_model":{"type":"string","required":true,"description":"目标声音模型名"}}'
) ON DUPLICATE KEY UPDATE description=VALUES(description), input_fields=VALUES(input_fields);

-- 视频评估
INSERT INTO uapiio (id, name, description, input_fields) VALUES (
  'ktv_video_eval_evaluate_io', 'KTV视频评估', '评估视频质量',
  '{"video_file":{"type":"string","required":true,"description":"视频URL"}}'
) ON DUPLICATE KEY UPDATE description=VALUES(description), input_fields=VALUES(input_fields);
