微软语音朗读引擎MSSPEECH打造自己的TTS应用

本文介绍了一种使用MSSpeech SDK将日语文本转换为语音的方法,通过C++代码示例展示了如何读取文本文件并用指定的语言和速度参数进行朗读。

不废话,直接上代码,例子是读取日语文本进行朗读。LANGUAGE ID可以改成其他语言的。

#include "pch.h"
#include <Windows.h>
#include <string>
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iostream>
#include <sapi.h>
using namespace std;

int main()
{
	//read speech text
	ifstream input("./speech.txt", ios::in);
	stringstream buffer;
	buffer << input.rdbuf();
	string contents(buffer.str());
	/*
	language id
	411		jpanese
	809		chinese
	409		english
	speech speed
	-10 ~ 10
	*/
	string speech= "<VOICE REQUIRED='LANGUAGE=411' /><rate absspeed='-2' />" + contents;

	/*
		#define CP_ACP                    0           // default to ANSI code page
		#define CP_OEMCP                  1           // default to OEM  code page
		#define CP_MACCP                  2           // default to MAC  code page
		#define CP_THREAD_ACP             3           // current thread's ANSI code page
		#defin
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值