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

Apple Silicon Mac下pyttsx3可朗读但无法保存语音文件问题求助

Apple Silicon Mac上pyttsx3 save_to_file()无限挂起的解决方法

在Apple Silicon芯片的Mac设备上使用pyttsx3时,say()方法可正常朗读,但调用save_to_file()保存MP3文件会导致脚本无限挂起,提前创建空文件也无法解决这个问题。

可能的解决办法:

  • 换用AIFF格式保存再转MP3
    pyttsx3在macOS上对AIFF格式的支持更稳定,先保存为AIFF再用系统工具转MP3:

    eng = pyttsx3.init()
    eng.save_to_file('Hey', 'hey.aiff')
    eng.runAndWait()
    

    然后用终端命令转成MP3:

    afconvert hey.aiff -d mp3 -o hey.mp3
    
  • 手动指定NSSpeech驱动
    强制pyttsx3使用macOS原生的NSSpeechSynthesizer驱动,避免兼容性问题:

    import pyttsx3
    
    eng = pyttsx3.init(driverName='nsss')
    eng.save_to_file('Hey', 'hey.mp3')
    eng.runAndWait()
    
  • 升级pyttsx3到最新版本
    新版本可能修复了Apple Silicon的适配问题,执行升级命令:

    pip install --upgrade pyttsx3
    
  • 重启终端/IDE后重试
    有时音频资源被其他进程占用会导致挂起,重启后再运行脚本。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.30 14:27:35