flitevox_info_main.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*************************************************************************/
  2. /* */
  3. /* Language Technologies Institute */
  4. /* Carnegie Mellon University */
  5. /* Copyright (c) 2014 */
  6. /* All Rights Reserved. */
  7. /* */
  8. /* Permission is hereby granted, free of charge, to use and distribute */
  9. /* this software and its documentation without restriction, including */
  10. /* without limitation the rights to use, copy, modify, merge, publish, */
  11. /* distribute, sublicense, and/or sell copies of this work, and to */
  12. /* permit persons to whom this work is furnished to do so, subject to */
  13. /* the following conditions: */
  14. /* 1. The code must retain the above copyright notice, this list of */
  15. /* conditions and the following disclaimer. */
  16. /* 2. Any modifications must be clearly marked as such. */
  17. /* 3. Original authors' names are not deleted. */
  18. /* 4. The authors' names are not used to endorse or promote products */
  19. /* derived from this software without specific prior written */
  20. /* permission. */
  21. /* */
  22. /* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
  23. /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
  24. /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
  25. /* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
  26. /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
  27. /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
  28. /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
  29. /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
  30. /* THIS SOFTWARE. */
  31. /* */
  32. /*************************************************************************/
  33. /* Author: Alan W Black (awb@cs.cmu.edu) */
  34. /* Date: November 2014 */
  35. /*************************************************************************/
  36. /* */
  37. /* For setting and viewing features in a .flitevox clustergen file */
  38. /* */
  39. /*************************************************************************/
  40. #include <stdio.h>
  41. #include <string.h>
  42. #include <sys/time.h>
  43. #include <unistd.h>
  44. #include "cst_args.h"
  45. #include "flite.h"
  46. void *flite_set_lang_list(void);
  47. int main(int argc, char **argv)
  48. {
  49. cst_features *args=new_features();
  50. cst_voice *v;
  51. const char *voice_name, *feat;
  52. (void)cst_args(argv,argc,
  53. "usage: flitevox_info [OPTIONS]\n"
  54. "-voice <string> Pathname to flitevox file\n"
  55. "-set <string> Set given feature name\n"
  56. "-get <string> Get given feature name\n"
  57. "-val <string> Value to set\n"
  58. "-info Output general info on voice\n"
  59. "set/get features in a flitevox voice.",
  60. args);
  61. flite_init();
  62. flite_set_lang_list();
  63. if (!feat_present(args,"-voice"))
  64. {
  65. fprintf(stderr,"no voice specified\n");
  66. exit(-1);
  67. }
  68. voice_name = feat_string(args,"-voice");
  69. v = flite_voice_load(voice_name);
  70. if (v == NULL)
  71. {
  72. fprintf(stderr,"can't load voice %s\n",voice_name);
  73. exit(-1);
  74. }
  75. if (feat_present(args,"-info"))
  76. {
  77. cst_feat_print(stdout,v->features);
  78. } else if (feat_present(args,"-set"))
  79. {
  80. feat = get_param_string(args,"-set","feat");
  81. if (!feat_present(args,"-val"))
  82. {
  83. fprintf(stderr,"no feat val given for %s\n",feat);
  84. exit(-1);
  85. }
  86. /* set the feature */
  87. feat_set_string(v->features,feat,feat_string(args,"-val"));
  88. /* save the voice back out again */
  89. flite_voice_dump(v,voice_name);
  90. }
  91. else if (feat_present(args,"-get"))
  92. {
  93. feat = get_param_string(args,"-get","feat");
  94. printf("%s \"%s\"\n",feat,feat_string(v->features,feat));
  95. }
  96. return 0;
  97. }