Spaces:
Runtime error
Runtime error
File size: 953 Bytes
bf7bd33 |
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 |
import gradio as gr
import librosa
import soundfile as sf
def nightcore_effect(audio_filepath):
try:
y, sr = librosa.load(audio_filepath, sr=None)
# Speed up the audio (e.g., 1.25 times faster)
y_speed_up = librosa.effects.time_stretch(y, rate=1.25)
# Shift the pitch higher (e.g., by 5 semitones)
y_pitch_shift = librosa.effects.pitch_shift(y_speed_up, sr=sr, n_steps=5)
# Save the modified audio to a temporary file
output_path = "modified_audio.wav"
sf.write(output_path, y_pitch_shift, sr)
return output_path
except Exception as e:
print(f"Error processing audio: {e}")
return "Error"
# Define the Gradio interface
iface = gr.Interface(
fn=nightcore_effect,
inputs=gr.Audio(type="filepath", label="Upload a .wav file"), # Updated line
outputs=gr.Audio(label="Processed Audio"),
live=False
)
# Launch the interface
iface.launch()
|