Zw07 commited on
Commit
b98996a
1 Parent(s): 782ddf5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -0
app.py CHANGED
@@ -10,6 +10,7 @@ from wavmark.utils import file_reader
10
  from audioseal import AudioSeal
11
  import torchaudio
12
  from pydub import AudioSegment
 
13
 
14
  # pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
15
 
@@ -141,6 +142,13 @@ def main():
141
  st.markdown(wav)
142
  wav= wav.unsqueeze(0)
143
 
 
 
 
 
 
 
 
144
  # Play the audio file (WAV format)
145
  st.audio(wav, format="audio/wav")
146
 
 
10
  from audioseal import AudioSeal
11
  import torchaudio
12
  from pydub import AudioSegment
13
+ import io
14
 
15
  # pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
16
 
 
142
  st.markdown(wav)
143
  wav= wav.unsqueeze(0)
144
 
145
+ #2nd way
146
+ # Convert the tensor to a byte-like object in WAV format
147
+ with io.BytesIO() as buffer:
148
+ # Save the audio to the buffer using torchaudio
149
+ torchaudio.save(buffer, wav, default_sr, format="wav")
150
+ # Get the byte data from the buffer
151
+ wav = buffer.getvalue()
152
  # Play the audio file (WAV format)
153
  st.audio(wav, format="audio/wav")
154