Rhueue commited on
Commit
581e69d
1 Parent(s): 1b95475

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import streamlit as st
2
  from pydub import AudioSegment
 
3
  import io
4
 
5
  # Define a Streamlit app
@@ -14,15 +15,13 @@ if uploaded_audio is not None:
14
  # Convert audio file to AudioSegment
15
  audio = AudioSegment.from_file(io.BytesIO(audio_bytes))
16
 
17
- # Slow down the audio by changing the playback speed
18
  st.write("Slowing down audio...")
19
- slowed_audio = audio.speedup(playback_speed=0.5)
 
20
 
21
- # Convert the slowed audio to bytes
22
- slowed_audio_bytes = slowed_audio.export(format="wav").read()
23
-
24
- # Provide a link to download the processed audio
25
- st.audio(slowed_audio_bytes, format="audio/wav")
26
 
27
  # Run the Streamlit app
28
  if __name__ == "__main__":
 
1
  import streamlit as st
2
  from pydub import AudioSegment
3
+ from pydub.playback import _play_with_simpleaudio as play_sound
4
  import io
5
 
6
  # Define a Streamlit app
 
15
  # Convert audio file to AudioSegment
16
  audio = AudioSegment.from_file(io.BytesIO(audio_bytes))
17
 
18
+ # Slow down the audio using the speed_change_ratio
19
  st.write("Slowing down audio...")
20
+ speed_change_ratio = 0.7
21
+ slowed_audio = audio.speedup(playback_speed=1/speed_change_ratio)
22
 
23
+ # Play the slowed down audio
24
+ play_sound(slowed_audio)
 
 
 
25
 
26
  # Run the Streamlit app
27
  if __name__ == "__main__":