File size: 752 Bytes
a1b12e0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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()