Zw07 commited on
Commit
c95c8e4
·
verified ·
1 Parent(s): 3fb9d11

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -26
app.py CHANGED
@@ -212,33 +212,18 @@ def main():
212
 
213
  # Run on an unwatermarked audio
214
 
215
- audio_file = st.file_uploader("Upload Audio", type=["wav", "mp3"], accept_multiple_files=False)
216
-
217
- if audio_file:
218
- tmp_input_audio_file = os.path.join("/tmp/", audio_file.name)
219
- file_extension = os.path.splitext(tmp_input_audio_file)[1].lower()
220
- if file_extension in [".wav", ".flac"]:
221
- with open("test.wav", "wb") as f:
222
- f.write(audio_file.getbuffer())
223
-
224
- elif file_extension == ".mp3":
225
- with open("test.mp3", "wb") as f:
226
- f.write(audio_file.getbuffer())
227
-
228
- #Load the WAV file using torchaudio
229
- if file_extension in [".wav", ".flac"]:
230
- wav, sample_rate = torchaudio.load("test.wav")
231
-
232
- elif file_extension == ".mp3":
233
- # Load an MP3 file
234
- audio = AudioSegment.from_mp3("test.mp3")
235
-
236
- # Export it as a WAV file
237
- audio.export("test.wav", format="wav")
238
- wav3, sample_rate = torchaudio.load("test.wav")
239
- wav3= wav3.unsqueeze(0)
240
 
241
- result2, message2 = detector.detect_watermark(wav3, sample_rate=default_sr, message_threshold=0.5)
242
  st.markdown("This is likely an unwatermarked audio:")
243
  print(f"This is likely an unwatermarked audio: {result2}")
244
  st.markdown(result2)
 
212
 
213
  # Run on an unwatermarked audio
214
 
215
+ if file_extension in [".wav", ".flac"]:
216
+ wav, sample_rate = torchaudio.load("test.wav")
217
+
218
+ elif file_extension == ".mp3":
219
+ # Load an MP3 file
220
+ audio = AudioSegment.from_mp3("test.mp3")
221
+ # Export it as a WAV file
222
+ audio.export("test.wav", format="wav")
223
+ wav, sample_rate = torchaudio.load("test.wav")
224
+ wav= wav.unsqueeze(0)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
 
226
+ result2, message2 = detector.detect_watermark(wav, sample_rate=default_sr, message_threshold=0.5)
227
  st.markdown("This is likely an unwatermarked audio:")
228
  print(f"This is likely an unwatermarked audio: {result2}")
229
  st.markdown(result2)