-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsay.cpp
42 lines (33 loc) · 943 Bytes
/
say.cpp
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
//
// say.exe - copyright (c) 2006 by Antoni Sawicki <as@tenoware.com>;
//
#include <windows.h>
#include <sapi.h>
#include <wchar.h>
#pragma comment(lib,"ole32")
int wmain(int argc, WCHAR **argv) {
WCHAR buff[8192];
int n;
ISpVoice *pVoice = NULL;
for(n=1; n<argc; n++) {
if(wcslen(buff) + wcslen(argv[n]) + 2 > ARRAYSIZE(buff))
break;
wcscat(buff, argv[n]);
wcscat(buff, L" ");
}
if(!wcslen(buff)) {
wprintf(L"Copyright (c) 2006 by Antoni Sawicki <as@tenoware.com>\n\nusage: say.exe <text to say>\n\n");
return 1;
}
if(FAILED(::CoInitialize(NULL))) {
wprintf(L"ERROR: Unable to initialize SAPI\n\n");
return 2;
}
if(SUCCEEDED(CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice))) {
pVoice->Speak(buff, 0, NULL);
pVoice->Release();
pVoice=NULL;
}
::CoUninitialize();
return 0;
}