Pyttsx3 语音性别(女)

jel*_*ean 6 python-3.x pyttsx

我测试了文本转语音模块,即 pyttsx3,它工作正常,但是在打印文本时我没有听到女声。关于将性别从男性更改为女性有什么建议吗?顺便说一下,我使用的是树莓派,并且使用的是 Linux 操作系统。

先感谢您

tts.py

engine = pyttsx.init()
voices = engine.getProperty('voices')
for voice in voices:
   engine.setProperty('voice', voice.id)
   engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()
Run Code Online (Sandbox Code Playgroud)

小智 9

事实上,核心 pyttsx3 包中不包含女性声音。但如果你使用linux/espeak,就有一个解决方案。您可以使用其中之一来模拟女声。

engine.setProperty('voice', 'english+f1')
engine.setProperty('voice', 'english+f2')
engine.setProperty('voice', 'english+f3')
engine.setProperty('voice', 'english+f4')
engine.setProperty('voice', 'english_rp+f3') #my preference
engine.setProperty('voice', 'english_rp+f4')
Run Code Online (Sandbox Code Playgroud)

您还可以通过将+f1 到 +f4添加到其他基本声音来进行尝试。有关更多信息,您可以在 github 中查看此问题:pyttsx Female voice


Car*_*lio 5

我使用 pyttsx3 找到了一些可以接受的女性声音(就我而言)。我使用的是 MacOS High Sierra、Python 3.7.3 和 Pyttsx3 2.90。我运行了下面的代码来使用 Samantha 语音 ID:

import pyttsx3
engine = pyttsx3.init()
engine.setProperty('voice', 'com.apple.speech.synthesis.voice.samantha')
Run Code Online (Sandbox Code Playgroud)

我发现许多女性声音都在寻找性别属性(“VoiceGenderFemale”)。不过大部分都很奇怪,上面这个是最能接受的。我发现它运行以下代码:

import pyttsx3
engine = pyttsx3.init()
voices = engine.getProperty('voices')
voiceFemales = filter(lambda v: v.gender == 'VoiceGenderFemale', voices)
for v in voiceFemales:
    engine.setProperty('voice', v.id)
    engine.say('Hello world from ' + v.name)
    engine.runAndWait()
Run Code Online (Sandbox Code Playgroud)


Art*_*out -1

来自pyttsx3 的官方 pypi 页面

voices = engine.getProperty('voices')       #getting details of current voice
#engine.setProperty('voice', voices[0].id)  #changing index, changes voices. o for male
engine.setProperty('voice', voices[1].id)   #changing index, changes voices. 1 for female

Run Code Online (Sandbox Code Playgroud)

  • 不幸的是,我只能听到男声。当我尝试打印所有可用的声音时,令人惊讶的是只有男性声音,但有不同的口音,例如非洲、英国等。有没有办法安装一些模块并实现女性声音? (4认同)