XDHDD commited on
Commit
dbe7113
1 Parent(s): 0e7d3e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -10
app.py CHANGED
@@ -21,6 +21,8 @@ from torchmetrics.audio.pesq import PerceptualEvaluationSpeechQuality as PESQ
21
 
22
 
23
  from PLCMOS.plc_mos import PLCMOSEstimator
 
 
24
 
25
 
26
  @st.cache
@@ -226,29 +228,33 @@ if st.button('Сгенерировать потери'):
226
 
227
 
228
 
229
- pesq_orig = pesq(fs = 16000, ref = data_clean, deg = data_clean, mode='wb')
230
- pesq_lossy = pesq(fs = 16000, ref = data_clean, deg = data_lossy, mode='wb')
231
- pesq_enhanced = pesq(fs = 16000, ref = data_clean, deg = data_enhanced, mode='wb')
232
 
233
  psq_mas=[pesq_orig, pesq_lossy, pesq_enhanced]
234
 
235
 
236
 
 
 
 
237
 
238
-
239
-
240
-
 
241
 
242
  PLC_example=PLCMOSEstimator()
243
  PLC_org = PLC_example.run(audio_degraded=data_clean, audio_clean=data_clean)[0]
244
  PLC_lossy = PLC_example.run(audio_degraded=data_lossy, audio_clean=data_clean)[0]
245
  PLC_enhanced = PLC_example.run(audio_degraded=data_enhanced, audio_clean=data_clean)[0]
246
 
247
- PLC_mass = [PLC_org, PLC_lossy, PLC_enhanced]
248
 
249
 
250
 
251
- df = pd.DataFrame(columns=['Audio', 'PESQ', 'STOI', 'PLCMOS', 'LSD'])
252
 
253
  df['Audio'] = ['Clean', 'Lossy', 'Enhanced']
254
 
@@ -256,10 +262,18 @@ if st.button('Сгенерировать потери'):
256
 
257
  df['STOI'] = stoi_mass
258
 
259
- df['LSD'] = lsd_mass
260
 
261
- df['PLCMOS'] = PLC_mass
262
 
 
 
 
 
 
 
 
 
263
  st.table(df)
264
 
265
 
 
21
 
22
 
23
  from PLCMOS.plc_mos import PLCMOSEstimator
24
+ from speechmos import dnsmos
25
+ from speechmos import plcmos
26
 
27
 
28
  @st.cache
 
228
 
229
 
230
 
231
+ pesq_orig = pesq(fs = 8000, ref = data_clean, deg = data_clean, mode='nb')
232
+ pesq_lossy = pesq(fs = 8000, ref = data_clean, deg = data_lossy, mode='nb')
233
+ pesq_enhanced = pesq(fs = 8000, ref = data_clean, deg = data_enhanced, mode='nb')
234
 
235
  psq_mas=[pesq_orig, pesq_lossy, pesq_enhanced]
236
 
237
 
238
 
239
+ data_clean, fs = sf.read('target.wav')
240
+ data_lossy, fs = sf.read('lossy.wav')
241
+ data_enhanced, fs = sf.read('enhanced.wav')
242
 
243
+ if fs!= 16000:
244
+ data_lossy = librosa.resample(data_lossy, orig_sr=48000, target_sr=16000)
245
+ data_clean = librosa.resample(data_clean, orig_sr=48000, target_sr=16000)
246
+ data_enhanced = librosa.resample(data_enhanced, orig_sr=48000, target_sr=16000)
247
 
248
  PLC_example=PLCMOSEstimator()
249
  PLC_org = PLC_example.run(audio_degraded=data_clean, audio_clean=data_clean)[0]
250
  PLC_lossy = PLC_example.run(audio_degraded=data_lossy, audio_clean=data_clean)[0]
251
  PLC_enhanced = PLC_example.run(audio_degraded=data_enhanced, audio_clean=data_clean)[0]
252
 
253
+ PLC_massv1 = [PLC_org, PLC_lossy, PLC_enhanced]
254
 
255
 
256
 
257
+ df = pd.DataFrame(columns=['Audio', 'PESQ', 'STOI', 'PLCMOSv1', 'DNSMOS', 'PLCMOSv2'])
258
 
259
  df['Audio'] = ['Clean', 'Lossy', 'Enhanced']
260
 
 
262
 
263
  df['STOI'] = stoi_mass
264
 
265
+ #df['LSD'] = lsd_mass
266
 
267
+ df['PLCMOSv1'] = PLC_massv1
268
 
269
+
270
+ PLC_massvV2 = [plcmos.run("target.wav", sr=16000)['plcmos'], plcmos.run("lossy.wav", sr=16000)['plcmos'], plcmos.run("enhanced.wav", sr=16000)['plcmos']]
271
+
272
+ df['PLCMOSv2'] = PLC_massv2
273
+
274
+ df.columns = pd.MultiIndex.from_tuples(zip(['', 'Intrusive metrics', '', '', 'Non intrusive metrics', ''], df.columns))
275
+
276
+
277
  st.table(df)
278
 
279