Zw07 commited on
Commit
d4253a5
·
verified ·
1 Parent(s): 5b1f262

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -13
app.py CHANGED
@@ -170,8 +170,10 @@ def main():
170
  file_name="output.mp3",
171
  mime="audio/mpeg",
172
  )
173
- if detect_watermark_button:
174
- with st.spinner("Detecting..."):
 
 
175
  # result, message = detector.detect_watermark(watermarked_audio, sample_rate=default_sr, message_threshold=0.5)
176
  # st.markdown("Probability of audio being watermarked: ")
177
  # st.markdown(result)
@@ -180,17 +182,17 @@ def main():
180
 
181
  #Run on an unwatermarked audio
182
 
183
- if file_extension in [".wav", ".flac"]:
184
- wav, sample_rate = torchaudio.load("test.wav")
185
- wav= wav.unsqueeze(0)
186
-
187
- elif file_extension == ".mp3":
188
- # Load an MP3 file
189
- audio = AudioSegment.from_mp3("test.mp3")
190
- # Export it as a WAV file
191
- audio.export("test.wav", format="wav")
192
- wav, sample_rate = torchaudio.load("test.wav")
193
- wav= wav.unsqueeze(0)
194
 
195
  result2, message2 = detector.detect_watermark(wav, sample_rate=default_sr, message_threshold=0.5)
196
  print(f"This is likely an unwatermarked audio: {result2}")
 
170
  file_name="output.mp3",
171
  mime="audio/mpeg",
172
  )
173
+ elif action == "Detect Watermark":
174
+ detect_watermark_button = st.button("Detect Watermark", key="detect_watermark_btn")
175
+ if detect_watermark_button:
176
+ with st.spinner("Detecting..."):
177
  # result, message = detector.detect_watermark(watermarked_audio, sample_rate=default_sr, message_threshold=0.5)
178
  # st.markdown("Probability of audio being watermarked: ")
179
  # st.markdown(result)
 
182
 
183
  #Run on an unwatermarked audio
184
 
185
+ if file_extension in [".wav", ".flac"]:
186
+ wav, sample_rate = torchaudio.load("test.wav")
187
+ wav= wav.unsqueeze(0)
188
+
189
+ elif file_extension == ".mp3":
190
+ # Load an MP3 file
191
+ audio = AudioSegment.from_mp3("test.mp3")
192
+ # Export it as a WAV file
193
+ audio.export("test.wav", format="wav")
194
+ wav, sample_rate = torchaudio.load("test.wav")
195
+ wav= wav.unsqueeze(0)
196
 
197
  result2, message2 = detector.detect_watermark(wav, sample_rate=default_sr, message_threshold=0.5)
198
  print(f"This is likely an unwatermarked audio: {result2}")