0

我想要将 python 文本中的泰米尔语语音转换为语音,但我无法将语音从默认更改为任何其他语言。我试过这段代码

import pyttsx3
engine = pyttsx3.init()
voices = engine.getProperty('voices')
for voice in voices:
   if voice.id == 'tamil':
       engine.setProperty('voice', voice.id)
       print(engine.getProperty('voice'))
       break

但打印语句仍然打印默认值。

4

1 回答 1

0

我试图解决您的问题,并得出结论,当您运行该线路时:

engine.runAndWait() 

那是在变量引擎中设置参数的时候。因此,您可以尝试使用以下代码:

import pyttsx3;
engine = pyttsx3.init();
voices = engine.getProperty('voices')
idVoice = 0
for voice in voices:
   idVoice = idVoice + 1
   if voice.id == 'tamil':
       print("void ID: ", voice.id)
       engine.setProperty('voice', voice.id)
       engine.say("My new message...")
       engine.runAndWait()
       print(engine.getProperty('voice'))
       break
print(idVoice)
engine.setProperty('rate',170)
engine.setProperty('volume', 0.9)
print("The new voice: ", engine.getProperty('voice'))
于 2018-11-21T15:39:46.557 回答