Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,40 +1,33 @@
|
|
1 |
import numpy as np
|
2 |
-
import
|
3 |
-
import
|
|
|
4 |
import gradio as gr
|
5 |
|
6 |
-
def
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
"""
|
11 |
-
# In a real implementation, you'd process the audio to extract an image.
|
12 |
-
# Here, we just return a blank image for demonstration purposes.
|
13 |
-
image = np.zeros((256, 320, 3), dtype=np.uint8)
|
14 |
-
return image
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
sample_rate
|
19 |
-
|
20 |
-
# Decode the SSTV signal (Dummy Function)
|
21 |
-
image = dummy_sstv_decode(audio_data, sample_rate)
|
22 |
|
23 |
-
#
|
24 |
-
plt.imshow(
|
25 |
plt.axis('off')
|
26 |
-
|
|
|
|
|
27 |
|
28 |
-
return image
|
29 |
-
|
30 |
-
# Set up Gradio interface
|
31 |
iface = gr.Interface(
|
32 |
-
fn=
|
33 |
-
inputs=gr.Audio(
|
34 |
-
outputs="
|
35 |
title="SSTV Decoder",
|
36 |
-
description="Upload an audio file
|
37 |
)
|
38 |
|
39 |
-
|
40 |
-
iface.launch()
|
|
|
1 |
import numpy as np
|
2 |
+
from pydub import AudioSegment
|
3 |
+
from matplotlib import pyplot as plt
|
4 |
+
from pysstv.color import Robot36
|
5 |
import gradio as gr
|
6 |
|
7 |
+
def decode_sstv(audio_file):
|
8 |
+
# Чтение аудиофайла
|
9 |
+
audio = AudioSegment.from_file(audio_file)
|
10 |
+
samples = np.array(audio.get_array_of_samples(), dtype=np.int16)
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
# Декодирование SSTV сигнала, установка sample_rate после создания объек
|
13 |
+
sstv = Robot36(samples)
|
14 |
+
sstv.sample_rate = audio.frame_rate
|
15 |
+
img = sstv.decode()
|
|
|
|
|
16 |
|
17 |
+
# Отображение изображения
|
18 |
+
plt.imshow(img)
|
19 |
plt.axis('off')
|
20 |
+
img_path = 'decoded_image.png'
|
21 |
+
plt.savefig(img_path, bbox_inches='tight', pad_inches=0)
|
22 |
+
return img_path
|
23 |
|
|
|
|
|
|
|
24 |
iface = gr.Interface(
|
25 |
+
fn=decode_sstv,
|
26 |
+
inputs=gr.Audio(type="filepath", label="Upload SSTV Audio File"),
|
27 |
+
outputs=gr.Image(label="Decoded Image"),
|
28 |
title="SSTV Decoder",
|
29 |
+
description="Upload an SSTV audio file to decode the image."
|
30 |
)
|
31 |
|
32 |
+
if __name__ == "__main__":
|
33 |
+
iface.launch()
|