redstoneleo commited on
Commit
a1b12e0
·
verified ·
1 Parent(s): 1436976

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import shutil
3
+ import os
4
+
5
+ def save_audio_file(audio_path):
6
+ if audio_path is None:
7
+ return "No audio file uploaded."
8
+
9
+ save_dir = "files"
10
+ os.makedirs(save_dir, exist_ok=True)
11
+
12
+ file_name = os.path.basename(audio_path)
13
+ destination = os.path.join(save_dir, file_name)
14
+
15
+ shutil.copy(audio_path, destination)
16
+
17
+ return f"Audio file saved to {destination}"
18
+
19
+
20
+ interface = gr.Interface(
21
+ fn=save_audio_file,
22
+ inputs=gr.Audio(sources=["upload", "microphone"], type="filepath"),
23
+ outputs="text",
24
+ title="Audio File Uploader",
25
+ description="Upload an audio file or record from your microphone. It will be saved to the 'files' folder."
26
+ )
27
+
28
+ interface.launch()