Zw07 commited on
Commit
651d68e
1 Parent(s): 933f493

2nd way of watermarking audio

Browse files
Files changed (1) hide show
  1. app.py +19 -4
app.py CHANGED
@@ -150,8 +150,25 @@ def main():
150
  if audio_file and watermark_text:
151
  with st.spinner("Adding Watermark..."):
152
  #wav = my_read_file(wav,max_second_encode)
153
- watermark = model.get_watermark(wav, default_sr)
154
- watermarked_audio = wav + watermark
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  print(watermarked_audio.size())
156
  size = watermarked_audio.size()
157
  st.markdown(size)
@@ -162,8 +179,6 @@ def main():
162
  st.markdown(shape)
163
 
164
  st.markdown(squeeze)
165
-
166
- watermarked_audio = torchaudio.save("output.wav", squeeze, default_sr)
167
  # watermarked_audio, encode_time_cost = add_watermark(tmp_input_audio_file, watermark_text)
168
  st.write("Watermarked Audio:")
169
  st.markdown(watermarked_audio)
 
150
  if audio_file and watermark_text:
151
  with st.spinner("Adding Watermark..."):
152
  #wav = my_read_file(wav,max_second_encode)
153
+
154
+ #1st attempt
155
+ # watermark = model.get_watermark(wav, default_sr)
156
+ # watermarked_audio = wav + watermark
157
+ # print(watermarked_audio.size())
158
+ # size = watermarked_audio.size()
159
+ # st.markdown(size)
160
+
161
+ # print(watermarked_audio.squeeze())
162
+ # squeeze = watermarked_audio.squeeze(1)
163
+ # shape = squeeze.size()
164
+ # st.markdown(shape)
165
+
166
+ # st.markdown(squeeze)
167
+
168
+ # watermarked_audio = torchaudio.save("output.wav", squeeze, default_sr)
169
+
170
+ #2nd Attempt
171
+ watermarked_audio = model(wav, sample_rate=default_sr, message=watermark_text, alpha=1)
172
  print(watermarked_audio.size())
173
  size = watermarked_audio.size()
174
  st.markdown(size)
 
179
  st.markdown(shape)
180
 
181
  st.markdown(squeeze)
 
 
182
  # watermarked_audio, encode_time_cost = add_watermark(tmp_input_audio_file, watermark_text)
183
  st.write("Watermarked Audio:")
184
  st.markdown(watermarked_audio)