File size: 1,793 Bytes
af28602
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
---

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 编译的。