我正在尝试使用pyttsx进行文本转语音。我想告诉法语'é':
# -*- coding: utf8 -*-
import pyttsx
engine = pyttsx.init()
voice = engine.getProperty('voices')[26] # the french voice
engine.setProperty('voice', voice.id)
engine.say('Je lui ai dit, fait gaffe a ton nez') # perfect
engine.say('Tu as bien mangé?') # not saying anything
engine.runAndWait()
答案 0 :(得分:0)
我尝试使用pyttsx3,因为它是我安装的。它在python 2.7下运行。
这是代码(对我来说法语为0)。只需在字符串前面加上u(对于unicode)即可。
# -*- coding: utf8 -*
import pyttsx3
engine = pyttsx3.init()
voice = engine.getProperty('voices')[0] # the french voice
engine.setProperty('voice', voice.id)
engine.say('Je lui ai dit, fait gaffe a ton nez') # perfect
engine.say(u'Tu as bien mangé?') # it works!!
engine.runAndWait()