|
|
import gradio as gr |
|
|
import shutil |
|
|
import subprocess |
|
|
|
|
|
def save_file(input_file): |
|
|
|
|
|
temp_file_path = input_file.name |
|
|
|
|
|
|
|
|
saved_file_path = "audio/saved_file.wav" |
|
|
|
|
|
|
|
|
shutil.copy(temp_file_path, saved_file_path) |
|
|
cmd = ["svc", "infer", f"/content/{saved_file_path}", "-m", "/content/models", "-c", "/content/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, |
|
|
capture_session=True |
|
|
) |
|
|
|
|
|
|
|
|
iface.launch(share=True) |