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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -45
app.py CHANGED
@@ -137,77 +137,77 @@ if st.button('Сгенерировать потери'):
137
 
138
 
139
 
140
- data_clean, samplerate = torchaudio.load('target.wav')
141
- data_lossy, samplerate = torchaudio.load('lossy.wav')
142
- data_enhanced, samplerate = torchaudio.load('enhanced.wav')
143
 
144
- min_len = min(data_clean.shape[1], data_lossy.shape[1], data_enhanced.shape[1])
145
- data_clean = data_clean[:, :min_len]
146
- data_lossy = data_lossy[:, :min_len]
147
- data_enhanced = data_enhanced[:, :min_len]
148
 
149
 
150
- stoi = STOI(samplerate)
151
 
152
- stoi_orig = round(float(stoi(data_clean, data_clean)),3)
153
- stoi_lossy = round(float(stoi(data_clean, data_lossy)),5)
154
- stoi_enhanced = round(float(stoi(data_clean, data_enhanced)),5)
155
 
156
- stoi_mass=[stoi_orig, stoi_lossy, stoi_enhanced]
157
 
158
 
159
- pesq = PESQ(8000, 'nb')
160
 
161
- data_clean = data_clean.cpu().numpy()
162
- data_lossy = data_lossy.cpu().numpy()
163
- data_enhanced = data_enhanced.cpu().numpy()
164
 
165
- if samplerate != 8000:
166
- data_lossy = librosa.resample(data_lossy, orig_sr=48000, target_sr=8000)
167
- data_clean = librosa.resample(data_clean, orig_sr=48000, target_sr=8000)
168
- data_enhanced = librosa.resample(data_enhanced, orig_sr=48000, target_sr=8000)
169
 
170
- pesq_orig = float(pesq(torch.tensor(data_clean), torch.tensor(data_clean)))
171
- pesq_lossy = float(pesq(torch.tensor(data_lossy), torch.tensor(data_clean)))
172
- pesq_enhanced = float(pesq(torch.tensor(data_enhanced), torch.tensor(data_clean)))
173
 
174
- psq_mas=[pesq_orig, pesq_lossy, pesq_enhanced]
175
 
176
 
177
 
178
 
179
 
180
  #_____________________________________________
181
- #data_clean, samplerate = sf.read('target.wav')
182
- #data_lossy, samplerate = sf.read('lossy.wav')
183
- #data_enhanced, samplerate = sf.read('enhanced.wav')
184
- #min_len = min(data_clean.shape[0], data_lossy.shape[0], data_enhanced.shape[0])
185
- #data_clean = data_clean[:min_len]
186
- #data_lossy = data_lossy[:min_len]
187
- #data_enhanced = data_enhanced[:min_len]
188
-
189
-
190
- #stoi_orig = round(stoi(data_clean, data_clean, samplerate, extended=False),5)
191
- #stoi_lossy = round(stoi(data_clean, data_lossy , samplerate, extended=False),5)
192
- #stoi_enhanced = round(stoi(data_clean, data_enhanced, samplerate, extended=False),5)
193
 
194
- #stoi_mass=[stoi_orig, stoi_lossy, stoi_enhanced]
195
 
196
 
197
 
198
 
199
- #if samplerate != 16000:
200
- #data_lossy = librosa.resample(data_lossy, orig_sr=48000, target_sr=16000)
201
- #data_clean = librosa.resample(data_clean, orig_sr=48000, target_sr=16000)
202
- #data_enhanced = librosa.resample(data_enhanced, orig_sr=48000, target_sr=16000)
203
 
204
 
205
 
206
- #pesq_orig = pesq(fs = 16000, ref = data_clean, deg = data_clean, mode='nb')
207
- #pesq_lossy = pesq(fs = 16000, ref = data_clean, deg = data_lossy, mode='nb')
208
- #pesq_enhanced = pesq(fs = 16000, ref = data_clean, deg = data_enhanced, mode='nb')
209
 
210
- #psq_mas=[pesq_orig, pesq_lossy, pesq_enhanced]
211
 
212
 
213
 
 
137
 
138
 
139
 
140
+ #data_clean, samplerate = torchaudio.load('target.wav')
141
+ #data_lossy, samplerate = torchaudio.load('lossy.wav')
142
+ #data_enhanced, samplerate = torchaudio.load('enhanced.wav')
143
 
144
+ #min_len = min(data_clean.shape[1], data_lossy.shape[1], data_enhanced.shape[1])
145
+ #data_clean = data_clean[:, :min_len]
146
+ #data_lossy = data_lossy[:, :min_len]
147
+ #data_enhanced = data_enhanced[:, :min_len]
148
 
149
 
150
+ #stoi = STOI(samplerate)
151
 
152
+ #stoi_orig = round(float(stoi(data_clean, data_clean)),3)
153
+ #stoi_lossy = round(float(stoi(data_clean, data_lossy)),5)
154
+ #stoi_enhanced = round(float(stoi(data_clean, data_enhanced)),5)
155
 
156
+ #stoi_mass=[stoi_orig, stoi_lossy, stoi_enhanced]
157
 
158
 
159
+ #pesq = PESQ(8000, 'nb')
160
 
161
+ #data_clean = data_clean.cpu().numpy()
162
+ #data_lossy = data_lossy.cpu().numpy()
163
+ #data_enhanced = data_enhanced.cpu().numpy()
164
 
165
+ #if samplerate != 8000:
166
+ #data_lossy = librosa.resample(data_lossy, orig_sr=48000, target_sr=8000)
167
+ #data_clean = librosa.resample(data_clean, orig_sr=48000, target_sr=8000)
168
+ #data_enhanced = librosa.resample(data_enhanced, orig_sr=48000, target_sr=8000)
169
 
170
+ #pesq_orig = float(pesq(torch.tensor(data_clean), torch.tensor(data_clean)))
171
+ #pesq_lossy = float(pesq(torch.tensor(data_lossy), torch.tensor(data_clean)))
172
+ #pesq_enhanced = float(pesq(torch.tensor(data_enhanced), torch.tensor(data_clean)))
173
 
174
+ #psq_mas=[pesq_orig, pesq_lossy, pesq_enhanced]
175
 
176
 
177
 
178
 
179
 
180
  #_____________________________________________
181
+ data_clean, samplerate = sf.read('target.wav')
182
+ data_lossy, samplerate = sf.read('lossy.wav')
183
+ data_enhanced, samplerate = sf.read('enhanced.wav')
184
+ min_len = min(data_clean.shape[0], data_lossy.shape[0], data_enhanced.shape[0])
185
+ data_clean = data_clean[:min_len]
186
+ data_lossy = data_lossy[:min_len]
187
+ data_enhanced = data_enhanced[:min_len]
188
+
189
+
190
+ stoi_orig = round(stoi(data_clean, data_clean, samplerate, extended=False),5)
191
+ stoi_lossy = round(stoi(data_clean, data_lossy , samplerate, extended=False),5)
192
+ stoi_enhanced = round(stoi(data_clean, data_enhanced, samplerate, extended=False),5)
193
 
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)
202
+ data_enhanced = librosa.resample(data_enhanced, orig_sr=48000, target_sr=8000)
203
 
204
 
205
 
206
+ pesq_orig = pesq(fs = 8000, ref = data_clean, deg = data_clean, mode='nb')
207
+ pesq_lossy = pesq(fs = 8000, ref = data_clean, deg = data_lossy, mode='nb')
208
+ pesq_enhanced = pesq(fs = 8000, ref = data_clean, deg = data_enhanced, mode='nb')
209
 
210
+ psq_mas=[pesq_orig, pesq_lossy, pesq_enhanced]
211
 
212
 
213