src/mbrola_interface.c
changeset 0 06dd3b8d90ad
equal deleted inserted replaced
-1:000000000000 0:06dd3b8d90ad
       
     1 /**
       
     2  *  $Id: mbrola_interface.c 53 2008-01-10 00:19:41Z mbroeker $
       
     3  * $URL: http://localhost/svn/c/VirtualReader/trunk/src/mbrola_interface.c $
       
     4  */
       
     5 
       
     6 #ifdef MBROLA
       
     7 #include <mbrola_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     long *t = NULL;
       
    19     int i = 0;
       
    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 #ifdef DEBUG
       
    26     printf ("\nTiming analysis ends\n");
       
    27 #endif
       
    28 
       
    29     t[i] = 0;
       
    30 
       
    31     return t;
       
    32 };
       
    33 
       
    34 int interface_write_to_wav (char *fname, char *text, ttshandles t_handles, tts_options t_options)
       
    35 {
       
    36     char *s = NULL;
       
    37 
       
    38     if ((s = malloc (strlen (text) + 80)) == NULL)
       
    39         return -1;
       
    40 
       
    41     sprintf (s, "printf \"%s\" | bin/mbrola_write_wav - %s", text, fname);
       
    42 #ifdef DEBUG
       
    43     printf ("Writing %s\n", fname);
       
    44 #endif
       
    45     system (s);
       
    46 
       
    47     if (s != NULL)
       
    48         free (s);
       
    49     return 0;
       
    50 }
       
    51 
       
    52 tts_options interface_get_cl_opts (int num, char **arguments)
       
    53 {
       
    54     tts_options options = { 0, 0, 0, 0 };
       
    55     int c;
       
    56 
       
    57     while ((c = getopt (num, arguments, "p:v:i:")) > 0) {
       
    58         switch (c) {
       
    59         case 'p':
       
    60             options.Path = optarg;
       
    61             break;
       
    62         case 'v':
       
    63             options.Voice = optarg;
       
    64             break;
       
    65         case 'i':
       
    66             options.TextFile = optarg;
       
    67             break;
       
    68         }
       
    69     }
       
    70 
       
    71     if (options.TextFile == NULL) {
       
    72         fprintf (stderr, "It's substantial to give a text file by -i <text file>!\n");
       
    73         exit (0);
       
    74     }
       
    75 
       
    76     return options;
       
    77 }
       
    78 
       
    79 #endif