|
|
Programmer with Ekho(updated on May 7, 2011) For Linux PlatformFirst, install Ekho. Second, try following simple example.
/* file try.cpp */
#include "config.h" // this file is generated when building Ekho
#include "ekho.h"
using namespace ekho;
int main(int argc, char **argv) {
Ekho wong("Cantonese");
wong.blockSpeak("123");
return 0;
}
Third, compile and run it. On linux platform, issue following commands (suppose we are under directory of Ekho):
$ g++ try.cpp libekho.a \
lib/libSoundTouch.a lib/libFestival.a lib/libestools.a \
lib/libeststring.a lib/libestbase.a \
-I. -Iutfcpp/source -Isonic -pthread \
-lvorbisenc -lvorbis -lm -logg -lmp3lame -lsndfile -lncurses \
`pkg-config --libs libpulse-simple` \
`pkg-config --cflags libpulse-simple`
$ ./a.out
Then, check ekho.h for API and go ahead. For Windows PlatformYou can use Ekho through SAPI5 on Windows. You need to install the SAPI5 SDK yourself first and read the document about how to use it. Following is a HelloWorld. Note: The Ekho on Windows platform does not support English yet.
#include "stdafx.h"
#include <iostream>
#include <sapi.h>
#include <sphelper.h>
#include <atlcom.h>
using namespace std;
int main ( int NumOfArguments, char** Argument )
{
HRESULT hr = S_OK;
CComPtr<IEnumSpObjectTokens> cpEnum;
ULONG ulCount = 0;
ISpVoice * pSpVoice = NULL;
CComPtr<ISpObjectToken> cpToken;
// Initialize COM
CoInitialize(NULL);
// Create the voice interface object
if (FAILED(CoCreateInstance(CLSID_SpVoice, NULL,
CLSCTX_INPROC_SERVER, IID_ISpVoice, (void **)&pSpVoice))) {
cerr << "Fail to create instance of ISpVoice!" << endl;
return -1;
}
if (FAILED(SpEnumTokens(SPCAT_VOICES, L"Name=Ekho Cantonese", NULL, &cpEnum))) {
cerr << "Fail to get voices!" << endl;
return -1;
}
//Get the closest token
if (FAILED(cpEnum->Next(1, &cpToken, NULL))) {
cerr << "Fail to get voice EkhoVoice!" << endl;
return -1;
}
//set the voice
if (FAILED(pSpVoice->SetVoice( cpToken))) {
cerr << "Fail to set voice EkhoVoice!" << endl;
return -1;
}
pSpVoice->Speak(L"123", SPF_DEFAULT, NULL);
// Shutdown COM
CoUninitialize ();
return 0;
}
Email me (Cameron) or leave messages in the forum for further questions :-) |
|
| Copyright 2006 - 2012, eGuideDog team | |