Spaces:
Sleeping
Sleeping
File size: 1,002 Bytes
84f0350 dca7ef0 84f0350 |
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 29 30 31 32 33 34 35 36 37 |
import gradio as gr
import shutil
import os
import uuid
SAVE_DIR = "recordings"
os.makedirs(SAVE_DIR, exist_ok=True)
def save_and_return(audio_path):
if audio_path is None:
return None, "β ι²ι³γγγ¦γγΎγγ"
# δΏεε
γγ¦γγΌγ―γ«οΌδΈζΈγι²ζ’οΌ
new_path = os.path.join(SAVE_DIR, f"{uuid.uuid4().hex}.wav")
shutil.copy(audio_path, new_path)
return new_path, "β
ι²ι³δΏεοΌεηζΊεOKοΌ"
with gr.Blocks() as demo:
gr.Markdown("# π€ ι²ι³γγ¦εη")
with gr.Row():
audio_input = gr.Audio(sources=["microphone"], type="filepath", label="ι²ι³")
audio_output = gr.Audio(label="ι²ι³γγι³ε£°γεη")
result_text = gr.Textbox(label="η΅ζ")
audio_input.change(fn=save_and_return, inputs=audio_input, outputs=[audio_output, result_text])
if __name__ == "__main__":
demo.launch(
server_name="0.0.0.0",
server_port=7860,
share=True,
show_error=True
)
|