RHEL7.2上基于eSpeak实现TTS

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
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

皓月如我

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值