Update app.py
Browse files
app.py
CHANGED
@@ -170,6 +170,34 @@ def main():
|
|
170 |
file_name="output.mp3",
|
171 |
mime="audio/mpeg",
|
172 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
except RuntimeError:
|
174 |
st.error("Please input audio with one channel (mono-channel)")
|
175 |
|
@@ -318,33 +346,33 @@ def main():
|
|
318 |
# # #st.markdown(size)
|
319 |
|
320 |
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
|
349 |
|
350 |
if __name__ == "__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)
|
178 |
+
# st.markdown("This is likely a watermarked audio!")
|
179 |
+
# print(f"\nThis is likely a watermarked audio: {result}")
|
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}")
|
197 |
+
st.markdown("Probability of audio being watermarked: ")
|
198 |
+
st.markdown(result2)
|
199 |
+
st.markdown("This is likely an unwatermarked audio!")
|
200 |
+
|
201 |
except RuntimeError:
|
202 |
st.error("Please input audio with one channel (mono-channel)")
|
203 |
|
|
|
346 |
# # #st.markdown(size)
|
347 |
|
348 |
|
349 |
+
if detect_watermark_button:
|
350 |
+
with st.spinner("Detecting..."):
|
351 |
+
# result, message = detector.detect_watermark(watermarked_audio, sample_rate=default_sr, message_threshold=0.5)
|
352 |
+
# st.markdown("Probability of audio being watermarked: ")
|
353 |
+
# st.markdown(result)
|
354 |
+
# st.markdown("This is likely a watermarked audio!")
|
355 |
+
# print(f"\nThis is likely a watermarked audio: {result}")
|
356 |
+
|
357 |
+
#Run on an unwatermarked audio
|
358 |
+
|
359 |
+
if file_extension in [".wav", ".flac"]:
|
360 |
+
wav, sample_rate = torchaudio.load("test.wav")
|
361 |
+
wav= wav.unsqueeze(0)
|
362 |
+
|
363 |
+
elif file_extension == ".mp3":
|
364 |
+
# Load an MP3 file
|
365 |
+
audio = AudioSegment.from_mp3("test.mp3")
|
366 |
+
# Export it as a WAV file
|
367 |
+
audio.export("test.wav", format="wav")
|
368 |
+
wav, sample_rate = torchaudio.load("test.wav")
|
369 |
+
wav= wav.unsqueeze(0)
|
370 |
|
371 |
+
result2, message2 = detector.detect_watermark(wav, sample_rate=default_sr, message_threshold=0.5)
|
372 |
+
print(f"This is likely an unwatermarked audio: {result2}")
|
373 |
+
st.markdown("Probability of audio being watermarked: ")
|
374 |
+
st.markdown(result2)
|
375 |
+
st.markdown("This is likely an unwatermarked audio!")
|
376 |
|
377 |
|
378 |
if __name__ == "__main__":
|