示例#1
0
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 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;
}
示例#3
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;
}