Update app.py
Browse files
app.py
CHANGED
|
@@ -170,8 +170,10 @@ def main():
|
|
| 170 |
file_name="output.mp3",
|
| 171 |
mime="audio/mpeg",
|
| 172 |
)
|
| 173 |
-
|
| 174 |
-
|
|
|
|
|
|
|
| 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 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 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}")
|