gpt4 book ai didi

C++ sapi : User input, 编辑语音输出

转载 作者:行者123 更新时间:2023-11-28 06:14:41 25 4
gpt4 key购买 nike

#include <sapi.h>
#include <string>
#include <iostream>

//User inputs what is to be said//
int main(int argc, char* argv[])
{
ISpVoice * pVoice = NULL;

if (FAILED(::CoInitialize(NULL)))
return FALSE;

HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);
if (SUCCEEDED(hr))
{
std::wstring input;
while (true)
{
std::cout << "Enter text:\n";
std::getline(std::wcin, input);

hr = pVoice->Speak(input.c_str(), 0, NULL);
}
}
pVoice->Release();
pVoice = NULL;
::CoUninitialize();
return 0;
}

上面的代码允许用户输入他们想要说的内容并且可以完美运行。

以下是 MSDN 中改变音高的方法,任何其他类似的 Action 都是以同样的方式完成的。

hr = pVoice->Speak(L"This sounds normal <pitch middle = '-10'/> but the pitch drops half way through", SPF_IS_XML, NULL );

我想改变音高,但不知道如何使用我的代码执行相同的操作。

最佳答案

你必须像那样集中 XML 指令

std::wstring input;
std::getline(std::wcin, input);
pVoice->Speak(std::wstring(L"<pitch middle = '+10'>"+input).c_str(), 0, 0);

祝你好运!

关于C++ sapi : User input, 编辑语音输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30562625/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com