当前位置:   article > 正文

RHEL7.2上基于eSpeak实现TTS_espeak 中文语音包

espeak 中文语音包

RHEL7.2上已经自带了eSpeak库。

eSpeak是一个小型的、开放源码的语音合成系统,支持多种语言。eSpeak使用共振峰合成方法,这可以使提供的语言文件非常小。该系统支持Windows平台上的SAPI5,所以能用于屏幕阅读程序和其他支持Windows SAPI5接口的程序。eSpeak可以将文本转换成音素代码,因此它也可以用于另一个语音合成引擎的前端。

Mandarin Chinese
This speaks Pinyin text and Chinese characters. There is only a simple one-to-one translation of Chinese characters to a single Pinyin pronunciation. There is no attempt yet at recognising different pronunciations of Chinese characters in context, or of recognising sequences of characters as “words”. The eSpeak installation includes a basic set of Chinese characters. More are available in an additional data file for Mandarin Chinese at: http://espeak.sourceforge.net/data/.

直接上源码:

#include "speak_lib.h"  // 包括espeak的头文件
#include <string.h>
#include <unistd.h>

int main(int argc, char **argv)
{
    // 初始化
    espeak_Initialize(AUDIO_OUTPUT_PLAYBACK, 0, NULL, 0);

    char word[] = "这是我的工作站, 12345";
    // 设置音源为中文女声
    espeak_SetVoiceByName("zh+f2");
    // 发音
    espeak_Synth(word, strlen(word) + 1, 0, POS_CHARACTER, 0, espeakCHARS_UTF8, NULL, NULL);
    // 等一段时间,否则程序会立即退出,听不到发音
    sleep(4);

    char word2[] = "this is my workstation, 12345";
    // 设置音源为英文女声
    espeak_SetVoiceByName("en+f2");
    // 发音
    espeak_Synth(word2, strlen(word2) + 1, 0, POS_CHARACTER, 0, espeakCHARS_UTF8, NULL, NULL);
    // 等一段时间,否则程序会立即退出,听不到发音
    sleep(4);

    // 回收资源
    espeak_Terminate();
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/201517
推荐阅读
相关标签
  

闽ICP备14008679号