int main(int ac, char **av) { int iret; int i, j; char kanji[NSTR]; char koe[NSTR]; char koer[NSTR]; void* hAqKanji2Koe; if(ac==1){ char* pPathDic = GetPathDic(av[0]); hAqKanji2Koe = AqKanji2Koe_Create(pPathDic, &iret); free(pPathDic); } else { hAqKanji2Koe = AqKanji2Koe_Create(av[1], &iret); } if(hAqKanji2Koe==0){ fprintf(stderr, "ERR: can not initialize Dictionary(%d)\n", iret); fprintf(stderr, "USAGE: $ Kanji2KoeCmd (dic_dir) < in.txt > out.koe\n"); return iret; } for(i=0; ; i++){ if(fgets(kanji, NSTR, stdin)==0) break; iret = AqKanji2Koe_Convert(hAqKanji2Koe, kanji, koe, NSTR); if(iret!=0) { fprintf(stderr, "ERR: AqKanji2Koe_Convert()=%d\n", iret); break; } // fprintf(stdout, "original: %s\n", koe); int rres = replace_utf8(koe, "ー", "-"); if (rres < 0) goto replace_utf8_failed; rres = replace_utf8(koe, "?", "?"); if (rres < 0) { replace_utf8_failed: fprintf(stderr, "ERR: replace_utf8 failed.\n", iret); exit(1); } // fprintf(stdout, "original2: %s\n", koe); koer[0] = 0; int res = str2romaji(koe, koer, NSTR); // fprintf(stdout, "romaji: %d %s\n", res, koer); fprintf(stdout, "%s\n", koer); } AqKanji2Koe_Release(hAqKanji2Koe); return 0; }
int main(int argc, char *argv[]) { int size; int nErr=0; char buf[1024]; char *phont_path = NULL; if (argc == 2) { GRand *g_rnd = g_rand_new(); int nphont = g_rand_int_range(g_rnd, 0, 10); g_print("%d\n", nphont); phont_path = phont_files[nphont]; } else if (argc == 3){ phont_path = argv[2]; }else { printf ("HelloTalk [talk string] [phont file path]"); return 0; } void* p=AqKanji2Koe_Create("./aq_dic", &nErr); if (p==NULL){ printf("error\n"); } AqKanji2Koe_Convert(p, argv[1], buf, 1024); printf("%s\n", buf); GError *perr = NULL; GMappedFile *gmap=NULL; g_print("%s\n", phont_path); gmap = g_mapped_file_new(phont_path, FALSE, &perr); if (gmap!=NULL){ gchar *pc = g_mapped_file_get_contents(gmap); AquesTalk2Da_PlaySync(buf, 100, pc); g_mapped_file_free(gmap); } AqKanji2Koe_Release(p); return 0; }
int main(int ac, char **av) { int iret; // ロケールの設定(ファイルの入出力にwchar_tを使うために必要) setlocale(LC_ALL, "") ; // 辞書ファイルをメモリにマップ void *pSysDic; void *pUserDic; loadDic(av[1], &pSysDic, &pUserDic); if(pSysDic==0) return 1; // load error // AqKanji2Koe初期化(インスタンス生成) void *hAqKanji2Koe = AqKanji2Koe_Create_Ptr(pSysDic, pUserDic, &iret); if(hAqKanji2Koe==0) return iret; for(;;){ wchar_t wch[1024]; if(fgetws(wch, 1024, stdin)==0) break; // 解析 wchar_t wKoe[1024]; iret =AqKanji2Koe_ConvertW(hAqKanji2Koe, wch, wKoe, 1024); //入出力はUTF16(LE) if(iret!=0) break; // error std::wcout << wKoe << std::endl; } // AqKanji2Koe解放 AqKanji2Koe_Release(hAqKanji2Koe); // 辞書データ解放 // メモリマップトファイルのunmapは、CAqMmapのデストラクタで呼ばれる return iret; }
int main(int ac, char **av) { int iret; char kanji[NSTR]; char koe[NSTR]; void *hAqKanji2Koe; if(ac==1){ char *pPathDic = GetPathDic(av[0]); hAqKanji2Koe = AqKanji2Koe_Create(pPathDic, &iret); free(pPathDic); } else { hAqKanji2Koe = AqKanji2Koe_Create(av[1], &iret); } if(hAqKanji2Koe==0){ fprintf(stderr, "ERR: can not initialize Dictionary(%d)\n", iret); fprintf(stderr, "USAGE: $ Kanji2KoeCmd (dic_dir) < in.txt > out.koe\n"); return iret; } int i; for(i=0; ; i++){ if(fgets(kanji, NSTR, stdin)==0) break; iret = AqKanji2Koe_Convert(hAqKanji2Koe, kanji, koe, NSTR); if(iret!=0) { fprintf(stderr, "ERR: AqKanji2Koe_Convert()=%d\n", iret); break; } fprintf(stdout, "%s\n", koe); } AqKanji2Koe_Release(hAqKanji2Koe); return 0; }