xiaoyao9184 commited on
Commit
c4d43a6
·
verified ·
1 Parent(s): f307f20

Synced repo using 'sync_with_huggingface' Github Action

Browse files
Files changed (2) hide show
  1. gradio_app.py +30 -4
  2. requirements.txt +7 -4
gradio_app.py CHANGED
@@ -144,7 +144,7 @@ def generate_hex_random_message(bytes_count):
144
  with gr.Blocks(title="AudioSeal") as demo:
145
  gr.Markdown("""
146
  # AudioSeal Demo
147
-
148
  Find the project [here](https://github.com/facebookresearch/audioseal.git).
149
  """)
150
 
@@ -181,7 +181,8 @@ with gr.Blocks(title="AudioSeal") as demo:
181
  embedding_type.change(
182
  fn=change_embedding_type,
183
  inputs=[embedding_type],
184
- outputs=[embedding_msg]
 
185
  )
186
 
187
  def check_embedding_msg(msg):
@@ -192,10 +193,26 @@ with gr.Blocks(title="AudioSeal") as demo:
192
  embedding_msg.change(
193
  fn=check_embedding_msg,
194
  inputs=[embedding_msg],
195
- outputs=[]
 
196
  )
197
 
198
  def run_embed_watermark(file, show_specgram, type, msg):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  if file is None:
200
  raise gr.Erro("No file uploaded", duration=5)
201
  if not re.match(regex_pattern, msg):
@@ -234,6 +251,15 @@ with gr.Blocks(title="AudioSeal") as demo:
234
  predicted_messages = gr.JSON(label="Detected Messages")
235
 
236
  def run_detect_watermark(file):
 
 
 
 
 
 
 
 
 
237
  if file is None:
238
  raise gr.Error("No file uploaded", duration=5)
239
 
@@ -261,4 +287,4 @@ with gr.Blocks(title="AudioSeal") as demo:
261
  )
262
 
263
  if __name__ == "__main__":
264
- demo.launch()
 
144
  with gr.Blocks(title="AudioSeal") as demo:
145
  gr.Markdown("""
146
  # AudioSeal Demo
147
+ ![](https://badge.mcpx.dev?type=server 'MCP Server')
148
  Find the project [here](https://github.com/facebookresearch/audioseal.git).
149
  """)
150
 
 
181
  embedding_type.change(
182
  fn=change_embedding_type,
183
  inputs=[embedding_type],
184
+ outputs=[embedding_msg],
185
+ api_name=False
186
  )
187
 
188
  def check_embedding_msg(msg):
 
193
  embedding_msg.change(
194
  fn=check_embedding_msg,
195
  inputs=[embedding_msg],
196
+ outputs=[],
197
+ api_name=False
198
  )
199
 
200
  def run_embed_watermark(file, show_specgram, type, msg):
201
+ """
202
+ Embeds a watermark into the given audio file and optionally shows spectrograms.
203
+
204
+ Args:
205
+ file (str): The input file, either a file path.
206
+ show_specgram (bool): Whether to return spectrograms for debugging.
207
+ type (str): The type of watermark to embed. Accepts "random" or "input".
208
+ msg (str): A 2-byte hex string message to embed, e.g., "FFFF".
209
+
210
+ Returns:
211
+ tuple:
212
+ - filepath: An audio file representing the output with embedded watermark.
213
+ - dict: A spectrogram image of the original signal (if show_specgram is True).
214
+ - dict: A spectrogram image of the watermark signal (if show_specgram is True).
215
+ """
216
  if file is None:
217
  raise gr.Erro("No file uploaded", duration=5)
218
  if not re.match(regex_pattern, msg):
 
251
  predicted_messages = gr.JSON(label="Detected Messages")
252
 
253
  def run_detect_watermark(file):
254
+ """
255
+ Detects a watermark in the given audio file.
256
+
257
+ Args:
258
+ file (str): Path to the input audio file.
259
+
260
+ Returns:
261
+ str: A Markdown-formatted string containing detection information.
262
+ """
263
  if file is None:
264
  raise gr.Error("No file uploaded", duration=5)
265
 
 
287
  )
288
 
289
  if __name__ == "__main__":
290
+ demo.launch(server_name="0.0.0.0", server_port=7860, mcp_server=True, ssr_mode=False)
requirements.txt CHANGED
@@ -1,7 +1,10 @@
1
  torch==2.5.1
2
- gradio==5.8.0
3
- huggingface-hub==0.26.3
4
- audioseal==0.1.4
5
  matplotlib==3.10.0
6
  soundfile==0.12.1
7
- torchaudio==2.5.1
 
 
 
 
1
  torch==2.5.1
2
+ gradio[mcp]==5.28.0
3
+ huggingface-hub==0.28.1
4
+ audioseal==0.1.7
5
  matplotlib==3.10.0
6
  soundfile==0.12.1
7
+ torchaudio==2.5.1
8
+
9
+ # gradio[mcp] 5.28.0 depends on pydantic>=2.11
10
+ pydantic==2.11.4