import gradio as gr from inference_main import infer def interference(wav_file, trans=0): # determine if wav_file is .wav # then, inference # return the result # if the wav_file is not .wav, inform the user and let user re upload the file if not wav_file.endswith('.wav'): return None, "Please upload a .wav file" return infer(wav_file, trans=[trans]), "Succeed" # write a gr.Interface that accept a wav file iface = gr.Interface( fn=interference, inputs=[gr.inputs.Audio(type="filepath", label="Input Audio"), gr.inputs.Number(default=0, label="音高变换")], outputs=[gr.outputs.Audio(type="numpy", label="Reversed Audio"), "text"] ) iface.launch()