Spaces:
Runtime error
Runtime error
import gradio as gr | |
def greet(name): | |
return "Hello " + name + "!!" | |
iface = gr.Interface(fn=greet, inputs="text", outputs="text") | |
iface.launch() | |
import gradio as gr | |
from pydub import AudioSegment | |
import os | |
def cut_audio(input_audio, cut_interval): | |
# Load the audio file | |
audio = AudioSegment.from_file(input_audio) | |
# Calculate the number of cuts based on the specified interval | |
num_cuts = int(len(audio) / (cut_interval * 1000)) | |
# Create a directory to save the cut clips | |
output_dir = "cut_audio_clips" | |
os.makedirs(output_dir, exist_ok=True) | |
# Cut the audio into clips and save each clip | |
for i in range(num_cuts): | |
start_time = i * cut_interval * 1000 | |
end_time = (i + 1) * cut_interval * 1000 | |
cut_clip = audio[start_time:end_time] | |
output_path = os.path.join(output_dir, f"cut_{i + 1}.wav") | |
cut_clip.export(output_path, format="wav") | |
return f"{num_cuts} clips saved in {output_dir}" | |
iface = gr.Interface( | |
fn=cut_audio, | |
inputs=[ | |
gr.File("audio", label="Upload an audio file"), | |
gr.Number("number", default=5, label="Cut Interval (in seconds)"), | |
], | |
outputs="text", | |
live=True, | |
) | |
iface.launch() | |