Update app.py
Browse files
app.py
CHANGED
@@ -76,8 +76,8 @@ 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("
|
81 |
|
82 |
is_file_uploaded = uploaded_file is not None
|
83 |
if not is_file_uploaded:
|
@@ -86,11 +86,11 @@ if not is_file_uploaded:
|
|
86 |
target, sr = librosa.load(uploaded_file, sr=48000)
|
87 |
target = target[:packet_size * (len(target) // packet_size)]
|
88 |
|
89 |
-
st.text('
|
90 |
st.audio(uploaded_file)
|
91 |
|
92 |
st.subheader('Выберите желаемый процент потерь')
|
93 |
-
slider = [st.slider("
|
94 |
loss_percent = float(slider[0])/100
|
95 |
mask_gen = MaskGenerator(is_train=False, probs=[(1 - loss_percent, loss_percent)])
|
96 |
lossy_input = target.copy().reshape(-1, packet_size)
|
@@ -103,20 +103,20 @@ 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('
|
114 |
sf.write('target.wav', target, sr)
|
115 |
sf.write('lossy.wav', lossy_input, sr)
|
116 |
sf.write('enhanced.wav', output, sr)
|
117 |
-
st.text('
|
118 |
st.audio('target.wav')
|
119 |
-
st.text('
|
120 |
st.audio('lossy.wav')
|
121 |
-
st.text('
|
122 |
st.audio('enhanced.wav')
|
|
|
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("Загрузите аудио формата (.wav) 48 КГц")
|
81 |
|
82 |
is_file_uploaded = uploaded_file is not None
|
83 |
if not is_file_uploaded:
|
|
|
86 |
target, sr = librosa.load(uploaded_file, sr=48000)
|
87 |
target = target[:packet_size * (len(target) // packet_size)]
|
88 |
|
89 |
+
st.text('Ваше аудио')
|
90 |
st.audio(uploaded_file)
|
91 |
|
92 |
st.subheader('Выберите желаемый процент потерь')
|
93 |
+
slider = [st.slider("Ожидаемый процент потерь для генератора потерь цепи Маркова", 0, 100, step=1)]
|
94 |
loss_percent = float(slider[0])/100
|
95 |
mask_gen = MaskGenerator(is_train=False, probs=[(1 - loss_percent, loss_percent)])
|
96 |
lossy_input = target.copy().reshape(-1, packet_size)
|
|
|
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('Сделано!')
|
114 |
sf.write('target.wav', target, sr)
|
115 |
sf.write('lossy.wav', lossy_input, sr)
|
116 |
sf.write('enhanced.wav', output, sr)
|
117 |
+
st.text('Оригинальное аудио')
|
118 |
st.audio('target.wav')
|
119 |
+
st.text('Аудио с потерями')
|
120 |
st.audio('lossy.wav')
|
121 |
+
st.text('Улучшенное аудио')
|
122 |
st.audio('enhanced.wav')
|