|
import streamlit as st |
|
import soundfile as sf |
|
import numpy as np |
|
from pydub import AudioSegment |
|
|
|
|
|
st.title("Audio Processing App") |
|
|
|
|
|
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() |
|
|
|
|
|
audio, sample_rate = sf.read(io.BytesIO(audio_bytes)) |
|
|
|
|
|
audio = (audio * 32767).astype(np.int16) |
|
|
|
|
|
audio_segment = AudioSegment( |
|
audio.tobytes(), |
|
frame_rate=sample_rate, |
|
sample_width=2, |
|
channels=1 |
|
) |
|
|
|
|
|
st.write("Slowing down audio...") |
|
slowed_audio = audio_segment.speedup(playback_speed=0.7) |
|
|
|
|
|
st.audio(slowed_audio.export(format="wav").read(), format="audio/wav") |
|
|
|
|
|
if __name__ == "__main__": |
|
st.write("Upload an audio file to process.") |
|
|