You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

gTTS模块无法使用:无音频输出且弹出Adobe Reader对话框求助

问题解决步骤

1. 修正代码中的文件名错误

你代码里保存的音频文件是example.mp3,但调用系统打开的是不存在的hello.mp3,这会导致系统调用错误的关联程序(比如Adobe Reader)。把代码最后一行改成:

os.system("start example.mp3")

2. 修复MP3文件的系统关联

如果修正文件名后仍弹出Adobe Reader,说明系统把MP3格式默认关联到了PDF阅读器,需要修改默认打开程序:

  • 右键生成的example.mp3文件,选择「打开方式」→「选择其他应用」
  • 选中常用的音频播放器(比如Windows Media Player、VLC等),勾选「始终使用此应用打开.mp3文件」

3. 更可靠的音频播放方案(推荐)

避免依赖系统文件关联,使用专门的音频播放库playsound:

  1. 先安装库:
pip install playsound
  1. 修改代码为:
from gtts import gTTS
from playsound import playsound

mytext = "Hi, this is an example of converting text to audio. This is a bot speaking here, not a real human!"
audio = gTTS(text=mytext, lang="en", slow=False)
audio.save("example.mp3")
playsound("example.mp3")

内容的提问来源于stack exchange,提问作者Sachin R

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.06 09:55:23