我的Pyttsx3模块没有说什么,但文本到语音功能不起作用,没有获得任何音频输出

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

我在pycharm中具有intsalle d pyttsx3 2.7vpython 3.7v

我的代码:说功能不返回音频输出

import pyttsx3
engine = pyttsx3.init("dummy")
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[0].id)

def speak(text):
    print('Rex:' + text)
    engine.say(text)
    engine.runAndWait()

print("On")
speak("This programe is runniing perfectly")
print("End")

输出

On
Rex:This programe is runniing perfectly
End

Process finished with exit code 0

我在pycharm中安装了pyttsx3 2.7v和python 3.7v我的代码:说话功能未返回音频输出导入pyttsx3 engine = pyttsx3.init(“ dummy”)声音= engine.getProperty('voices')...] >

python-3.x module pycharm speech-recognition
1个回答
0
投票

这非常容易,我与Pyttsx3合作。请尝试以下程序。

import pyttsx3
engine = pyttsx3.init('sapi5')           # <--- sapi 5 is for Windows
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[0].id)  # <--- voice id can be male(0) or female(1) 


def speak(audio):
    engine.say(audio)
    engine.runAndWait()
© www.soinside.com 2019 - 2024. All rights reserved.