You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
1.0 KiB
28 lines
1.0 KiB
import requests |
|
|
|
# 配置 |
|
API_URL = "http://localhost:8001/api/segment" |
|
AUDIO_FILE = "大湖口镇米湖村适配器-763882-20251101083039.mp3" |
|
|
|
# 上传音频文件 |
|
with open(AUDIO_FILE, "rb") as f: |
|
files = {"file": (AUDIO_FILE, f, "audio/mpeg")} |
|
response = requests.post(API_URL, files=files) |
|
|
|
# 解析结果 |
|
result = response.json() |
|
|
|
if result["code"] == 200: |
|
data = result["data"] |
|
print(f"✓ 处理成功!") |
|
print(f" 会话ID: {data['session_id']}") |
|
print(f" 原始片段: {data['statistics']['original_segments']}") |
|
print(f" 合并后: {data['statistics']['merged_segments']}") |
|
print(f" 最终片段: {data['statistics']['final_segments']}") |
|
print(f" 总耗时: {data['statistics']['processing_time']}秒") |
|
print(f"\n输出目录: {data['output_folder']}") |
|
print(f"\n片段列表:") |
|
for seg in data['segments']: |
|
print(f" {seg['filename']}: {seg['start_time']}s - {seg['end_time']}s ({seg['duration']}s)") |
|
else: |
|
print(f"✗ 处理失败: {result['message']}") |