// Test program for Fluency API #include #include "Windows.h" #include "FluencyAPI.h" bool fluencyDone; void WINAPI FLUENCYSYNC(unsigned Event, unsigned Param1, unsigned Param2, unsigned User) { switch (Event) { case SYNC_START: //printf("start\n"); break; case SYNC_PROGRESS: break; case SYNC_FINISH: //printf("\nfinish\n"); fluencyDone = TRUE; break; case SYNC_PHONEME: char p[3]; p[0] = (char)Param1; p[1] = (char)(Param1 >> 8); p[2] = (char)0; printf("%s ", p); break; } } void main(void) { HINSTANCE hFluencyDLL; char Path[250]; char Wrd[100]; char NextWrd[100]; char Transcription[100]; int Voices; int i; char VoiceName[200]; void *Voice; void *Channel; char *Phone; void *Wav; unsigned TextIndex; unsigned Samples; unsigned WordLength; MSG Msg; // load DLL hFluencyDLL = fluencyLoadDLL(""); if (hFluencyDLL) { // test GetVersion (can be called before Initialize) printf("Welkom bij Fluency TTS %d.%d\n", fluencyGetMajorVersion(), fluencyGetMinorVersion()); // initialize if (fluencyInitialize()) { // test AboutWindow //fluencyAboutWindow((HWND)0); // test fluencyGetUserDataPath fluencyGetUserDataPath(Path, 250); printf("\nMap waar instellingen worden opgeslagen:\n%s\n", Path); // test fluencyLookupWord fluencyLookupWord("leuk", Transcription, 100); printf("\n\nTest fluencyLookupWord()\nleuk=%s\n", Transcription); // test fluencyUserLexiconNextWord printf("\nTest fluencyUserLexiconNextWord()\n"); Wrd[0] = '\0'; while (fluencyUserLexiconNextWord(Wrd, NextWrd, 100)) { printf("%s ", NextWrd); strcpy(Wrd, NextWrd); } printf("\n"); // test enumerate voices Voices = fluencyGetVoiceCount(); printf("\n%d stemmen:\n", Voices); for (i=1; i <= Voices; i++) { fluencyGetVoiceName(i, VoiceName, 200); printf("%s ", VoiceName); } // get preferred voice fluencyGetPreferredVoiceName(VoiceName, 200); printf("\n\nGekozen stem: %s\n", VoiceName); // create voice and channel Voice = fluencyCreateVoice(VoiceName); Channel = fluencyCreateChannel(Voice, 22050, TRUE); // test fluencyGetPhone() printf("\nTest met fluencyGetPhone()\n"); fluencySetInputText(Channel, "Hallo, dit is een test voor Fluency TTS"); while (fluencyGetPhone(Channel, &Phone, &Samples, &Wav, &TextIndex, &WordLength)) { printf("%s ", Phone); } // test set tempo/volume/balance fluencySetTempo(Channel, -4); fluencySetVolume(Channel, 40); fluencySetBalance(Channel, -60); // test fluencySpeakToFile() printf("\n\nTest met fluencySpeakToFile()\n"); fluencyDone = FALSE; fluencySetInputText(Channel, "Hallo, dit is een test voor Fluency TTS"); fluencySpeakToFile(Channel, "tmp.wav", &FLUENCYSYNC, 0); // sleep while Fluency TTS is writing to file while (!fluencyDone) Sleep(10); // test fluencySpeak() printf("\n\nTest met fluencySpeak()\n"); fluencyDone = FALSE; fluencySetInputText(Channel, "Hallo, dit is een test voor Fluency TTS"); fluencySpeak(Channel, &FLUENCYSYNC, 0); // important: keep a message loop running while Fluency TTS is speaking while ((!fluencyDone) && (GetMessage(&Msg, 0, 0, 0))) { TranslateMessage(&Msg); DispatchMessage(&Msg); } // clean up fluencyDeleteChannel(Channel); fluencyDeleteVoice(Voice); fluencyClose(); } // free dll FreeLibrary(hFluencyDLL); } }