| import gradio as gr |
| import subprocess |
|
|
| |
| def save_file(input_file): |
| |
| saved_file_path = "/home/user/app/audio/saved_file.wav" |
| |
| |
| with open(saved_file_path, 'wb') as saved_file: |
| saved_file.write(input_file.read()) |
| |
| cmd = ["svc", "infer", saved_file_path, "-m", "/home/user/app/models", "-c", "/home/user/app/models/config.json"] |
| result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) |
| print("STDOUT:", result.stdout) |
| print("STDERR:", result.stderr) |
| |
| |
| with open(saved_file_path, "rb") as f: |
| final_file_bytes = f.read() |
| |
| return final_file_bytes |
|
|
| |
| iface = gr.Interface( |
| fn=save_file, |
| inputs="file", |
| outputs="text", |
| live=False, |
| ) |
|
|
| |
| iface.launch() |