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 1389, in process_api result = await self.call_function( File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\blocks.py", line 1094, in call_function prediction = await anyio.to_thread.run_sync( File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\anyio\to_thread.py", line 33, in run_sync return await get_asynclib().run_sync_in_worker_thread( File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread return await future File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run result = context.run(func, *args) File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\python3.9.13\3.9.13\lib\site-packages\gradio\utils.py", line 703, in wrapper response = f(*args, **kwargs) File "C:\Users\LY-AI\Desktop\AI\vits_chinese-2.0\vits_chinese-2.0\app.py", line 65, in tts_calback return "成功", gr.outputs.File(output_filepath, mime_type="audio/wav") TypeError: __init__() got an unexpected keyword argument 'mime_type'
时间: 2023-08-05 19:10:10 浏览: 160
Mac下anaconda中Spyder打开报错Traceback(most recent call last)…问题
5星 · 资源好评率100%
非常抱歉,我之前给出的代码有误。在 Gradio 中,使用 `gr.outputs.File` 类来创建文件下载的输出组件,并没有 `mime_type` 这个关键字参数。
正确的代码应该是这样的:
```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.File(output_filepath)
return tts_callback
```
这样可以将生成的音频文件作为文件下载的输出,在 Gradio 中显示下载按钮,而不需要指定 `mime_type`。
非常抱歉给您带来的困扰,希望这次修改能够解决问题。如有任何其他问题,请随时提问!
阅读全文