File size: 1,187 Bytes
5034d88 bd01872 a1d239c 5034d88 bd01872 5034d88 bd01872 7cd88dd bd01872 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import streamlit as st
import noisereduce as nr
from pydub import AudioSegment
# Define a Streamlit app
st.title("Audio Processing App")
# Upload the input audio file
uploaded_audio = st.file_uploader("Upload an audio file", type=["mp3", "wav"])
if uploaded_audio is not None:
# Clean the input audio using noisereduce
# You may need to adjust the parameters for your specific audio
st.write("Cleaning audio...")
# Load the audio file
audio = AudioSegment.from_file(uploaded_audio)
# Convert to numpy array for processing
audio_data = audio.get_array_of_samples()
# Apply noise reduction
reduced_audio = nr.reduce_noise(y=audio_data, sr=audio.frame_rate)
# Slow down the audio
st.write("Slowing down audio...")
slowed_audio = audio.speedup(playback_speed=0.7) # Adjust the speed factor as needed
# Generate a new audio file
st.write("Generating output audio...")
slowed_audio.export("output_audio.wav", format="wav")
# Provide the download link for the cleaned and slowed audio
st.audio("output_audio.wav")
# Run the Streamlit app
if __name__ == "__main__":
st.write("Upload an audio file to get started.")
|