windows中的合成器听起来比linux(python和pyttsx3)要好得多



我在python中基于pyttsx3库(使用波兰语(制作了一个简单的text_to_speech函数。

import pyttsx3 as tts
engine = tts.init()
engine.setProperty('rate', 130)
engine.setProperty('voice', 'polish')
def text_to_speech(text):
engine.say(text)
engine.runAndWait()

当我在windows上运行这个程序时,声音是可以忍受的,但在linux中听起来很刺耳(两台机器上的windows 10和ubuntu 18.04,pyttsx==2.9(。

我还制作了循环打印所有可用的声音:

voices = engine.getProperty('voices')
for voice in voices:
print("Voice:")
print("ID: %s" %voice.id)
print("Name: %s" %voice.name)
print("Age: %s" %voice.age)
print("Gender: %s" %voice.gender)
print("Languages Known: %s" %voice.languages)

窗口输出:

Voice: ID: HKEY_LOCAL_MACHINESOFTWAREMicrosoftSpeechVoicesTokensTTS_MS_PL-PL_PAULINA_11.0 Name: Microsoft Paulina Desktop - Polish Age: None Gender: None Languages Known: [] Voice: ID: HKEY_LOCAL_MACHINESOFTWAREMicrosoftSpeechVoicesTokensTTS_MS_EN-US_ZIRA_11.0 Name: Microsoft Zira Desktop - English (United States) Age: None Gender: None Languages Known: []

linux下的输出:

Voice:
ID: english-us
Name: english-us
Age: None
Gender: male
Languages Known: [b'\x02en-us']
Voice:
ID: polish
Name: polish
Age: None
Gender: male
Languages Known: [b'\x05pl']
Voice:
ID: brazil
Name: brazil
Age: None
Gender: male
Languages Known: [b'\x05pt-br']

and a lot of other languages
(...)

有没有办法在linux版本的pyttsx3(或者其他库(上安装其他抛光声音?

好吧,我发现名为sapi5的windows合成器可能无法转移到linux。

来自pyttsx3文档:

pyttsx3的2.6版本包括以下文本到语音合成器的驱动程序。只列出了驱动程序经过测试且已知可以工作的操作系统。驱动程序可能在其他系统上工作。

  • WindowsXP、WindowsVista和Windows8,8.1、10上的SAPI5
  • Mac OS X 10.5(Leopard(和10.6(Snow Leopard
  • Ubuntu桌面版8.10(Intrepid(、9.04(Jaunty(和9.10(Karmic(上的espeak

但我也发现有一个库gTTS在linux上支持听起来很好的抛光语音:(

最新更新