Spaces:
Sleeping
Sleeping
Update steganography.py
Browse files- steganography.py +36 -39
steganography.py
CHANGED
@@ -6,6 +6,13 @@ import librosa.display
|
|
6 |
import gradio as gr
|
7 |
import soundfile as sf
|
8 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
# Function for creating a spectrogram image with text
|
11 |
def text_to_spectrogram_image(text, base_width=512, height=256, max_font_size=80, margin=10, letter_spacing=5):
|
@@ -83,11 +90,7 @@ def image_to_spectrogram_audio(image_path, sr=22050):
|
|
83 |
sf.write(img2audio_path, y, sr)
|
84 |
return img2audio_path
|
85 |
|
86 |
-
|
87 |
-
|
88 |
-
informstion = """
|
89 |
-
|
90 |
-
|
91 |
<!DOCTYPE html>
|
92 |
<html lang="en">
|
93 |
<head>
|
@@ -115,50 +118,44 @@ informstion = """
|
|
115 |
|
116 |
</body>
|
117 |
</html>
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
"""
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
|
126 |
# Gradio interface
|
127 |
with gr.Blocks(
|
128 |
-
title='Audio Steganography',
|
129 |
theme="Hev832/Applio",
|
130 |
) as iface:
|
131 |
-
gr.Markdown("# Audio Steganography")
|
132 |
|
133 |
with gr.Group():
|
134 |
with gr.Row(variant='panel'):
|
135 |
with gr.Column():
|
136 |
-
gr.HTML("<center><h2><a href='https://t.me/pol1trees'>Telegram Channel</a></h2></center>")
|
137 |
with gr.Column():
|
138 |
-
gr.HTML("<center><h2><a href='https://t.me/+GMTP7hZqY0E4OGRi'>Telegram Chat</a></h2></center>")
|
139 |
with gr.Column():
|
140 |
-
gr.HTML("<center><h2><a href='https://www.youtube.com/channel/UCHb3fZEVxUisnqLqCrEM8ZA'>YouTube</a></h2></center>")
|
141 |
with gr.Column():
|
142 |
-
gr.HTML("<center><h2><a href='https://github.com/Bebra777228/Audio-Steganography'>GitHub</a></h2></center>")
|
143 |
|
144 |
-
with gr.Tab("INFO"):
|
145 |
gr.HTML(informstion)
|
146 |
-
with gr.Tab("Text to Spectrogram"):
|
147 |
-
gr.HTML("<center><h2>Oh my god people, learn to read. Go to the “INFO” tab, it says what this interface is and what it is for, don't be idiots.</h2></center>")
|
148 |
with gr.Group():
|
149 |
-
text = gr.Textbox(lines=2, placeholder="Enter your text:", label="Text")
|
150 |
with gr.Row(variant='panel'):
|
151 |
-
base_width = gr.Slider(value=512, label="Image Width", visible=False)
|
152 |
-
height = gr.Slider(value=256, label="Image Height", visible=False)
|
153 |
-
max_font_size = gr.Slider(minimum=10, maximum=130, step=5, value=80, label="Font size")
|
154 |
-
margin = gr.Slider(minimum=0, maximum=50, step=1, value=10, label="Indent")
|
155 |
-
letter_spacing = gr.Slider(minimum=0, maximum=50, step=1, value=5, label="Letter spacing")
|
156 |
-
generate_button = gr.Button("Generate")
|
157 |
|
158 |
with gr.Column(variant='panel'):
|
159 |
with gr.Group():
|
160 |
-
output_audio = gr.Audio(type="filepath", label="Generated audio")
|
161 |
-
output_image = gr.Image(type="filepath", label="Spectrogram")
|
162 |
|
163 |
def gradio_interface_fn(text, base_width, height, max_font_size, margin, letter_spacing):
|
164 |
print("\n", text)
|
@@ -170,15 +167,15 @@ with gr.Blocks(
|
|
170 |
outputs=[output_audio, output_image]
|
171 |
)
|
172 |
|
173 |
-
with gr.Tab("Image to Spectrogram"):
|
174 |
-
gr.HTML("<center><h2>Oh my god people, learn to read. Go to the “INFO” tab, it says what this interface is and what it is for, don't be idiots.</h2></center>")
|
175 |
with gr.Group():
|
176 |
with gr.Row(variant='panel'):
|
177 |
-
upload_image = gr.Image(type="filepath", label="Upload image")
|
178 |
-
convert_button = gr.Button("Convert to audio")
|
179 |
|
180 |
with gr.Column(variant='panel'):
|
181 |
-
output_audio_from_image = gr.Audio(type="filepath", label="Generated audio")
|
182 |
|
183 |
def gradio_image_to_audio_fn(upload_image):
|
184 |
return image_to_spectrogram_audio(upload_image)
|
@@ -189,14 +186,14 @@ with gr.Blocks(
|
|
189 |
outputs=[output_audio_from_image]
|
190 |
)
|
191 |
|
192 |
-
with gr.Tab("Audio Spectrogram"):
|
193 |
with gr.Group():
|
194 |
with gr.Row(variant='panel'):
|
195 |
-
upload_audio = gr.Audio(type="filepath", label="Upload audio", scale=3)
|
196 |
-
decode_button = gr.Button("Show spectrogram", scale=2)
|
197 |
|
198 |
with gr.Column(variant='panel'):
|
199 |
-
decoded_image = gr.Image(type="filepath", label="Audio Spectrogram")
|
200 |
|
201 |
def gradio_decode_fn(upload_audio):
|
202 |
return display_audio_spectrogram(upload_audio)
|
|
|
6 |
import gradio as gr
|
7 |
import soundfile as sf
|
8 |
import os
|
9 |
+
import gettext
|
10 |
+
|
11 |
+
# Set up message catalog access
|
12 |
+
locales_dir = 'locales'
|
13 |
+
lang = gettext.translation('base', localedir=locales_dir, languages=['en'])
|
14 |
+
lang.install()
|
15 |
+
_ = lang.gettext
|
16 |
|
17 |
# Function for creating a spectrogram image with text
|
18 |
def text_to_spectrogram_image(text, base_width=512, height=256, max_font_size=80, margin=10, letter_spacing=5):
|
|
|
90 |
sf.write(img2audio_path, y, sr)
|
91 |
return img2audio_path
|
92 |
|
93 |
+
informstion = _("""
|
|
|
|
|
|
|
|
|
94 |
<!DOCTYPE html>
|
95 |
<html lang="en">
|
96 |
<head>
|
|
|
118 |
|
119 |
</body>
|
120 |
</html>
|
121 |
+
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
|
123 |
# Gradio interface
|
124 |
with gr.Blocks(
|
125 |
+
title=_('Audio Steganography'),
|
126 |
theme="Hev832/Applio",
|
127 |
) as iface:
|
128 |
+
gr.Markdown(_("# Audio Steganography"))
|
129 |
|
130 |
with gr.Group():
|
131 |
with gr.Row(variant='panel'):
|
132 |
with gr.Column():
|
133 |
+
gr.HTML(_("<center><h2><a href='https://t.me/pol1trees'>Telegram Channel</a></h2></center>"))
|
134 |
with gr.Column():
|
135 |
+
gr.HTML(_("<center><h2><a href='https://t.me/+GMTP7hZqY0E4OGRi'>Telegram Chat</a></h2></center>"))
|
136 |
with gr.Column():
|
137 |
+
gr.HTML(_("<center><h2><a href='https://www.youtube.com/channel/UCHb3fZEVxUisnqLqCrEM8ZA'>YouTube</a></h2></center>"))
|
138 |
with gr.Column():
|
139 |
+
gr.HTML(_("<center><h2><a href='https://github.com/Bebra777228/Audio-Steganography'>GitHub</a></h2></center>"))
|
140 |
|
141 |
+
with gr.Tab(_("INFO")):
|
142 |
gr.HTML(informstion)
|
143 |
+
with gr.Tab(_("Text to Spectrogram")):
|
144 |
+
gr.HTML(_("<center><h2>Oh my god people, learn to read. Go to the “INFO” tab, it says what this interface is and what it is for, don't be idiots.</h2></center>"))
|
145 |
with gr.Group():
|
146 |
+
text = gr.Textbox(lines=2, placeholder=_("Enter your text:"), label=_("Text"))
|
147 |
with gr.Row(variant='panel'):
|
148 |
+
base_width = gr.Slider(value=512, label=_("Image Width"), visible=False)
|
149 |
+
height = gr.Slider(value=256, label=_("Image Height"), visible=False)
|
150 |
+
max_font_size = gr.Slider(minimum=10, maximum=130, step=5, value=80, label=_("Font size"))
|
151 |
+
margin = gr.Slider(minimum=0, maximum=50, step=1, value=10, label=_("Indent"))
|
152 |
+
letter_spacing = gr.Slider(minimum=0, maximum=50, step=1, value=5, label=_("Letter spacing"))
|
153 |
+
generate_button = gr.Button(_("Generate"))
|
154 |
|
155 |
with gr.Column(variant='panel'):
|
156 |
with gr.Group():
|
157 |
+
output_audio = gr.Audio(type="filepath", label=_("Generated audio"))
|
158 |
+
output_image = gr.Image(type="filepath", label=_("Spectrogram"))
|
159 |
|
160 |
def gradio_interface_fn(text, base_width, height, max_font_size, margin, letter_spacing):
|
161 |
print("\n", text)
|
|
|
167 |
outputs=[output_audio, output_image]
|
168 |
)
|
169 |
|
170 |
+
with gr.Tab(_("Image to Spectrogram")):
|
171 |
+
gr.HTML(_("<center><h2>Oh my god people, learn to read. Go to the “INFO” tab, it says what this interface is and what it is for, don't be idiots.</h2></center>"))
|
172 |
with gr.Group():
|
173 |
with gr.Row(variant='panel'):
|
174 |
+
upload_image = gr.Image(type="filepath", label=_("Upload image"))
|
175 |
+
convert_button = gr.Button(_("Convert to audio"))
|
176 |
|
177 |
with gr.Column(variant='panel'):
|
178 |
+
output_audio_from_image = gr.Audio(type="filepath", label=_("Generated audio"))
|
179 |
|
180 |
def gradio_image_to_audio_fn(upload_image):
|
181 |
return image_to_spectrogram_audio(upload_image)
|
|
|
186 |
outputs=[output_audio_from_image]
|
187 |
)
|
188 |
|
189 |
+
with gr.Tab(_("Audio Spectrogram")):
|
190 |
with gr.Group():
|
191 |
with gr.Row(variant='panel'):
|
192 |
+
upload_audio = gr.Audio(type="filepath", label=_("Upload audio"), scale=3)
|
193 |
+
decode_button = gr.Button(_("Show spectrogram"), scale=2)
|
194 |
|
195 |
with gr.Column(variant='panel'):
|
196 |
+
decoded_image = gr.Image(type="filepath", label=_("Audio Spectrogram"))
|
197 |
|
198 |
def gradio_decode_fn(upload_audio):
|
199 |
return display_audio_spectrogram(upload_audio)
|