Update app.py
Browse files
app.py
CHANGED
@@ -3,9 +3,10 @@ import noisereduce as nr
|
|
3 |
import soundfile as sf
|
4 |
import io
|
5 |
import numpy as np
|
|
|
6 |
|
7 |
# Define a Streamlit app
|
8 |
-
st.title("Audio
|
9 |
|
10 |
# Upload the input audio file
|
11 |
uploaded_audio = st.file_uploader("Upload an audio file", type=["mp3", "wav"])
|
@@ -20,9 +21,24 @@ if uploaded_audio is not None:
|
|
20 |
st.write("Applying noise reduction...")
|
21 |
reduced_audio = nr.reduce_noise(y=audio, sr=sample_rate)
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
# Provide a link to download the processed audio
|
24 |
-
st.audio(
|
25 |
|
26 |
# Run the Streamlit app
|
27 |
if __name__ == "__main__":
|
28 |
-
st.write("Upload an audio file to apply noise reduction.")
|
|
|
3 |
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")
|
10 |
|
11 |
# Upload the input audio file
|
12 |
uploaded_audio = st.file_uploader("Upload an audio file", type=["mp3", "wav"])
|
|
|
21 |
st.write("Applying noise reduction...")
|
22 |
reduced_audio = nr.reduce_noise(y=audio, sr=sample_rate)
|
23 |
|
24 |
+
# Convert the reduced audio to an AudioSegment for further processing
|
25 |
+
audio_segment = AudioSegment(
|
26 |
+
reduced_audio.tobytes(),
|
27 |
+
frame_rate=sample_rate,
|
28 |
+
sample_width=reduced_audio.dtype.itemsize,
|
29 |
+
channels=1 # Assuming mono audio
|
30 |
+
)
|
31 |
+
|
32 |
+
# Slow down the audio
|
33 |
+
st.write("Slowing down audio...")
|
34 |
+
slowed_audio = audio_segment.speedup(playback_speed=0.7) # Adjust the speed factor as needed
|
35 |
+
|
36 |
+
# Export the slowed audio to a WAV file
|
37 |
+
slowed_audio.export("output_audio.wav", format="wav")
|
38 |
+
|
39 |
# Provide a link to download the processed audio
|
40 |
+
st.audio("output_audio.wav")
|
41 |
|
42 |
# Run the Streamlit app
|
43 |
if __name__ == "__main__":
|
44 |
+
st.write("Upload an audio file to apply noise reduction and slow down the audio.")
|