mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
Remove further ATL dependency in Windows speech recognizer
This commit is contained in:
parent
adf168b7ea
commit
627dad88cb
2 changed files with 20 additions and 8 deletions
|
@ -12,8 +12,6 @@
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include <sphelper.h>
|
|
||||||
|
|
||||||
#include "SpeechRecognizer.h"
|
#include "SpeechRecognizer.h"
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
|
@ -79,11 +77,28 @@ void SpeechRecognizer::setEnabled(bool enabled) {
|
||||||
hr = CoCreateInstance(CLSID_SpInprocRecognizer, NULL, CLSCTX_ALL, IID_ISpRecognizer, (void**)&_speechRecognizer);
|
hr = CoCreateInstance(CLSID_SpInprocRecognizer, NULL, CLSCTX_ALL, IID_ISpRecognizer, (void**)&_speechRecognizer);
|
||||||
}
|
}
|
||||||
if (SUCCEEDED(hr)) {
|
if (SUCCEEDED(hr)) {
|
||||||
CComPtr<ISpObjectToken> cpAudioToken;
|
ISpObjectToken* audioToken;
|
||||||
hr = SpGetDefaultTokenFromCategoryId(SPCAT_AUDIOIN, &cpAudioToken);
|
ISpObjectTokenCategory* audioTokenCategory;
|
||||||
|
hr = CoCreateInstance(CLSID_SpObjectTokenCategory, NULL, CLSCTX_ALL, IID_ISpObjectTokenCategory,
|
||||||
|
(void**)&audioTokenCategory);
|
||||||
if (SUCCEEDED(hr)) {
|
if (SUCCEEDED(hr)) {
|
||||||
hr = static_cast<ISpRecognizer*>(_speechRecognizer)->SetInput(cpAudioToken, TRUE);
|
hr = audioTokenCategory->SetId(SPCAT_AUDIOIN, TRUE);
|
||||||
}
|
}
|
||||||
|
if (SUCCEEDED(hr)) {
|
||||||
|
WCHAR * tokenID;
|
||||||
|
hr = audioTokenCategory->GetDefaultTokenId(&tokenID);
|
||||||
|
if (SUCCEEDED(hr)) {
|
||||||
|
hr = CoCreateInstance(CLSID_SpObjectToken, NULL, CLSCTX_ALL, IID_ISpObjectToken, (void**)&audioToken);
|
||||||
|
if (SUCCEEDED(hr)) {
|
||||||
|
hr = audioToken->SetId(NULL, tokenID, FALSE);
|
||||||
|
}
|
||||||
|
::CoTaskMemFree(tokenID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (SUCCEEDED(hr)) {
|
||||||
|
hr = static_cast<ISpRecognizer*>(_speechRecognizer)->SetInput(audioToken, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (SUCCEEDED(hr)) {
|
if (SUCCEEDED(hr)) {
|
||||||
hr = static_cast<ISpRecognizer*>(_speechRecognizer)
|
hr = static_cast<ISpRecognizer*>(_speechRecognizer)
|
||||||
|
|
|
@ -18,9 +18,6 @@
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
#include <QWinEventNotifier>
|
#include <QWinEventNotifier>
|
||||||
|
|
||||||
//#include <atlbase.h>
|
|
||||||
//#include <sapi.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class SpeechRecognizer : public QObject {
|
class SpeechRecognizer : public QObject {
|
||||||
|
|
Loading…
Reference in a new issue