Trim / app.py
Rhueue's picture
Update app.py
581e69d
raw
history blame
No virus
876 Bytes
import streamlit as st
from pydub import AudioSegment
from pydub.playback import _play_with_simpleaudio as play_sound
import io
# Define a Streamlit app
st.title("Audio Speed Reduction App")
# Upload the input audio file
uploaded_audio = st.file_uploader("Upload an audio file", type=["mp3", "wav", "ogg", "flac", "wma", "m4a"])
if uploaded_audio is not None:
audio_bytes = uploaded_audio.read()
# Convert audio file to AudioSegment
audio = AudioSegment.from_file(io.BytesIO(audio_bytes))
# Slow down the audio using the speed_change_ratio
st.write("Slowing down audio...")
speed_change_ratio = 0.7
slowed_audio = audio.speedup(playback_speed=1/speed_change_ratio)
# Play the slowed down audio
play_sound(slowed_audio)
# Run the Streamlit app
if __name__ == "__main__":
st.write("Upload an audio file to apply speed reduction.")