Update app.py
Browse files
app.py
CHANGED
@@ -10,8 +10,8 @@ from dataset import MaskGenerator
|
|
10 |
import onnxruntime, onnx
|
11 |
import matplotlib.pyplot as plt
|
12 |
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
|
13 |
-
from
|
14 |
-
from
|
15 |
import pandas as pd
|
16 |
import torchaudio
|
17 |
|
@@ -125,38 +125,34 @@ if st.button('Сгенерировать потери'):
|
|
125 |
st.audio('lossy.wav')
|
126 |
st.text('Улучшенное аудио')
|
127 |
st.audio('enhanced.wav')
|
128 |
-
data_clean, samplerate = torchaudio.load('target.wav')
|
129 |
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
|
|
|
|
142 |
stoi_mass=[stoi_orig, stoi_lossy, stoi_enhanced]
|
143 |
|
144 |
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
#if samplerate != 16000:
|
151 |
-
# data_lossy = librosa.resample(data_lossy, orig_sr=48000, target_sr=16000)
|
152 |
-
# data_clean = librosa.resample(data_clean, orig_sr=48000, target_sr=16000)
|
153 |
-
# data_enhanced = librosa.resample(data_enhanced, orig_sr=48000, target_sr=16000)
|
154 |
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
|
159 |
-
|
160 |
|
161 |
|
162 |
|
@@ -164,7 +160,7 @@ if st.button('Сгенерировать потери'):
|
|
164 |
|
165 |
df['Audio'] = ['Clean', 'Lossy', 'Enhanced']
|
166 |
|
167 |
-
|
168 |
|
169 |
df['STOI'] = stoi_mass
|
170 |
|
|
|
10 |
import onnxruntime, onnx
|
11 |
import matplotlib.pyplot as plt
|
12 |
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
|
13 |
+
from pystoi import stoi
|
14 |
+
from pesq import pesq
|
15 |
import pandas as pd
|
16 |
import torchaudio
|
17 |
|
|
|
125 |
st.audio('lossy.wav')
|
126 |
st.text('Улучшенное аудио')
|
127 |
st.audio('enhanced.wav')
|
|
|
128 |
|
129 |
+
|
130 |
+
data_clean, samplerate = sf.read('target.wav')
|
131 |
+
data_lossy, samplerate = sf.read('lossy.wav')
|
132 |
+
data_enhanced, samplerate = sf.read('enhanced.wav')
|
133 |
+
min_len = min(data_clean.shape[0], data_lossy.shape[0], data_enhanced.shape[0])
|
134 |
+
data_clean = data_clean[:min_len]
|
135 |
+
data_lossy = data_lossy[:min_len]
|
136 |
+
data_enhanced = data_enhanced[:min_len]
|
137 |
+
|
138 |
+
|
139 |
+
stoi_orig = round(stoi(data_clean, data_clean, samplerate, extended=False),5)
|
140 |
+
stoi_lossy = round(stoi(data_clean, data_lossy , samplerate, extended=False),5)
|
141 |
+
stoi_enhanced = round(stoi(data_clean, data_enhanced, samplerate, extended=False),5)
|
142 |
+
|
143 |
stoi_mass=[stoi_orig, stoi_lossy, stoi_enhanced]
|
144 |
|
145 |
|
146 |
+
if samplerate != 16000:
|
147 |
+
data_lossy = librosa.resample(data_lossy, orig_sr=48000, target_sr=16000)
|
148 |
+
data_clean = librosa.resample(data_clean, orig_sr=48000, target_sr=16000)
|
149 |
+
data_enhanced = librosa.resample(data_enhanced, orig_sr=48000, target_sr=16000)
|
|
|
|
|
|
|
|
|
|
|
150 |
|
151 |
+
pesq_orig = pesq(fs = 16000, ref = data_clean, deg = data_clean, mode='nb')
|
152 |
+
pesq_lossy = pesq(fs = 16000, ref = data_clean, deg = data_lossy, mode='nb')
|
153 |
+
pesq_enhanced = pesq(fs = 16000, ref = data_clean, deg = data_enhanced, mode='nb')
|
154 |
|
155 |
+
psq_mas=[pesq_orig, pesq_lossy, pesq_enhanced]
|
156 |
|
157 |
|
158 |
|
|
|
160 |
|
161 |
df['Audio'] = ['Clean', 'Lossy', 'Enhanced']
|
162 |
|
163 |
+
df['PESQ'] = psq_mas
|
164 |
|
165 |
df['STOI'] = stoi_mass
|
166 |
|