如何在mpg123库中使用gTTs解决

2022-09-28 20:44:02 发布

您现在位置:Python中文网/ 问答频道 /正文

from gtts import gTTS
import speech_recognition as sr
from mpg123 import Mpg123, Out123


# class Test():
#     def __init__(self):
tts = gTTS(text="How can I help you ?", lang='en')
tts.save('speak_test.mp3')
aud_file = Mpg123('speak_test.mp3')
out = Out123()
for frame in aud_file.iter_frames(out.start):
    out.play(frame)

输出: 回溯(最近一次呼叫): 文件“D:/Users/ASUS/PycharmProjects/intent\u identifier\u aud/test.py”,第10行,in aud\u file=Mpg123('speak\u jarvis.mp3') 文件“C:\Users\ASUS\AppData\Local\Programs\Python\Python37\lib\site packages\mpg123.py”,第110行,ininit self.\u lib=self.init\u库(库路径) 文件“C:\Users\ASUS\AppData\Local\Programs\Python\Python37\lib\site packages\mpg123.py”,第99行,在init\u库中 raise self.LibInitializationException('libmpg123 not found') mpg123.LibInitializationException:找不到libmpg123


Tags: 文件pytestimportselfinitoutmp3usersfilespeakmpg123audasus