Rhueue commited on
Commit
8a33587
·
1 Parent(s): c29f44b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -4,6 +4,7 @@ import soundfile as sf
4
  import io
5
  import numpy as np
6
  from pydub import AudioSegment
 
7
 
8
  # Define a Streamlit app
9
  st.title("Audio Processing App")
@@ -29,15 +30,15 @@ if uploaded_audio is not None:
29
  channels=1
30
  )
31
 
32
- # Save the reduced audio as a 16-bit wave file
33
  reduced_audio.export("reduced_audio.wav", format="wav")
34
 
35
  # Load the 16-bit wave file and slow it down
36
  slowed_audio = AudioSegment.from_wav("reduced_audio.wav")
37
  slowed_audio = slowed_audio.speedup(playback_speed=0.7)
38
 
39
- # Export the slowed audio to a file
40
- slowed_audio.export("output_audio.wav", format="wav")
41
 
42
  # Provide the download link for the processed audio
43
  st.audio("output_audio.wav")
 
4
  import io
5
  import numpy as np
6
  from pydub import AudioSegment
7
+ from scipy.io.wavfile import write
8
 
9
  # Define a Streamlit app
10
  st.title("Audio Processing App")
 
30
  channels=1
31
  )
32
 
33
+ # Save the reduced audio as a temporary 16-bit wave file
34
  reduced_audio.export("reduced_audio.wav", format="wav")
35
 
36
  # Load the 16-bit wave file and slow it down
37
  slowed_audio = AudioSegment.from_wav("reduced_audio.wav")
38
  slowed_audio = slowed_audio.speedup(playback_speed=0.7)
39
 
40
+ # Save the slowed down audio as a WAV file with 16-bit sample width using scipy
41
+ write("output_audio.wav", slowed_audio.frame_rate, slowed_audio.get_array_of_samples())
42
 
43
  # Provide the download link for the processed audio
44
  st.audio("output_audio.wav")