Spaces:
Runtime error
Runtime error
Download app.py from redstoneleo/test-upload: direct link, hf CLI and curl.
- Browser
- Download file 752 Bytes
-
https://huggingface.co/spaces/redstoneleo/test-upload/resolve/main/app.py
- Command line
-
hf download hf://spaces/redstoneleo/test-upload/app.py
-
curl -L -o app.py https://huggingface.co/spaces/redstoneleo/test-upload/resolve/main/app.py
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() |