Update app.py
Browse files
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('
|
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,11 +72,11 @@ packet_size = CONFIG.DATA.EVAL.packet_size
|
|
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,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('
|
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('
|
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!')
|
|
|
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!')
|