src/festival_interface.c
changeset 0 06dd3b8d90ad
equal deleted inserted replaced
-1:000000000000 0:06dd3b8d90ad
       
     1 /**
       
     2  *  $Id: festival_interface.c 53 2008-01-10 00:19:41Z mbroeker $
       
     3  * $URL: http://localhost/svn/c/VirtualReader/trunk/src/festival_interface.c $
       
     4  */
       
     5 
       
     6 #ifdef FESTIVAL
       
     7 #include <festival_interface.h>
       
     8 
       
     9 ttshandles interface_init (tts_options t_options)
       
    10 {
       
    11     ttshandles handle;
       
    12 
       
    13     return handle;
       
    14 }
       
    15 
       
    16 long *interface_get_timing (ttshandles tts, char *text)
       
    17 {
       
    18     int i;
       
    19     long *t = NULL;
       
    20 
       
    21     for (i = 0; i < strlen (text); i++) {
       
    22         t = realloc (t, (i + 2) * sizeof (long));
       
    23         t[i] = i * 20 + 10;
       
    24     }
       
    25 
       
    26     t[i] = 0;
       
    27     return t;
       
    28 };
       
    29 
       
    30 int interface_write_to_wav (char *fname, char *text, ttshandles t_handles, tts_options t_options)
       
    31 {
       
    32     char *s = NULL;
       
    33 
       
    34     if ((s = malloc (strlen (text) + 80)) == NULL)
       
    35         return -1;
       
    36 
       
    37     sprintf (s, "printf \"%s\" | bin/festival_write_wav - %s", text, fname);
       
    38 #ifdef DEBUG
       
    39     printf ("Writing %s\n", fname);
       
    40 #endif
       
    41     system (s);
       
    42 
       
    43     if (s != NULL)
       
    44         free (s);
       
    45     return 0;
       
    46 }
       
    47 
       
    48 tts_options interface_get_cl_opts (int num, char **arguments)
       
    49 {
       
    50     tts_options options = { 0, 0, 0, 0 };
       
    51     int c;
       
    52 
       
    53     while ((c = getopt (num, arguments, "p:v:i:")) > 0) {
       
    54         switch (c) {
       
    55         case 'p':
       
    56             options.Path = optarg;
       
    57             break;
       
    58         case 'v':
       
    59             options.Voice = optarg;
       
    60             break;
       
    61         case 'i':
       
    62             options.TextFile = optarg;
       
    63             break;
       
    64         }
       
    65     }
       
    66 
       
    67     if (options.TextFile == NULL) {
       
    68         fprintf (stderr, "It's substantial to give a text file by -i <text file>!\n");
       
    69         exit (0);
       
    70     }
       
    71 
       
    72     return options;
       
    73 }
       
    74 
       
    75 #endif