import gradio as gr import torch import utils # 确保导入utils模块 # 假设模型是一个声音合成模型 def synthesize_speech(text): model = torch.load("mg_e8_s112.pth", map_location=torch.device('cpu')) model.eval() audio_output = model.synthesize(text) return audio_output gr.Interface( fn=synthesize_speech, inputs="text", outputs="audio" ).launch(share=True)