-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSAPIEngine.h
More file actions
54 lines (40 loc) · 1.31 KB
/
Copy pathSAPIEngine.h
File metadata and controls
54 lines (40 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef __SAPIENGINE_H__
#define __SAPIENGINE_H__
#pragma comment(lib, "sapi.lib")
#include <atlcom.h>
#include <sapi.h>
#include <string>
#include <vector>
class SAPIEngine
{
public:
// Singleton access
static SAPIEngine& getInstance();
// Initialize the SAPI engine for the user's default language
bool initialize();
// Update the SAPI engine
void update();
// Shutdown and cleanup
void shutdown();
// Add a new command to the speech recognition grammar
// Returns the ID assigned to the new command, or -1 on failure
int addCommand(const std::wstring& command);
// Set a callback to inform the client when a word or phrase
// has been recognized by SAPI. The first parameter is the ID
// of the recognized command, as returned when the command was added,
// and the second is the recognized phrase itself.
using SAPICallback = void(*)(int, const std::wstring&);
void setCallback(SAPICallback callbackFunc);
private:
SAPIEngine();
SAPIEngine(const SAPIEngine&); // Not implemented
SAPIEngine& operator=(const SAPIEngine&); // Not implmented
~SAPIEngine();
void onRecognized(const std::wstring& text);
CComPtr<ISpRecoContext> _recoContext;
CComPtr<ISpRecoGrammar> _grammar;
SAPICallback _callback;
std::vector<std::pair<int, std::wstring>> _commands;
int _nextRuleId;
};
#endif // __SAPIENGINE_H__