XDHDD commited on
Commit
69f6cc9
1 Parent(s): 56d123d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -58,9 +58,9 @@ def visualize(hr, lr, recon):
58
  stft_recon = 2 * np.abs(stft_recon) / np.sum(window)
59
 
60
  fig, (ax1, ax2, ax3) = plt.subplots(3, 1, sharey=True, sharex=True, figsize=(16, 10))
61
- ax1.title.set_text('Target signal')
62
- ax2.title.set_text('Lossy signal')
63
- ax3.title.set_text('Enhanced signal')
64
 
65
  canvas = FigureCanvas(fig)
66
  p = librosa.display.specshow(librosa.amplitude_to_db(stft_hr), ax=ax1, y_axis='linear', x_axis='time', sr=sr)
@@ -72,11 +72,11 @@ packet_size = CONFIG.DATA.EVAL.packet_size
72
  window = CONFIG.DATA.window_size
73
  stride = CONFIG.DATA.stride
74
 
75
- title = 'Packet Loss Concealment'
76
  st.set_page_config(page_title=title, page_icon=":sound:")
77
  st.title(title)
78
 
79
- st.subheader('Upload audio')
80
  uploaded_file = st.file_uploader("Upload your audio file (.wav) at 48 kHz sampling rate")
81
 
82
  is_file_uploaded = uploaded_file is not None
@@ -89,7 +89,7 @@ target = target[:packet_size * (len(target) // packet_size)]
89
  st.text('Audio sample')
90
  st.audio(uploaded_file)
91
 
92
- st.subheader('Choose expected packet loss rate')
93
  slider = [st.slider("Expected loss rate for Markov Chain loss generator", 0, 100, step=1)]
94
  loss_percent = float(slider[0])/100
95
  mask_gen = MaskGenerator(is_train=False, probs=[(1 - loss_percent, loss_percent)])
@@ -103,11 +103,11 @@ re_im = torch.stft(lossy_input_tensor, window, stride, window=hann, return_compl
103
  1).numpy().astype(np.float32)
104
  session, onnx_model, input_names, output_names = load_model()
105
 
106
- if st.button('Conceal lossy audio!'):
107
- with st.spinner('Please wait for completion'):
108
  output = inference(re_im, session, onnx_model, input_names, output_names)
109
 
110
- st.subheader('Visualization')
111
  fig = visualize(target, lossy_input, output)
112
  st.pyplot(fig)
113
  st.success('Done!')
 
58
  stft_recon = 2 * np.abs(stft_recon) / np.sum(window)
59
 
60
  fig, (ax1, ax2, ax3) = plt.subplots(3, 1, sharey=True, sharex=True, figsize=(16, 10))
61
+ ax1.title.set_text('Оригинальный сигнал')
62
+ ax2.title.set_text('Сигнал с потерями')
63
+ ax3.title.set_text('Улучшенный сигнал')
64
 
65
  canvas = FigureCanvas(fig)
66
  p = librosa.display.specshow(librosa.amplitude_to_db(stft_hr), ax=ax1, y_axis='linear', x_axis='time', sr=sr)
 
72
  window = CONFIG.DATA.window_size
73
  stride = CONFIG.DATA.stride
74
 
75
+ title = 'Сокрытие потерь пакетов'
76
  st.set_page_config(page_title=title, page_icon=":sound:")
77
  st.title(title)
78
 
79
+ st.subheader('Загрузить аудио')
80
  uploaded_file = st.file_uploader("Upload your audio file (.wav) at 48 kHz sampling rate")
81
 
82
  is_file_uploaded = uploaded_file is not None
 
89
  st.text('Audio sample')
90
  st.audio(uploaded_file)
91
 
92
+ st.subheader('Выберите желаемый процент потерь')
93
  slider = [st.slider("Expected loss rate for Markov Chain loss generator", 0, 100, step=1)]
94
  loss_percent = float(slider[0])/100
95
  mask_gen = MaskGenerator(is_train=False, probs=[(1 - loss_percent, loss_percent)])
 
103
  1).numpy().astype(np.float32)
104
  session, onnx_model, input_names, output_names = load_model()
105
 
106
+ if st.button('Улучшить'):
107
+ with st.spinner('Ожидайте...'):
108
  output = inference(re_im, session, onnx_model, input_names, output_names)
109
 
110
+ st.subheader('Визуализация')
111
  fig = visualize(target, lossy_input, output)
112
  st.pyplot(fig)
113
  st.success('Done!')