shithub: flite

Download patch

ref: e98804740dd0d36ee04d710dc0859d31aa0126a5
parent: b273a40041a0330bd1545316eed63959a6cc4bdd
author: Alan W Black <awb@cs.cmu.edu>
date: Mon Jan 21 04:41:21 EST 2019

post-wilderness fixes

--- /dev/null
+++ b/.time-stamp
@@ -1,0 +1,8 @@
+Festival Lite
+flite
+2.2
+Sep 2018
+current
+awb
+leith
+Tue Sep 11 08:19:34 EDT 2018
--- a/Makefile
+++ b/Makefile
@@ -37,8 +37,8 @@
 ##       Authors:  Alan W Black (awb@cs.cmu.edu)                         ##
 ##                 Kevin A. Lenzo (lenzo@cs.cmu.edu)                     ##
 ##                 and others see ACKNOWLEDGEMENTS                       ##
-##          Date:  Dec 2017                                              ##
-##       Version:  2.1 release                                           ##
+##          Date:  Sep 2018                                              ##
+##       Version:  2.2 current                                           ##
 ##                                                                       ## 
 ###########################################################################
 TOP=.
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
 
          Flite: a small run-time speech synthesis engine
                       version 2.1-release
-          Copyright Carnegie Mellon University 1999-2017
+          Copyright Carnegie Mellon University 1999-2018
                       All rights reserved
                       http://cmuflite.org
               https://github.com/festvox/flite
@@ -137,6 +137,9 @@
 News
 ----
 
+New in 2.2 (Oct 2018)
+    o Better qrapheme support (Wilderness Languages) hundreds of new languages
+    
 New in 2.1 (Oct 2017)
 
     o Improved Indic front end support (thanks to Suresh Bazaj @ Hear2Read)
--- a/config/project.mak
+++ b/config/project.mak
@@ -36,8 +36,8 @@
 ###########################################################################
 PROJECT_NAME = Festival Lite
 PROJECT_PREFIX = flite
-PROJECT_VERSION = 2.1
-PROJECT_DATE = Dec 2017
-PROJECT_STATE = release
+PROJECT_VERSION = 2.2
+PROJECT_DATE = Sep 2018
+PROJECT_STATE = current
 
 PROJECT_SHLIB_VERSION = 1
--- a/include/cst_cg.h
+++ b/include/cst_cg.h
@@ -51,9 +51,10 @@
 #include "cst_wave.h"
 #include "cst_audio.h"
 #include "cst_synth.h" /* for dur_stat */
+#include "cst_phoneset.h" 
 
 /* The parameters in the spectral model(s) may be encoded in various ways */
-/* mostly to preserve space.  The decoded can be dependent on the shape type */
+/* mostly to preserve space.  The decoder can be dependent on the shape type */
 /* This needs to be coordinated with the model creation in make_cg.scm */
 /* This is currently very BIG_HAMMER-like and hard coded */
 
@@ -142,6 +143,11 @@
 
     int spamf0;
     float gain;
+
+    /* If its a "grapheme" voice there will be a phoneset and a char_map */
+    const cst_phoneset *phoneset;
+    const char * const *char_sym_map; /* Unicode char to symbol map */
+    const char * const *sym_phone_map; /* symbol to phone map */
 
     int freeable;  /* doesn't get dumped, but 1 when this a freeable struct */
 
--- a/include/flite_version.h
+++ b/include/flite_version.h
@@ -1,6 +1,6 @@
 #define FLITE_PROJECT_NAME "Festival Lite"
 #define FLITE_PROJECT_PREFIX "flite"
-#define FLITE_PROJECT_VERSION "2.0.7"
-#define FLITE_PROJECT_DATE "Jul 2017"
+#define FLITE_PROJECT_VERSION "2.2"
+#define FLITE_PROJECT_DATE "Sep 2018"
 #define FLITE_PROJECT_STATE "current"
 #define FLITE_PROJECT_SHLIB_VERSION "1"
--- a/lang/cmu_grapheme_lex/cmu_grapheme_lex.c
+++ b/lang/cmu_grapheme_lex/cmu_grapheme_lex.c
@@ -89,6 +89,7 @@
         /* afterwards */
         cst_utf8_as_hex(val_string(val_car(v)),ord);
         phindex = cst_find_u2sampa(ord);
+        printf("awb_debug lookup sampa %s %s\n",val_string(val_car(v)),ord);
 #if 0        
         if (phindex < 0)
             printf("awb_debug no sampa %s %s\n",val_string(val_car(v)),ord);
--- a/lang/cmu_indic_lang/indic_eng_num_table.h
+++ b/lang/cmu_indic_lang/indic_eng_num_table.h
@@ -42,8 +42,133 @@
 
 #include "indic_num_table.h"
 
+#if 0
 static const char * const indic_eng_digit[11][2] =
 {
+    { "0", "शून्य" },
+    { "1", "एक" },
+    { "2", "दोन" },
+    { "3", "तीन" },
+    { "4", "चार" },
+    { "5", "पाच" },
+    { "6", "सहा" },
+    { "7", "सात" },
+    { "8", "आठ" },
+    { "9", "नऊ" },
+    { NULL, NULL },
+};
+
+static const char * const indic_eng_two_digit[101][4] =
+{
+    { "1", "0", "दहा",  NULL },
+    { "1", "1", "अकरा",  NULL },
+    { "1", "2", "बारा",  NULL },
+    { "1", "3", "तेरा",  NULL },
+    { "1", "4", "चौदा",  NULL },
+    { "1", "5", "पंधरा",  NULL },
+    { "1", "6", "सोळा",  NULL },
+    { "1", "7", "सतरा",  NULL },
+    { "1", "8", "अठरा",  NULL },
+    { "1", "9", "एकोणीस",  NULL },
+    { "2", "0", "वीस",  NULL },
+    { "2", "1", "एकवीस",  NULL },
+    { "2", "2", "बावीस",  NULL },
+    { "2", "3", "तेवीस",  NULL },
+    { "2", "4", "चोवीस",  NULL },
+    { "2", "5", "पंचवीस",  NULL },
+    { "2", "6", "सव्वीस",  NULL },
+    { "2", "7", "सत्तावीस",  NULL },
+    { "2", "8", "अठ्ठावीस",  NULL },
+    { "2", "9", "एकोणतीस",  NULL },
+    { "3", "0", "तीस",  NULL },
+    { "3", "1", "एकतीस",  NULL },
+    { "3", "2", "बत्तीस",  NULL },
+    { "3", "3", "तेहेतीस",  NULL },
+    { "3", "4", "चौतीस",  NULL },
+    { "3", "5", "पस्तीस",  NULL },
+    { "3", "6", "छत्तीस",  NULL },
+    { "3", "7", "सदतीस",  NULL },
+    { "3", "8", "अडतीस",  NULL },
+    { "3", "9", "एकोणचाळीस",  NULL },
+    { "4", "0", "चाळीस",  NULL },
+    { "4", "1", "एक्केचाळीस",  NULL },
+    { "4", "2", "बेचाळीस",  NULL },
+    { "4", "3", "त्रेचाळीस",  NULL },
+    { "4", "4", "चव्वेचाळीस",  NULL },
+    { "4", "5", "पंचेचाळीस",  NULL },
+    { "4", "6", "सेहेचाळीस",  NULL },
+    { "4", "7", "सत्तेचाळीस",  NULL },
+    { "4", "8", "अठ्ठेचाळीस",  NULL },
+    { "4", "9", "एकोणपन्नास",  NULL },
+    { "5", "0", "पन्नास",  NULL },
+    { "5", "1", "एक्कावन्न",  NULL },
+    { "5", "2", "बावन्न",  NULL },
+    { "5", "3", "त्रेपन्न",  NULL },
+    { "5", "4", "चोपन्न",  NULL },
+    { "5", "5", "पंचावन्न",  NULL },
+    { "5", "6", "छप्पन्न",  NULL },
+    { "5", "7", "सत्तावन्न",  NULL },
+    { "5", "8", "अठ्ठावन्न",  NULL },
+    { "5", "9", "एकोणसाठ",  NULL },
+    { "6", "0", "साठ",  NULL },
+    { "6", "1", "एकसष्ठ",  NULL },
+    { "6", "2", "बासष्ठ",  NULL },
+    { "6", "3", "त्रेसष्ठ",  NULL },
+    { "6", "4", "चौसष्ठ",  NULL },
+    { "6", "5", "पासष्ठ",  NULL },
+    { "6", "6", "सहासष्ठ",  NULL },
+    { "6", "7", "सदुसष्ठ",  NULL },
+    { "6", "8", "अडुसष्ठ",  NULL },
+    { "6", "9", "एकोणसत्तर",  NULL },
+    { "7", "0", "सत्तर",  NULL },
+    { "7", "1", "एक्काहत्तर",  NULL },
+    { "7", "2", "बाहत्तर",  NULL },
+    { "7", "3", "त्र्याहत्तर",  NULL },
+    { "7", "4", "चौर्‍याहत्तर",  NULL },
+    { "7", "5", "पंच्याहत्तर",  NULL },
+    { "7", "6", "शहात्तर",  NULL },
+    { "7", "7", "सत्याहत्तर",  NULL },
+    { "7", "8", "अठ्ठ्याहत्तर",  NULL },
+    { "7", "9", "एकोणऐंशी",  NULL },
+    { "8", "0", "ऐंशी",  NULL },
+    { "8", "1", "एक्क्याऐंशी",  NULL },
+    { "8", "2", "ब्याऐंशी",  NULL },
+    { "8", "3", "त्र्याऐंशी",  NULL },
+    { "8", "4", "चौऱ्याऐंशी",  NULL },
+    { "8", "5", "पंच्याऐंशी",  NULL },
+    { "8", "6", "शहाऐंशी",  NULL },
+    { "8", "7", "सत्त्याऐंशी",  NULL },
+    { "8", "8", "अठ्ठ्याऐंशी",  NULL },
+    { "8", "9", "एकोणनव्वद",  NULL },
+    { "9", "0", "नव्वद",  NULL },
+    { "9", "1", "एक्क्याण्णव",  NULL },
+    { "9", "2", "ब्याण्णव",  NULL },
+    { "9", "3", "त्र्याण्णव",  NULL },
+    { "9", "4", "चौऱ्याण्णव",  NULL },
+    { "9", "5", "पंच्याण्णव",  NULL },
+    { "9", "6", "शहाण्णव",  NULL },
+    { "9", "7", "सत्त्याण्णव",  NULL },
+    { "9", "8", "अठ्ठ्याण्णव",  NULL },
+    { "9", "9", "नव्व्याण्णव",  NULL },
+    { NULL, NULL },
+};
+
+const static indic_num_table mar_num_table = {
+    "mar",
+    &indic_eng_digit,
+    &indic_eng_two_digit,
+    "शंभर",   /* hundred */
+    "हजार", /* thousand */
+    "लाख",  /* lakh */
+    "कोटी", /* crore */
+};
+#endif
+
+
+#if 1
+
+static const char * const indic_eng_digit[11][2] =
+{
     { "0", "zero" },
     { "1", "one" },
     { "2", "two" },
@@ -171,6 +296,8 @@
     "lakh",
     "crore"
 };
+
+#endif
 
 
 #ifdef __cplusplus
--- a/src/cg/cst_cg.c
+++ b/src/cg/cst_cg.c
@@ -367,6 +367,8 @@
         start_index = ffeature_int(syl,"R:SylStructure.daughter1.R:segstate.daughter1.R:mcep_link.daughter1.frame_number");
         end_index = ffeature_int(syl,"R:SylStructure.daughtern.R:segstate.daughtern.R:mcep_link.daughtern.frame_number");
         mid_index = (int)((start_index + end_index)/2.0);
+        if (end_index <= start_index)
+            continue;
         
         start_f0 = param_track->frames[start_index][0];
         if (end_f0 > 0.0)
--- a/src/cg/cst_cg_map.c
+++ b/src/cg/cst_cg_map.c
@@ -176,6 +176,8 @@
     db->spamf0 = cst_read_int(fd,bs); /* yes, twice, its above too */
     db->gain = cst_read_float(fd,bs);
 
+    /* If this is "grapheme" voice, we will have phoneset and char_map */
+
     return db;
   
 }
--- a/testsuite/lex_lookup_main.c
+++ b/testsuite/lex_lookup_main.c
@@ -50,6 +50,12 @@
     p = lex_lookup(l,word,pos,NULL);
     val_print(stdout,p);
     printf("\n");
+    if (l->lts_function)
+        p = l->lts_function(l,word,pos,NULL);
+    else if (l->lts_rule_set)
+        p = lts_apply(word,"",l->lts_rule_set);
+    val_print(stdout,p);
+    printf("\n");
     delete_val(p);
 }
 
--- a/tools/Makefile.flite
+++ b/tools/Makefile.flite
@@ -67,6 +67,9 @@
 ifeq ($(SPAMF0),true)
 CSRCS += $(VOICENAME)_spamf0_phrase.c $(VOICENAME)_spamf0_accent.c $(VOICENAME)_spamf0_accent_params.c
 endif
+ifeq ($(CG_GRAPHEME),true)
+CSRCS += $(VOICENAME)_phoneset.c 
+endif
 MCEPOBJS =
 LPCOBJS =
 else
--- a/tools/VOICE_cg.c
+++ b/tools/VOICE_cg.c
@@ -48,6 +48,8 @@
 extern cst_cg_db __VOICENAME___cg_db;
 cst_voice *__VOICENAME___cg = NULL;
 
+extern const cst_phoneset __VOICENAME___phoneset;
+
 cst_voice *register___VOICENAME__(const char *voxdir)
 {
     cst_voice *vox;
@@ -72,6 +74,12 @@
     lex = __FLITELEX___init();
     flite_feat_set(vox->features,"lexicon",lexicon_val(lex));
     flite_feat_set(vox->features,"postlex_func",uttfunc_val(lex->postlex));
+
+    /* If grapheme link in grapheme specific info */
+    if (feat_present(vox->features,"grapheme"))
+    {
+        flite_feat_set(vox->features,"phoneset",phoneset_val(&__VOICENAME___phoneset));
+    }
 
     /* No standard segment durations are needed as its done at the */
     /* HMM state level */
--- a/tools/build_flite
+++ b/tools/build_flite
@@ -387,12 +387,15 @@
    then
       ${FLITEDIR}/tools/make_flite_feats etc/voice.feats >flite/${FV_VOICENAME}_voice_feats.c
    fi
-   
-   if [ "$FV_LANG_TYPE" = "grapheme" ]
+
+   # If Grapheme-based it has its own phoneset
+   if [ -f festvox/${FV_VOICENAME}_char_phone_map.scm ]
    then
-      echo cg_convert: converting phoneset table
+       echo "flite_feat_set_int(vox->features,\"grapheme\",1);" >>flite/${FV_VOICENAME}_voice_feats.c
+       echo cg_convert: converting phoneset table
+       echo "CG_GRAPHEME=true" >>flite/paramfiles.mak
       $FESTIVAL -b $FLITEDIR/tools/make_phoneset.scm \
-      '(phonesettoC "'${FV_INST}_${FV_LANG}'" (car (load "festvox/'${FV_VOICENAME}'_phoneset.scm" t)) "pau" "flite")'
+      '(phonesettoC "'${FV_VOICENAME}'" (car (load "festvox/'${FV_VOICENAME}'_phoneset.scm" t)) "pau" "flite")'
    fi
 
    echo "flite_build cg complete.  You can compile the generated voice by"
--- a/tools/make_cg.scm
+++ b/tools/make_cg.scm
@@ -75,6 +75,8 @@
    (format ofd "#include \"cst_cg.h\"\n")
    (format ofd "#include \"cst_cart.h\"\n")
 
+   (format ofd "extern const cst_phoneset %s_phoneset;\n\n" name)
+
    (format t "cg_convert: converting F0 trees\n")
    ;; F0 trees
    (if (and cg:rfs_models (probe_file "rf_models/mlistf0"))
@@ -171,6 +173,20 @@
          (format ofd "extern const unsigned short * const %s_01_model_vectors[];\n" name )
          ))
 
+   (if (probe_file (format nil "festvox/%s_char_phone_map.scm" name))
+       (begin
+         (setq cpm (load (format nil "festvox/%s_char_phone_map.scm" name) t))
+         (format ofd "\nstatic char * const %s_char_phone_map[%s][2] =\n"
+                 name (+ 1 (length cpm)))
+         (format ofd "{\n")
+         (mapcar
+          (lambda (x)
+            (format ofd " { %l, \"%s\" },\n" (car x) (cadr x)))
+          cpm)
+         (format ofd "   { NULL, NULL }\n")
+         (format ofd "};\n\n")
+         ))
+
    (format ofd "#define %s_num_f0_models %d\n" name (length f0ms))
    (format ofd "const cst_cart **%s_f0_carts_table[] = {\n" name)
    (mapcar
@@ -399,9 +415,18 @@
          (format ofd "  0,0, /* cg:mixed_excitation */\n")
          (format ofd "  NULL, \n")))
    (if cg:spamf0
-	(format ofd "  1, // cg:spamf0\n")
-	(format ofd "  0, // cg:spamf0\n"))
+	(format ofd "  1, /* cg:spamf0 */\n")
+	(format ofd "  0, /* cg:spamf0 */\n"))
    (format ofd "  1.5 /* gain */\n")
+
+   ;; If a grapheme language, add phoneset and char_phone_map
+   (if (probe_file (format nil "festvox/%s_char_phone_map.scm" name))
+       (begin
+         (format ofd "   ,\n")
+         (format ofd "   &%s_phoneset,\n" name)
+         (format ofd "   &%s_char_phone_map\n" name)
+         ))
+   
    (format ofd "};\n")
 
    (fclose ofd)
@@ -802,6 +827,30 @@
       (string-before x "}")
       "rb"
       (string-after x "}"))))
+   ((string-matches x ".*].*")
+    (intern
+     (string-append
+      (string-before x "]")
+      "rbk"
+      (string-after x "]"))))
+   ((string-matches x ".*-.*")
+    (intern
+     (string-append
+      (string-before x "-")
+      "hyp"
+      (string-after x "-"))))
+   ((string-matches x ".*\\*.*")
+    (intern
+     (string-append
+      (string-before x "*")
+      "star"
+      (string-after x "*"))))
+   ((string-matches x ".*\\^.*")
+    (intern
+     (string-append
+      (string-before x "^")
+      "caret"
+      (string-after x "^"))))
    ((string-matches x ".*~.*")
     (intern
      (string-append