[Freeswitch-svn] [commit] r12166 - freeswitch/trunk/src/mod/asr_tts/mod_flite

FreeSWITCH SVN brian at freeswitch.org
Thu Feb 19 08:38:23 PST 2009


Author: brian
Date: Thu Feb 19 10:38:23 2009
New Revision: 12166

Log:
This version of flite has three new voices.  rms, awb (male) and slt (female),

The build system will automatically download the correct flite build from our website and compile it.  You'll need to rm -rf libs/flite* to make sure that takes place.

Thanks,
/b




Modified:
   freeswitch/trunk/src/mod/asr_tts/mod_flite/Makefile
   freeswitch/trunk/src/mod/asr_tts/mod_flite/mod_flite.c

Modified: freeswitch/trunk/src/mod/asr_tts/mod_flite/Makefile
==============================================================================
--- freeswitch/trunk/src/mod/asr_tts/mod_flite/Makefile	(original)
+++ freeswitch/trunk/src/mod/asr_tts/mod_flite/Makefile	Thu Feb 19 10:38:23 2009
@@ -1,7 +1,11 @@
 FLITE=flite-1.3.99
 FLITE_DIR=$(switch_srcdir)/libs/$(FLITE)
 FLITE_LIBDIR=$(FLITE_DIR)/build/libs
-FLITE_A=$(FLITE_LIBDIR)/libflite_cmu_us_kal.a $(FLITE_LIBDIR)/libflite_cmu_us_kal16.a $(FLITE_LIBDIR)/libflite_cmulex.a $(FLITE_LIBDIR)/libflite_usenglish.a $(FLITE_LIBDIR)/libflite.a
+FLITE_A=$(FLITE_LIBDIR)/libflite_cmu_us_awb.a \
+	$(FLITE_LIBDIR)/libflite_cmu_us_kal.a \
+	$(FLITE_LIBDIR)/libflite_cmu_us_rms.a \
+	$(FLITE_LIBDIR)/libflite_cmu_us_slt.a \
+	$(FLITE_LIBDIR)/libflite_cmulex.a $(FLITE_LIBDIR)/libflite_usenglish.a $(FLITE_LIBDIR)/libflite.a -lasound -lm
 
 LOCAL_CFLAGS=-I$(switch_srcdir)/libs/$(FLITE)/include
 LOCAL_LIBADD=$(FLITE_A)

Modified: freeswitch/trunk/src/mod/asr_tts/mod_flite/mod_flite.c
==============================================================================
--- freeswitch/trunk/src/mod/asr_tts/mod_flite/mod_flite.c	(original)
+++ freeswitch/trunk/src/mod/asr_tts/mod_flite/mod_flite.c	Thu Feb 19 10:38:23 2009
@@ -32,19 +32,27 @@
 #include <switch.h>
 #include <flite.h>
 
+cst_voice *register_cmu_us_awb(void);
+void unregister_cmu_us_awb(cst_voice * v);
+
 cst_voice *register_cmu_us_kal(void);
 void unregister_cmu_us_kal(cst_voice * v);
 
-cst_voice *register_cmu_us_kal16(void);
-void unregister_cmu_us_kal16(cst_voice * v);
+cst_voice *register_cmu_us_rms(void);
+void unregister_cmu_us_rms(cst_voice * v);
+
+cst_voice *register_cmu_us_slt(void);
+void unregister_cmu_us_slt(cst_voice * v);
 
 SWITCH_MODULE_LOAD_FUNCTION(mod_flite_load);
 SWITCH_MODULE_DEFINITION(mod_flite, mod_flite_load, NULL, NULL);
 SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_flite_shutdown);
 
 static struct {
-	cst_voice *v8;
-	cst_voice *v16;
+	cst_voice *awb;
+	cst_voice *kal;
+	cst_voice *rms;
+	cst_voice *slt;
 } globals;
 
 struct flite_data {
@@ -52,6 +60,7 @@
 	cst_wave *w;
 	switch_buffer_t *audio_buffer;
 };
+
 typedef struct flite_data flite_t;
 
 #define free_wave(w) if (w) {delete_wave(w) ; w = NULL; }
@@ -60,13 +69,19 @@
 static switch_status_t flite_speech_open(switch_speech_handle_t *sh, const char *voice_name, int rate, switch_speech_flag_t *flags)
 {
 	flite_t *flite = switch_core_alloc(sh->memory_pool, sizeof(*flite));
+
+	sh->native_rate = 16000;
 	
-	if (rate == 8000) {
-		flite->v = globals.v8;
-	} else if (rate == 16000) {
-		flite->v = globals.v16;
+	if (!strcasecmp(voice_name, "awb")) {
+		flite->v = globals.awb;
+	} else if (!strcasecmp(voice_name, "kal")) {
+		flite->v = globals.kal;
+	} else if (!strcasecmp(voice_name, "rms")) {
+		flite->v = globals.rms;
+	} else if (!strcasecmp(voice_name, "slt")) {
+		flite->v = globals.slt;
 	} else {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "invalid rate %d. Only 8000 and 16000 are supported.\n", rate);
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Valid voice names are awb, kal, rms or slt.\n");
 	}
 
 	if (flite->v) {
@@ -109,7 +124,7 @@
 	free_wave(flite->w);
 }
 
-static switch_status_t flite_speech_read_tts(switch_speech_handle_t *sh, void *data, switch_size_t *datalen, switch_speech_flag_t *flags)
+static switch_status_t flite_speech_read_tts(switch_speech_handle_t *sh, void *data, size_t *datalen, switch_speech_flag_t *flags)
 {
 	size_t bytes_read;
 	flite_t *flite = (flite_t *) sh->private_info;
@@ -160,8 +175,10 @@
 	switch_speech_interface_t *speech_interface;
 
 	flite_init();
-	globals.v8 = register_cmu_us_kal();
-	globals.v16 = register_cmu_us_kal16();
+	globals.awb = register_cmu_us_awb();
+	globals.kal = register_cmu_us_kal();
+	globals.rms = register_cmu_us_rms();
+	globals.slt = register_cmu_us_slt();
 	
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = switch_loadable_module_create_module_interface(pool, modname);
@@ -182,13 +199,14 @@
 
 SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_flite_shutdown)
 {
-	unregister_cmu_us_kal(globals.v8);
-	unregister_cmu_us_kal(globals.v16);
+	unregister_cmu_us_awb(globals.awb);
+	unregister_cmu_us_kal(globals.kal);
+	unregister_cmu_us_rms(globals.rms);
+	unregister_cmu_us_slt(globals.slt);
 
 	return SWITCH_STATUS_UNLOAD;
 }
 
-
 /* For Emacs:
  * Local Variables:
  * mode:c



More information about the Freeswitch-svn mailing list