XDHDD commited on
Commit
73bbc25
1 Parent(s): 3eeaf3e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -2
app.py CHANGED
@@ -93,6 +93,28 @@ def visualize(hr, lr, recon, sr):
93
  ax3.set_ylabel('Частота, Гц')
94
  return fig
95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  packet_size = CONFIG.DATA.EVAL.packet_size
97
  window = CONFIG.DATA.window_size
98
  stride = CONFIG.DATA.stride
@@ -147,8 +169,20 @@ if st.button('Сгенерировать потери'):
147
  output = inference(re_im, session, onnx_model, input_names, output_names)
148
  st.text(str(time.time() - start_time))
149
  st.subheader('3. Визуализация')
150
- fig = visualize(target, lossy_input, output, sr)
151
- st.pyplot(fig)
 
 
 
 
 
 
 
 
 
 
 
 
152
  st.success('Сделано!')
153
  sf.write('target.wav', target, sr)
154
  sf.write('lossy.wav', lossy_input, sr)
 
93
  ax3.set_ylabel('Частота, Гц')
94
  return fig
95
 
96
+
97
+
98
+ def waveplot(hr, lr, recon, sr):
99
+ fig, (ax1, ax2, ax3) = plt.subplots(3, 1, sharey=True, sharex=True, figsize=(16, 12))
100
+ ax1.title.set_text('Оригинальный сигнал')
101
+ ax2.title.set_text('Сигнал с потерями')
102
+ ax3.title.set_text('Улучшенный сигнал')
103
+
104
+ canvas = FigureCanvas(fig)
105
+ p = librosa.display.waveplot(hr, ax=ax1, sr=sr)
106
+ p = librosa.display.waveplot(lr, ax=ax2, sr=sr)
107
+ p = librosa.display.waveplot(recon, ax=ax3, sr=sr)
108
+
109
+ ax1.set_xlabel('Время, с')
110
+ #ax1.set_ylabel('Частота, Гц')
111
+ ax2.set_xlabel('Время, с')
112
+ #ax2.set_ylabel('Частота, Гц')
113
+ ax3.set_xlabel('Время, с')
114
+ #ax3.set_ylabel('Частота, Гц')
115
+ return fig
116
+
117
+
118
  packet_size = CONFIG.DATA.EVAL.packet_size
119
  window = CONFIG.DATA.window_size
120
  stride = CONFIG.DATA.stride
 
169
  output = inference(re_im, session, onnx_model, input_names, output_names)
170
  st.text(str(time.time() - start_time))
171
  st.subheader('3. Визуализация')
172
+ fig_1 = visualize(target, lossy_input, output, sr)
173
+ fig_2 = waveplot(target, lossy_input, output, sr)
174
+ tab1, tab2 = st.tabs(["Частотная", "Временная"])
175
+
176
+ with tab1:
177
+ st.header("Частотная область - Спектрограмма")
178
+ st.pyplot(fig_1)
179
+
180
+ with tab2:
181
+ st.header("Временная область - вейвплот")
182
+ st.pyplot(fig_2)
183
+
184
+
185
+ #st.pyplot(fig)
186
  st.success('Сделано!')
187
  sf.write('target.wav', target, sr)
188
  sf.write('lossy.wav', lossy_input, sr)