伊地知ニジカ放送局だぬ゛ん゛. https://www.youtube.com/@deerjika
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.5 KiB

  1. /*-------------------------------------------------------------
  2. Kanji2KoeCmd - かな漢字混じりテキストを音声記号列に変換
  3. $ Kanji2KoeCmd (dic_dir) < in.txt > out.koe
  4. ■ビルド(GCC 5.1以上の環境が必要)
  5. $ ln -sf ../lib64/libAqKanji2Koe.so.4.0 ./libAqKanji2Koe.so.4
  6. $ ln -sf ../lib64/libAqKanji2Koe.so.4.0 ./libAqKanji2Koe.so
  7. $ g++ -I./lib64 -o Kanji2KoeCmd Kanji2KoeCmd.cpp -L. -lAqKanji2Koe
  8. ■実行
  9. $ echo 音声合成テスト | LD_LIBRARY_PATH=. ./Kanji2KoeCmd ../aq_dic
  10. ■ライブラリの配置
  11. libAqKanji2Koe.so.X.Xを他のアプリからも呼び出す場合は、
  12. ldconfigコマンドで共有ライブラリに登録する。
  13. 詳しくは、本ライブラリのマニュアルの「ライブラリ配置」を参照
  14. ■辞書の配置(デフォルト)
  15. |- Kanji2KoeCmd
  16. |- aq_dic/ 辞書フォルダ(aq_dic)を同じディレクトリに配置
  17. |- aqdic.bin
  18. |- aq_user.dic (ユーザ辞書:任意)
  19. OE
  20. |- CREDITS
  21. 2011/01/14 N.Yamazaki Creation
  22. 2019/03/05 N.Yamazaki Ver.4用に一部修正
  23. -------------------------------------------------------------*/
  24. #include <stdio.h>
  25. #include <stdlib.h>
  26. #include <string.h>
  27. #include <locale.h> // setlocale()
  28. #include "AqKanji2Koe.h"
  29. #define NSTR 4096
  30. char * GetPathDic(const char *pathModule);
  31. int main(int ac, char **av)
  32. {
  33. int iret;
  34. char kanji[NSTR];
  35. char koe[NSTR];
  36. void *hAqKanji2Koe;
  37. // 開発ライセンスキー(ライセンス証に記載)の設定
  38. // iret = AqKanji2Koe_SetDevKey("XXX-XXX-XXX");
  39. if(ac==1){
  40. char *pPathDic = GetPathDic(av[0]);
  41. hAqKanji2Koe = AqKanji2Koe_Create(pPathDic, &iret);
  42. free(pPathDic);
  43. }
  44. else {
  45. hAqKanji2Koe = AqKanji2Koe_Create(av[1], &iret);
  46. }
  47. if(hAqKanji2Koe==0){
  48. fprintf(stderr, "ERR: can not initialize Dictionary(%d)\n", iret);
  49. fprintf(stderr, "USAGE: $ Kanji2KoeCmd (dic_dir) < in.txt > out.koe\n");
  50. return iret;
  51. }
  52. int i;
  53. for(i=0; ; i++){
  54. if(fgets(kanji, NSTR, stdin)==0) break;
  55. iret = AqKanji2Koe_Convert(hAqKanji2Koe, kanji, koe, NSTR);
  56. if(iret!=0) {
  57. fprintf(stderr, "ERR: AqKanji2Koe_Convert()=%d\n", iret);
  58. break;
  59. }
  60. fprintf(stdout, "%s\n", koe);
  61. }
  62. AqKanji2Koe_Release(hAqKanji2Koe);
  63. return 0;
  64. }
  65. char * GetPathDic(const char *pathModule)
  66. {
  67. char *p = strrchr((char*)pathModule, '/');
  68. if(p==NULL){
  69. return strdup("./aq_dic");
  70. }
  71. char *path = (char*)malloc(strlen(pathModule)+strlen("/aq_dic")+1);
  72. strncpy(path, pathModule, p-pathModule);
  73. strcpy(path+(p-pathModule), "/aq_dic");
  74. return path;
  75. }