Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ import numpy as np
|
|
6 |
from pydub import AudioSegment
|
7 |
|
8 |
# Define a Streamlit app
|
9 |
-
st.title("Audio
|
10 |
|
11 |
# Upload the input audio file
|
12 |
uploaded_audio = st.file_uploader("Upload an audio file", type=["mp3", "wav"])
|
@@ -20,25 +20,22 @@ if uploaded_audio is not None:
|
|
20 |
# Apply noise reduction
|
21 |
st.write("Applying noise reduction...")
|
22 |
reduced_audio = nr.reduce_noise(y=audio, sr=sample_rate)
|
23 |
-
|
24 |
-
#
|
25 |
-
|
26 |
reduced_audio.tobytes(),
|
27 |
frame_rate=sample_rate,
|
28 |
-
sample_width=
|
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 |
-
#
|
37 |
-
|
|
|
38 |
|
39 |
# Provide a link to download the processed audio
|
40 |
-
st.audio("
|
41 |
|
42 |
# Run the Streamlit app
|
43 |
if __name__ == "__main__":
|
44 |
-
st.write("Upload an audio file to apply noise reduction and
|
|
|
6 |
from pydub import AudioSegment
|
7 |
|
8 |
# Define a Streamlit app
|
9 |
+
st.title("Audio Noise Reduction and Playback Speed App")
|
10 |
|
11 |
# Upload the input audio file
|
12 |
uploaded_audio = st.file_uploader("Upload an audio file", type=["mp3", "wav"])
|
|
|
20 |
# Apply noise reduction
|
21 |
st.write("Applying noise reduction...")
|
22 |
reduced_audio = nr.reduce_noise(y=audio, sr=sample_rate)
|
23 |
+
|
24 |
+
# Create an AudioSegment from the reduced audio data
|
25 |
+
reduced_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 |
+
# Adjust playback speed
|
33 |
+
st.write("Adjusting playback speed...")
|
34 |
+
slowed_audio = reduced_audio_segment.speedup(playback_speed=0.5)
|
35 |
|
36 |
# Provide a link to download the processed audio
|
37 |
+
st.audio(slowed_audio.export(format="wav"), format="audio/wav", sample_rate=sample_rate)
|
38 |
|
39 |
# Run the Streamlit app
|
40 |
if __name__ == "__main__":
|
41 |
+
st.write("Upload an audio file to apply noise reduction and adjust playback speed.")
|