简单语音测试(TTS)接口库,支持多种语言和多引擎。
talke的Python项目详细描述
简单文本到语音(TTS)接口库,支持多种语言和多引擎。
文档:http://talkey.readthedocs.org/
基本原理
我对jasper的概念非常感兴趣,jasper是一个语音控制接口。 我需要它像我一样多语种,所以这个图书馆是我的尝试 多语种TTS引擎。这段代码的很多灵感来自jasper项目。
基本用法
从pypi安装:
pip install talkey
在最简单的用例中:
importtalkeytts=talkey.Talkey()tts.say('Old McDonald had a farm')
如果出现talkey.base.TTSError: No supported languages错误,则表示没有安装受支持的tts引擎。请看下面。
默认情况下,它将尝试查找并使用以下TTS引擎的本地实例:
- 飞行
- 斯沃克斯皮科
- 节日
- 埃斯皮克
- mbrola via espeak
安装其中一个或多个引擎应允许libary运行并生成语音。
它还支持以下联网的TTS引擎:
- Marytts(需要托管)
- 谷歌TTS(云托管)
为了获得最佳效果,您应该对其进行配置:
importtalkeytts=talkey.Talkey(# These languages are given better scoring by the language detector# to minimise the chance of it detecting a short string completely incorrectly.# Order is not important herepreferred_languages=['en','af','el','fr'],# The factor by which preferred_languages gets their score increased, defaults to 80.0preferred_factor=80.0,# The order of preference of using a TTS engine for a given language.# Note, that networked engines (Google, Mary) is disabled by default, and so is dummy# default: ['google', 'mary', 'espeak', 'festival', 'pico', 'flite', 'dummy']# This sets eSpeak as the preferred engine, the other engines may still be used# if eSpeak doesn't support a requested language.engine_preference=['espeak'],# Here you segment the configuration by engine# Key is the engine SLUG, in this case ``espeak``espeak={# Specify the engine options:'options':{'enabled':True,},# Specify some default voice options'defaults':{'words_per_minute':150,'variant':'f4',},# Here you specify language-specific voice options# e.g. for english we prefer the mbrola en1 voice'languages':{'en':{'voice':'english-mb-en1','words_per_minute':130},}})tts.say('Old McDonald had a farm')
安装TTS发动机
ubuntu/debian:
节日:
sudo apt-get install festival
对于飞行物:
sudo apt-get install flite
对于SVox Pico:
sudo apt-get install libttspico-utils
对于espeak:
sudo apt-get install espeak
对于mbrola和en1语音:
sudo apt-get install mbrola-en1
窗口:
安装espeak:
Go to http://espeak.sourceforge.net/download.html and download and install ^{tt2}$
对于mbrola及其声音:
Go to http://espeak.sourceforge.net/mbrola.html and download and install ^{tt3}$ and follow directions to install voices from http://www.tcts.fpms.ac.be/synthesis/mbrola/mbrcopybin.html
对于google tts:
install python package gTTS
Download ffmpeg from http://ffmpeg.zeranoe.com/builds/
Extract with 7Zip, and add the bin folder to the PATH.
- e.g.:
- extract to C:ffmpeg and add C:ffmpegbin to the PATH
(In cmd.exe you should be able to just run ffmpeg and see it showing information, then it is working right)