Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
"""Set up the Gradio interface"""
|
2 |
|
3 |
import gradio as gr
|
|
|
1 |
+
import librosa
|
2 |
+
import soundfile as sf
|
3 |
+
|
4 |
+
def adjust_pitch(audio_path, pitch_factor):
|
5 |
+
# Load audio
|
6 |
+
y, sr = librosa.load(audio_path)
|
7 |
+
# Adjust pitch
|
8 |
+
y_shifted = librosa.effects.pitch_shift(y, sr, n_steps=pitch_factor)
|
9 |
+
# Save adjusted audio
|
10 |
+
sf.write(audio_path, y_shifted, sr)
|
11 |
+
|
12 |
+
def adjust_speed(audio_path, speed_factor):
|
13 |
+
# Load the audio file
|
14 |
+
y, sr = librosa.load(audio_path)
|
15 |
+
|
16 |
+
# Adjust the speed (this alters the duration of the audio)
|
17 |
+
y_speeded = librosa.effects.time_stretch(y, speed_factor)
|
18 |
+
|
19 |
+
# Save the adjusted audio
|
20 |
+
sf.write(audio_path, y_speeded, sr)
|
21 |
+
|
22 |
"""Set up the Gradio interface"""
|
23 |
|
24 |
import gradio as gr
|