Warning (from warnings module): File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\vits_chinese-2.0\app.py", line 65 return "成功", gr.outputs.File(output_filepath) GradioDeprecationWarning: Usage of gradio.outputs is deprecated, and will not be supported in the future, please import your components from gradio.components DEBUG:matplotlib.pyplot:Loaded backend TkAgg version 8.6. Traceback (most recent call last): File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\routes.py", line 442, in run_predict output = await app.get_blocks().process_api( File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\blocks.py", line 1392, in process_api data = self.postprocess_data(fn_index, result["prediction"], state) File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\blocks.py", line 1326, in postprocess_data prediction_value = block.postprocess(prediction_value) File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\components\audio.py", line 334, in postprocess file_path = self.make_temp_copy_if_needed(y) File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\components\base.py", line 226, in make_temp_copy_if_needed temp_dir = self.hash_file(file_path) File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\components\base.py", line 190, in hash_file with open(file_path, "rb") as f: TypeError: expected str, bytes or os.PathLike object, not File
时间: 2023-08-05 09:10:10 浏览: 556
看起来代码中出现了一些问题。首先,Gradio 在最新版本中已经不再支持 `gradio.outputs` 模块,而是改为使用 `gradio.components` 模块。因此,您需要更新代码以适应最新的更改。
其次,关于 `TypeError: expected str, bytes or os.PathLike object, not File` 错误,它表明在代码中传递了一个 `File` 对象而不是文件路径。为了解决这个问题,您需要将 `output_filepath` 从 `File` 对象修改为文件路径。
下面是修改后的代码示例:
```python
import gradio as gr
def create_callback(net_g: SynthesizerTrn, tts_front: VITS_PinYin):
def tts_callback(text, dur_scale):
# 其他代码省略...
# 修改下载文件的默认存放位置
output_filepath = "/path/to/output/file.wav" # 指定下载文件的存放路径
return "成功", gr.outputs.FileDownload(output_filepath)
return tts_callback
```
确保您已经导入了 `gradio` 模块,并使用 `gr.outputs.FileDownload` 创建文件下载的输出。
希望这次修改能够解决问题。如有任何其他问题,请随时提问!
阅读全文