为什么我不能使用“PlaySound”播放 mp3 文件?

问题描述 投票:0回答:0

你好我是pyton的初学者。 我想通过 gtts 制作文字转语音。在将语音文件保存为 mp3 格式后,我想通过“playsound”播放它,但它给出了一个错误。 它播放普通歌曲,但不播放 gtts 保存的声音。 这是我的代码:

import gtts
from playsound import playsound

t1 = gtts.gTTS("hello world")
t1.save("t1.mp3")
playsound("t1.mp3")

保存文件后尝试播放声音时会返回错误 这是错误:

playsound.PlaysoundException:
    Error 259 for command:
        play t1.mp3 wait
    The driver cannot recognize the specified command parameter.

我确实尝试过使用

os.system("t1.mp3")
来完成它并且它确实有效但是使用媒体播放器我真的不喜欢那样。我认为背景声音在我的项目中可以做得更好。

python audio mp3 playsound gtts
© www.soinside.com 2019 - 2024. All rights reserved.