test-upload / app.py
redstoneleo's picture
Upload app.py
a1b12e0 verified
raw
history blame contribute delete
752 Bytes
import gradio as gr
import shutil
import os
def save_audio_file(audio_path):
if audio_path is None:
return "No audio file uploaded."
save_dir = "files"
os.makedirs(save_dir, exist_ok=True)
file_name = os.path.basename(audio_path)
destination = os.path.join(save_dir, file_name)
shutil.copy(audio_path, destination)
return f"Audio file saved to {destination}"
interface = gr.Interface(
fn=save_audio_file,
inputs=gr.Audio(sources=["upload", "microphone"], type="filepath"),
outputs="text",
title="Audio File Uploader",
description="Upload an audio file or record from your microphone. It will be saved to the 'files' folder."
)
interface.launch()