clean up
Browse files
app.py
CHANGED
@@ -40,18 +40,14 @@ def add_watermark(audio_path, watermark_text):
|
|
40 |
def decode_watermark(audio_path):
|
41 |
assert os.path.exists(audio_path)
|
42 |
|
43 |
-
#t1 = time.time()
|
44 |
signal, sr, audio_length_second = my_read_file(audio_path, max_second_decode)
|
45 |
payload_decoded, _ = wavmark.decode_watermark(model, signal, show_progress=False)
|
46 |
-
#decode_cost = time.time() - t1
|
47 |
|
48 |
if payload_decoded is None:
|
49 |
-
#return "No Watermark" , decode_cost
|
50 |
return "No Watermark"
|
51 |
|
52 |
payload_decoded_str = "".join([str(i) for i in payload_decoded])
|
53 |
st.write("Result:", payload_decoded_str)
|
54 |
-
#st.write("Time Cost:%d seconds" % (decode_cost))
|
55 |
|
56 |
|
57 |
def create_default_value():
|
@@ -65,7 +61,7 @@ def create_default_value():
|
|
65 |
def main():
|
66 |
create_default_value()
|
67 |
|
68 |
-
|
69 |
markdown_text = """
|
70 |
# Audio WaterMarking
|
71 |
You can upload an audio file and encode a custom 16-bit watermark or perform decoding from a watermarked audio.
|
@@ -83,8 +79,7 @@ def main():
|
|
83 |
with open(tmp_input_audio_file, "wb") as f:
|
84 |
f.write(audio_file.getbuffer())
|
85 |
|
86 |
-
|
87 |
-
# st.audio(tmp_input_audio_file, format="audio/wav")
|
88 |
|
89 |
action = st.selectbox("Select Action", ["Add Watermark", "Decode Watermark"])
|
90 |
|
@@ -94,13 +89,11 @@ def main():
|
|
94 |
if add_watermark_button:
|
95 |
if audio_file and watermark_text:
|
96 |
with st.spinner("Adding Watermark..."):
|
97 |
-
#watermarked_audio, encode_time_cost = add_watermark(tmp_input_audio_file, watermark_text)
|
98 |
watermarked_audio = add_watermark(tmp_input_audio_file, watermark_text)
|
99 |
st.write("Watermarked Audio:")
|
100 |
print("watermarked_audio:", watermarked_audio)
|
101 |
st.audio(watermarked_audio, format="audio/wav")
|
102 |
-
|
103 |
-
|
104 |
elif action == "Decode Watermark":
|
105 |
if st.button("Decode"):
|
106 |
with st.spinner("Decoding..."):
|
|
|
40 |
def decode_watermark(audio_path):
|
41 |
assert os.path.exists(audio_path)
|
42 |
|
|
|
43 |
signal, sr, audio_length_second = my_read_file(audio_path, max_second_decode)
|
44 |
payload_decoded, _ = wavmark.decode_watermark(model, signal, show_progress=False)
|
|
|
45 |
|
46 |
if payload_decoded is None:
|
|
|
47 |
return "No Watermark"
|
48 |
|
49 |
payload_decoded_str = "".join([str(i) for i in payload_decoded])
|
50 |
st.write("Result:", payload_decoded_str)
|
|
|
51 |
|
52 |
|
53 |
def create_default_value():
|
|
|
61 |
def main():
|
62 |
create_default_value()
|
63 |
|
64 |
+
|
65 |
markdown_text = """
|
66 |
# Audio WaterMarking
|
67 |
You can upload an audio file and encode a custom 16-bit watermark or perform decoding from a watermarked audio.
|
|
|
79 |
with open(tmp_input_audio_file, "wb") as f:
|
80 |
f.write(audio_file.getbuffer())
|
81 |
|
82 |
+
|
|
|
83 |
|
84 |
action = st.selectbox("Select Action", ["Add Watermark", "Decode Watermark"])
|
85 |
|
|
|
89 |
if add_watermark_button:
|
90 |
if audio_file and watermark_text:
|
91 |
with st.spinner("Adding Watermark..."):
|
|
|
92 |
watermarked_audio = add_watermark(tmp_input_audio_file, watermark_text)
|
93 |
st.write("Watermarked Audio:")
|
94 |
print("watermarked_audio:", watermarked_audio)
|
95 |
st.audio(watermarked_audio, format="audio/wav")
|
96 |
+
|
|
|
97 |
elif action == "Decode Watermark":
|
98 |
if st.button("Decode"):
|
99 |
with st.spinner("Decoding..."):
|