File size: 1,575 Bytes
9b98548
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
61
62
63
64
65
66
67
68
69
70
71
import numpy as np
import matplotlib.pyplot as plt

# Natural MOS to AVA MOS

def linear_function(x):
    return 8 * x - 8

def quadratic_function(x):
    return -0.0816 * (x - 5) ** 2 + 5

# Natural MOS to AVA MOS
def nat2avaMOS(x):
    if x <= 1.5:
        return linear_function(x)
    elif x >1.5 and x <= 5:
        return quadratic_function(x)

# Word error rate to Intellibility Score (X is percentage)
def WER2INTELI(x):
    if x <= 10:
        return 100
    elif x <= 100:
        slope = (30 - 100) / (100 - 10)
        intercept = 100 - slope * 10
        return slope * x + intercept
    else:
        return 100 * np.exp(-0.01 * (x - 100))

# # 生成 x 值
# x = np.linspace(0, 200, 400)  # 从0到200生成400个点

# # 计算对应的 y 值
# y = [WER2INT(xi) for xi in x]

# # 绘制函数图像
# plt.plot(x, y)
# plt.xlabel('x')
# plt.ylabel('f(x)')
# plt.title('Custom Function')
# plt.grid(True)
# plt.show()

# # 生成 x 值的范围
# x1 = np.linspace(1, 1.5, 100)
# x2 = np.linspace(1.5, 5, 100)

# # 计算对应的 y 值
# y1 = linear_function(x1)
# y2 = quadratic_function(x2)

# # 绘制线性部分
# plt.plot(x1, y1, label='Linear Function (1 <= x <= 1.5)')

# # 绘制二次部分
# plt.plot(x2, y2, label='Quadratic Function (1.5 <= x <= 5)')

# # 添加标签和标题
# plt.xlabel('Natural Mean Opinion Score')
# plt.ylabel('AVA Mean Opinion Score')
# plt.title('nat2avaMOS')

# # 添加图例
# plt.legend()

# # 显示图形
# plt.grid(True)

# # 显示图像
# plt.savefig("./local/nat2avaMOS.png")
# plt.savefig("./local/WER2INT.png")