fffiloni commited on
Commit
f04256e
·
verified ·
1 Parent(s): 7e9fcca

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def infer(audio_input_path):
4
+
5
+ import subprocess
6
+
7
+ command = [
8
+ "python", "-m", "moshi.run_inference",
9
+ f"{audio_input_path}", "out_en.wav",
10
+ "--hf-repo", "kyutai/hibiki-1b-pytorch-bf16"
11
+ ]
12
+
13
+ result = subprocess.run(command, capture_output=True, text=True)
14
+
15
+ # Print the standard output and error
16
+ print("STDOUT:", result.stdout)
17
+ print("STDERR:", result.stderr)
18
+
19
+ # Check if the command was successful
20
+ if result.returncode == 0:
21
+ print("Command executed successfully.")
22
+ else:
23
+ print("Error executing command.")
24
+
25
+ return "Done"
26
+
27
+ with gr.Blocks() as demo:
28
+ with gr.Column(elem_id="col-container"):
29
+ gr.Markdown("# hibiki test")
30
+ audio_input = gr.Audio(label="Audio IN", type="filepath")
31
+ submit_btn = gr.Button("Submit")
32
+ output_result = gr.Audio("Translated result")
33
+
34
+ submit_btn.click(
35
+ fn = infer,
36
+ inputs = [audio_input],
37
+ outputs = [output_result]
38
+ )
39
+
40
+ demo.queue().launch(show_api=False, show_error=True)