Spaces:
Paused
Paused
| title: ViSQOL Audio Quality API | |
| emoji: 🎧 | |
| colorFrom: blue | |
| colorTo: green | |
| sdk: docker | |
| app_port: 8000 | |
| # pinned: false | |
| # license: apache-2.0 # 如果你想指定许可证 | |
| # ViSQOL 音频质量评估 API | |
| 这是一个基于 FastAPI 的 Hugging Face Space,用于提供 ViSQOL 音频质量评估服务。 | |
| 它使用了 Google 的 ViSQOL 算法 (Linux 编译版本,适用于 Python 3.8) 来计算参考音频和待评估音频之间的感知相似度得分 (MOS-LQO)。 | |
| ## API 端点 | |
| * **`POST /evaluate/`** | |
| * 接收两个音频文件 (`reference` 和 `degraded`) 以及一个模式参数 (`mode`, 'audio' 或 'speech')。 | |
| * 返回包含 MOS-LQO 得分和其他信息的 JSON 响应。 | |
| ## 如何使用 | |
| 你可以通过发送 POST 请求到部署后的 Space URL 的 `/evaluate/` 路径来使用此 API。 | |
| **示例 (Python):** | |
| ```python | |
| import requests | |
| # 替换为你的 Space URL | |
| API_URL = "https://你的用户名-你的spacename.hf.space/evaluate/" | |
| files = { | |
| 'reference': open('path/to/reference.wav', 'rb'), | |
| 'degraded': open('path/to/degraded.wav', 'rb') | |
| } | |
| params = {'mode': 'audio'} # 或 'speech' | |
| response = requests.post(API_URL, files=files, params=params) | |
| if response.status_code == 200: | |
| result = response.json() | |
| print(f"评估结果: {result}") | |
| if result['status'] == '处理成功': | |
| print(f"MOS-LQO: {result['moslqo']}") | |
| else: | |
| print(f"处理失败: {result['error_message']}") | |
| else: | |
| print(f"API 请求错误: {response.status_code} - {response.text}") | |
| ``` | |
| ## 注意 | |
| * 输入的音频文件推荐使用 WAV 格式。 | |
| * 参考音频和待评估音频的采样率应该匹配。 | |
| * 此 Space 使用的 ViSQOL 库是为 Python 3.8 编译的。 |