不废话,直接上代码,例子是读取日语文本进行朗读。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

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

被折叠的 条评论
为什么被折叠?



