voicetext.c
Go to the documentation of this file.
00001 /***********************************************
00002  * Tts sample program
00003  * made by voiceware, 2006.02.24
00004  * modified by k-okada 2012.04.04
00005  ***********************************************/
00006 #include <stdio.h>
00007 #include <stdlib.h>
00008 #include <string.h>
00009 #include <unistd.h>
00010 
00011 #include "/usr/vt/sayaka/M16/inc/vt_jpn.h"
00012 
00013 int main(int argc, char *argv[])
00014 {
00015   int infoval;
00016   FILE *fp;
00017   char input_string[65536];
00018   char  input_fname[1024]="";
00019   char output_fname[1024]="/tmp/toFile.wav";
00020 
00021   int ch;
00022   extern char *optarg;
00023   extern int optind, opterr;
00024 
00025   while ((ch = getopt(argc, argv, "o:")) != -1) {
00026     switch (ch) {
00027     case 'o':
00028       strncpy(output_fname,optarg,1024);
00029       break;
00030     default:
00031       fprintf(stderr, "Usage : %s [-o output_file] [intput_file]\n", argv[0]);
00032       exit(1);
00033     }
00034   }
00035   if (optind < argc ) {
00036     strncpy(input_fname,argv[optind],1024);
00037   }
00038   fprintf(stderr, "[INFO  %s] Input file  : %s\n", argv[0], input_fname);
00039   fprintf(stderr, "[INFO  %s] Output file : %s\n", argv[0], output_fname);
00040 
00041   if (( fp = fopen(input_fname, "r") ) == NULL ) {
00042     fprintf(stderr, "[ERROR %s] File open error %s\n", argv[0], input_fname); 
00043     exit(1);
00044   }
00045   while (fgets(input_string+strlen(input_string), 65536-strlen(input_string),fp)!=NULL) ;
00046 
00047 
00048   /****************************************/
00049   /* Tts Initialize                       */
00050   /* Call Vtprintf("%s",buf);
00051 _Loadtts_Jpn ()               */
00052   /****************************************/
00053   if (VT_GetTTSInfo_JPN(VT_LOAD_SUCCESS_CODE, NULL, &infoval, sizeof(int)) != VT_INFO_SUCCESS) exit(1);
00054   if (VT_LOADTTS_JPN((int)NULL, -1, "/usr/vt/sayaka/M16/", NULL) != infoval) exit(1);
00055 
00056 
00057   /****************************************/
00058   /* TTS File API                              */
00059   /* call VT_TextToFile_JPN ()               */
00060   /****************************************/
00061   if (VT_TextToFile_JPN (VT_FILE_API_FMT_S16PCM_WAVE , input_string, output_fname, -1, -1, -1, -1, -1, -1, -1) != VT_FILE_API_SUCCESS)
00062     VT_UNLOADTTS_JPN (-1), exit (1);
00063 
00064   /****************************************/
00065   /* TTS Exit                                   */
00066   /* call VT_UNLOADTTS_JPN ()                */
00067   /****************************************/
00068   VT_UNLOADTTS_JPN (-1);
00069   exit (0);
00070 }


voice_text
Author(s): k-okada
autogenerated on Mon Oct 6 2014 11:05:20