int main(int argc, char **argv) { int i; int phonetic = 0; char* wavfilename = NULL; unsigned char input[256]; memset(input, 0, 256); if (argc <= 1) { PrintUsage(); return 1; } i = 1; while(i < argc) { if (argv[i][0] != '-') { strcat_s((char*)input, 256, argv[i]); strcat_s((char*)input, 256, " "); } else { if (strcmp(&argv[i][1], "wav")==0) { wavfilename = argv[i+1]; i++; } else if (strcmp(&argv[i][1], "sing")==0) { EnableSingmode(); } else if (strcmp(&argv[i][1], "phonetic")==0) { phonetic = 1; } else if (strcmp(&argv[i][1], "debug")==0) { debug = 1; } else if (strcmp(&argv[i][1], "pitch")==0) { SetPitch((unsigned char)min(atoi(argv[i+1]),255)); i++; } else if (strcmp(&argv[i][1], "speed")==0) { SetSpeed((unsigned char)min(atoi(argv[i+1]),255)); i++; } else if (strcmp(&argv[i][1], "mouth")==0) { SetMouth((unsigned char)min(atoi(argv[i+1]),255)); i++; } else if (strcmp(&argv[i][1], "throat")==0) { SetThroat((unsigned char)min(atoi(argv[i+1]),255)); i++; } else { PrintUsage(); return 1; } } i++; } //while for(i=0; input[i] != 0; i++) input[i] = (unsigned char)toupper((int)input[i]); if (debug) { if (phonetic) printf("phonetic input: %s\n", input); else printf("text input: %s\n", input); } if (!phonetic) { strcat_s((char*)input, 256, "["); if (!TextToPhonemes(input)) return 1; if (debug) printf("phonetic input: %s\n", input); } else strcat_s((char*)input, 256, "\x9b"); #ifdef USESDL if ( SDL_Init(SDL_INIT_AUDIO) < 0 ) { printf("Unable to init SDL: %s\n", SDL_GetError()); exit(1); } atexit(SDL_Quit); #endif SetInput(input); if (!SAMMain()) { PrintUsage(); return 1; } if (wavfilename != NULL) WriteWav(wavfilename, GetBuffer(), GetBufferLength()/50); else OutputSound(); return 0; }
int main(int argc, char **argv) { int i; int debug = 0; int phonetic = 0; int wavfilenameposition = -1; char input[256]; for(i=0; i<256; i++) input[i] = 0; if (argc <= 1) { printUsage(); return 1; } input[0]=0; strcat(input, " "); i = 1; while(i < argc) { if (argv[i][0] != '-') { strcat(input, argv[i]); strcat(input, " "); } else { if (strcmp(&argv[i][1], "wav")==0) { wavfilenameposition = i+1; i++; } else if (strcmp(&argv[i][1], "sing")==0) { EnableSingmode(1); } else if (strcmp(&argv[i][1], "phonetic")==0) { phonetic = 1; } else if (strcmp(&argv[i][1], "debug")==0) { debug = 1; } else if (strcmp(&argv[i][1], "pitch")==0) { SetPitch(atoi(argv[i+1])); i++; } else if (strcmp(&argv[i][1], "speed")==0) { SetSpeed(atoi(argv[i+1])); i++; } else if (strcmp(&argv[i][1], "mouth")==0) { SetMouth(atoi(argv[i+1])); i++; } else if (strcmp(&argv[i][1], "throat")==0) { SetThroat(atoi(argv[i+1])); i++; } else { printUsage(); return 1; } } i++; } //while strcat(input, " "); for(i=0; input[i] != 0; i++) input[i] = toupper(input[i]); if (debug) { printf("say: %s\n", input); } if (!phonetic) { if (!TextToPhonemes(input)) return 1; if (debug) printf("text translation: %s\n", input); } strcat(input, " \x9b\0"); #ifdef USESDL if ( SDL_Init(SDL_INIT_AUDIO) < 0 ) { printf("Unable to init SDL: %s\n", SDL_GetError()); exit(1); } atexit(SDL_Quit); #endif SetInput(input); if (!Code39771()) { printUsage(); return 1; } if (wavfilenameposition > 0) WriteWav(argv[wavfilenameposition], GetBuffer(), GetBufferLength()/50); else { #ifdef USESDL OutputSound(); #endif } if (debug) PrintDebug(); return 0; }