XDHDD commited on
Commit
cefb462
1 Parent(s): 1d8e82e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -2
app.py CHANGED
@@ -194,8 +194,22 @@ if st.button('Сгенерировать потери'):
194
  stoi_mass=[stoi_orig, stoi_lossy, stoi_enhanced]
195
 
196
 
197
-
198
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  if samplerate != 8000:
200
  data_lossy = librosa.resample(data_lossy, orig_sr=48000, target_sr=8000)
201
  data_clean = librosa.resample(data_clean, orig_sr=48000, target_sr=8000)
@@ -209,8 +223,13 @@ if st.button('Сгенерировать потери'):
209
 
210
  psq_mas=[pesq_orig, pesq_lossy, pesq_enhanced]
211
 
 
 
212
 
213
 
 
 
 
214
  df = pd.DataFrame(columns=['Audio', 'PESQ', 'STOI', 'PLCMOS', 'LSD'])
215
 
216
  df['Audio'] = ['Clean', 'Lossy', 'Enhanced']
@@ -219,6 +238,8 @@ if st.button('Сгенерировать потери'):
219
 
220
  df['STOI'] = stoi_mass
221
 
 
 
222
  st.table(df)
223
 
224
 
 
194
  stoi_mass=[stoi_orig, stoi_lossy, stoi_enhanced]
195
 
196
 
197
+ def get_power(x, nfft):
198
+ S = librosa.stft(x, n_fft=nfft)
199
+ S = np.log(np.abs(S) ** 2 + 1e-8)
200
+ return S
201
+ def LSD(x_hr, x_pr):
202
+ S1 = get_power(x_hr, nfft=2048)
203
+ S2 = get_power(x_pr, nfft=2048)
204
+ lsd = np.mean(np.sqrt(np.mean((S1 - S2) ** 2, axis=-1)), axis=0)
205
+ return lsd
206
+
207
+ lsd_orig = LSD(data_clean,data_clean)
208
+ lsd_lossy = LSD(data_lossy,data_clean)
209
+ lsd_enhanced = LSD(data_enhanced,data_clean)
210
+
211
+ lsd_mass=[lsd_orig, lsd_lossy, lsd_enhanced]
212
+
213
  if samplerate != 8000:
214
  data_lossy = librosa.resample(data_lossy, orig_sr=48000, target_sr=8000)
215
  data_clean = librosa.resample(data_clean, orig_sr=48000, target_sr=8000)
 
223
 
224
  psq_mas=[pesq_orig, pesq_lossy, pesq_enhanced]
225
 
226
+
227
+
228
 
229
 
230
+
231
+
232
+
233
  df = pd.DataFrame(columns=['Audio', 'PESQ', 'STOI', 'PLCMOS', 'LSD'])
234
 
235
  df['Audio'] = ['Clean', 'Lossy', 'Enhanced']
 
238
 
239
  df['STOI'] = stoi_mass
240
 
241
+ df['LSD'] = lsd_mass
242
+
243
  st.table(df)
244
 
245