[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/9] moved module_main.c from festival.c to Makefile.am
From: |
Andrei Kholodnyi |
Subject: |
[PATCH 4/9] moved module_main.c from festival.c to Makefile.am |
Date: |
Mon, 6 Sep 2010 23:17:56 +0200 |
moved functions with speechd specific declarations from festival_client.c to
festival.c
---
src/modules/Makefile.am | 2 +-
src/modules/festival.c | 123 +++++++++++++++++++++++++++++++--
src/modules/festival_client.c | 156 ++---------------------------------------
src/modules/festival_client.h | 35 +++++++++-
4 files changed, 158 insertions(+), 158 deletions(-)
diff --git a/src/modules/Makefile.am b/src/modules/Makefile.am
index 355aaa3..2d40d52 100644
--- a/src/modules/Makefile.am
+++ b/src/modules/Makefile.am
@@ -35,7 +35,7 @@ sd_flite_LDADD = -lsdaudio $(flite_kal) $(flite_basic)
-lpthread -ldotconf @glib
sd_generic_SOURCES = generic.c module_utils.c module_utils.h
sd_generic_LDADD = -lsdaudio -lpthread -ldotconf @glib_libs@ @gthread_libs@
-sd_festival_SOURCES = festival.c module_utils.c
+sd_festival_SOURCES = festival.c festival_client.c festival_client.h
module_main.c module_utils.c module_utils.h
sd_festival_LDFLAGS = @RPATH@ '$(spdlibdir)'
sd_festival_LDADD = -lsdaudio -lpthread -ldotconf @glib_libs@ @gthread_libs@
@EXTRA_SOCKET_LIBS@
diff --git a/src/modules/festival.c b/src/modules/festival.c
index 11becbc..f0396ba 100644
--- a/src/modules/festival.c
+++ b/src/modules/festival.c
@@ -21,13 +21,14 @@
* $Id: festival.c,v 1.82 2008-06-09 10:33:38 hanke Exp $
*/
+#include <stdio.h>
+
#include "fdset.h"
#include "fdsetconv.h"
+#include "festival_client.h"
#include "module_utils.h"
-#include "festival_client.c"
-
#define MODULE_NAME "festival"
#define MODULE_VERSION "0.5"
@@ -66,7 +67,67 @@ struct{
#define COM_SOCKET ((FestivalComType == FCT_SOCKET) ? 1 : 0)
#define COM_LOCAL ((FestivalComType == FCT_LOCAL) ? 1 : 0)
+/* --- SETTINGS COMMANDS --- */
+
+#define FEST_SET_STR(name, fest_param) \
+ int \
+ name(FT_Info *info, char *param, char **resp) \
+ { \
+ char *r; \
+ int ret; \
+ char *f; \
+ if (festival_check_info(info, #name)) return -1; \
+ if (param == NULL){ \
+ FEST_SEND_CMD("("fest_param" nil)"); \
+ }else{ \
+ f = g_ascii_strdown(param, -1); \
+ FEST_SEND_CMDA("("fest_param" \"%s\")", f); \
+ xfree(f); \
+ } \
+ ret = festival_read_response(info, &r); \
+ if (ret != 0) return -1; \
+ if (r != NULL){ \
+ if (resp != NULL) \
+ *resp = r; \
+ else \
+ free(r); \
+ } \
+ return ret; \
+ }
+
+#define FEST_SET_SYMB(name, fest_param) \
+ int \
+ name(FT_Info *info, char *param) \
+ { \
+ char *f = NULL; \
+ if (festival_check_info(info, #name)) return -1; \
+ if (param == NULL) return -1; \
+ FEST_SEND_CMDA("("fest_param" '%s)", f = g_ascii_strdown(param, -1)); \
+ xfree(f); \
+ return festival_read_response(info, NULL); \
+ }
+
+#define FEST_SET_INT(name, fest_param) \
+ int \
+ name(FT_Info *info, int param) \
+ { \
+ if (festival_check_info(info, #name)) return -1; \
+ FEST_SEND_CMDA("("fest_param" %d)", param); \
+ return festival_read_response(info, NULL); \
+ }
+
+FEST_SET_SYMB(FestivalSetMultiMode, "speechd-enable-multi-mode")
+
+FEST_SET_INT(FestivalSetRate, "speechd-set-rate")
+FEST_SET_INT(FestivalSetPitch, "speechd-set-pitch")
+FEST_SET_SYMB(FestivalSetPunctuationMode, "speechd-set-punctuation-mode")
+FEST_SET_STR(FestivalSetCapLetRecogn,
"speechd-set-capital-character-recognition-mode")
+FEST_SET_STR(FestivalSetLanguage, "speechd-set-language")
+FEST_SET_STR(FestivalSetVoice, "speechd-set-voice")
+FEST_SET_SYMB(FestivalSetSynthesisVoice, "speechd-set-festival-voice")
+
/* Internal functions prototypes */
+static VoiceDescription** festivalGetVoices(FT_Info *info);
void* _festival_speak(void*);
void festival_parent_clean();
@@ -446,6 +507,61 @@ module_close(int status)
goto sem_wait; \
}
+static VoiceDescription** festivalGetVoices(FT_Info *info)
+{
+ char *reply;
+ char** voices;
+ char* lang; char* dialect;
+ int i, j;
+ int num_voices = 0;
+ VoiceDescription** result;
+
+ FEST_SEND_CMD("(apply append (voice-list-language-codes))");
+ festival_read_response(info, &reply);
+ if (reply == NULL){
+ DBG("ERROR: Invalid reply for voice-list");
+ return NULL;
+ }
+ /* Remove trailing newline */
+ reply[strlen(reply)-1]=0;
+ DBG("Voice list reply: |%s|", reply);
+ voices = lisp_list_get_vect(reply);
+ if (voices == NULL){
+ DBG("ERROR: Can't parse voice listing reply into vector");
+ return NULL;
+ }
+
+ /* Compute number of voices */
+ for (i=0; ; i++, num_voices++) if (voices[i] == NULL) break;
+ num_voices /= 3;
+
+ result = (VoiceDescription**) malloc((num_voices +
1)*sizeof(VoiceDescription*));
+
+ for (i=0, j=0; ;j++){
+ if (voices[i] == NULL)
+ break;
+ else if (strlen(voices[i]) == 0)
+ continue;
+ else
+ {
+ result[j] = (VoiceDescription*) malloc(sizeof(VoiceDescription));
+ result[j]->name = voices[i];
+ lang = voices[i+1];
+ if ((lang != NULL) && (strcmp(lang, "nil")))
+ result[j]->language = strdup(lang);
+ else
+ result[j]->language = NULL;
+ dialect = voices[i+2];
+ if ((dialect != NULL) && (strcmp(dialect, "nil")))
+ result[j]->dialect = strdup(dialect);
+ else
+ result[j]->dialect=NULL;
+ i+=3;
+ }
+ }
+ result[j] = NULL;
+ return result;
+}
int
festival_send_to_audio(FT_Wave *fwave)
@@ -1061,6 +1177,3 @@ stop_festival_local()
kill(festival_process_pid, SIGINT);
return 0;
}
-
-
-#include "module_main.c"
diff --git a/src/modules/festival_client.c b/src/modules/festival_client.c
index a9e1b4e..3d85516 100644
--- a/src/modules/festival_client.c
+++ b/src/modules/festival_client.c
@@ -62,9 +62,13 @@
#include <arpa/inet.h>
#include <fcntl.h>
+#include <glib.h>
+
/* I'm including my local .h, not the Alan's one! */
#include "festival_client.h"
+#include "module_utils.h"
+
/* For testing endianness */
int fapi_endian_loc = 1;
@@ -430,39 +434,6 @@ festival_accept_any_response(FT_Info *info)
return 0;
}
-#define FEST_SEND_CMD(format) \
- { \
- FILE *fd; \
- char *str; \
- fd = fdopen(dup(info->server_fd),"wb"); \
- if (fd != NULL){ \
- str = g_strdup_printf(format"\n"); \
- fprintf(fd, str); \
- DBG("-> Festival: |%s|", str); \
- free(str); \
- fclose(fd); \
- }else{ \
- DBG("Can't open connection"); \
- } \
- }
-
-#define FEST_SEND_CMDA(format, args...) \
- { \
- FILE *fd; \
- char *str; \
- fd = fdopen(dup(info->server_fd),"wb"); \
- if (fd != NULL){ \
- str = g_strdup_printf(format"\n", args); \
- fprintf(fd, str); \
- DBG("-> Festival: |%s|", str); \
- free(str); \
- fclose(fd); \
- }else{ \
- DBG("Can't open connection"); \
- } \
- }
-
-
/* --- HELPER FUNCTIONS --- */
int
festival_check_info(FT_Info *info, char *fnname){
@@ -753,124 +724,7 @@ char* vect_read_item(char **vect, char* field)
}
}
-
-VoiceDescription** festivalGetVoices(FT_Info *info)
-{
- char *reply;
- char** voices;
- char* lang; char* dialect;
- int i, j;
- int num_voices = 0;
- VoiceDescription** result;
-
- FEST_SEND_CMD("(apply append (voice-list-language-codes))");
- festival_read_response(info, &reply);
- if (reply == NULL){
- DBG("ERROR: Invalid reply for voice-list");
- return NULL;
- }
- /* Remove trailing newline */
- reply[strlen(reply)-1]=0;
- DBG("Voice list reply: |%s|", reply);
- voices = lisp_list_get_vect(reply);
- if (voices == NULL){
- DBG("ERROR: Can't parse voice listing reply into vector");
- return NULL;
- }
-
- /* Compute number of voices */
- for (i=0; ; i++, num_voices++) if (voices[i] == NULL) break;
- num_voices /= 3;
-
- result = (VoiceDescription**) malloc((num_voices +
1)*sizeof(VoiceDescription*));
-
- for (i=0, j=0; ;j++){
- if (voices[i] == NULL)
- break;
- else if (strlen(voices[i]) == 0)
- continue;
- else
- {
- result[j] = (VoiceDescription*) malloc(sizeof(VoiceDescription));
- result[j]->name = voices[i];
- lang = voices[i+1];
- if ((lang != NULL) && (strcmp(lang, "nil")))
- result[j]->language = strdup(lang);
- else
- result[j]->language = NULL;
- dialect = voices[i+2];
- if ((dialect != NULL) && (strcmp(dialect, "nil")))
- result[j]->dialect = strdup(dialect);
- else
- result[j]->dialect=NULL;
- i+=3;
- }
- }
- result[j] = NULL;
- return result;
-}
-
-/* --- SETTINGS COMMANDS --- */
-
-#define FEST_SET_STR(name, fest_param) \
- int \
- name(FT_Info *info, char *param, char **resp) \
- { \
- char *r; \
- int ret; \
- char *f; \
- if (festival_check_info(info, #name)) return -1; \
- if (param == NULL){ \
- FEST_SEND_CMD("("fest_param" nil)"); \
- }else{ \
- f = g_ascii_strdown(param, -1); \
- FEST_SEND_CMDA("("fest_param" \"%s\")", f); \
- xfree(f); \
- } \
- ret = festival_read_response(info, &r); \
- if (ret != 0) return -1; \
- if (r != NULL){ \
- if (resp != NULL) \
- *resp = r; \
- else \
- free(r); \
- } \
- return ret; \
- }
-
-#define FEST_SET_SYMB(name, fest_param) \
- int \
- name(FT_Info *info, char *param) \
- { \
- char *f = NULL; \
- if (festival_check_info(info, #name)) return -1; \
- if (param == NULL) return -1; \
- FEST_SEND_CMDA("("fest_param" '%s)", f = g_ascii_strdown(param, -1)); \
- xfree(f); \
- return festival_read_response(info, NULL); \
- }
-
-#define FEST_SET_INT(name, fest_param) \
- int \
- name(FT_Info *info, int param) \
- { \
- if (festival_check_info(info, #name)) return -1; \
- FEST_SEND_CMDA("("fest_param" %d)", param); \
- return festival_read_response(info, NULL); \
- }
-
-FEST_SET_SYMB(FestivalSetMultiMode, "speechd-enable-multi-mode")
-
-FEST_SET_INT(FestivalSetRate, "speechd-set-rate")
-FEST_SET_INT(FestivalSetPitch, "speechd-set-pitch")
-FEST_SET_SYMB(FestivalSetPunctuationMode, "speechd-set-punctuation-mode")
-FEST_SET_STR(FestivalSetCapLetRecogn,
"speechd-set-capital-character-recognition-mode")
-FEST_SET_STR(FestivalSetLanguage, "speechd-set-language")
-FEST_SET_STR(FestivalSetVoice, "speechd-set-voice")
-FEST_SET_SYMB(FestivalSetSynthesisVoice, "speechd-set-festival-voice")
-
-
-static FT_Info *festivalDefaultInfo()
+FT_Info *festivalDefaultInfo()
{
FT_Info *info;
info = (FT_Info *) malloc(sizeof(FT_Info));
diff --git a/src/modules/festival_client.h b/src/modules/festival_client.h
index 7c68833..5cd5784 100644
--- a/src/modules/festival_client.h
+++ b/src/modules/festival_client.h
@@ -79,6 +79,37 @@ void delete_FT_Info(FT_Info *info);
/* Intel, Alpha, DEC Mips, Vax */
#define FAPI_LITTLE_ENDIAN (((char *)&fapi_endian_loc)[0] != 0)
+#define FEST_SEND_CMD(format) \
+ { \
+ FILE *fd; \
+ char *str; \
+ fd = fdopen(dup(info->server_fd),"wb"); \
+ if (fd != NULL){ \
+ str = g_strdup_printf(format"\n"); \
+ fprintf(fd, str); \
+ DBG("-> Festival: |%s|", str); \
+ free(str); \
+ fclose(fd); \
+ }else{ \
+ DBG("Can't open connection"); \
+ } \
+ }
+
+#define FEST_SEND_CMDA(format, args...) \
+ { \
+ FILE *fd; \
+ char *str; \
+ fd = fdopen(dup(info->server_fd),"wb"); \
+ if (fd != NULL){ \
+ str = g_strdup_printf(format"\n", args); \
+ fprintf(fd, str); \
+ DBG("-> Festival: |%s|", str); \
+ free(str); \
+ fclose(fd); \
+ }else{ \
+ DBG("Can't open connection"); \
+ } \
+ }
/*****************************************************************/
/* Public functions to interface */
@@ -96,8 +127,10 @@ int festivalSpell(FT_Info *info, const char *text);
FT_Wave* festivalStringToWaveGetData(FT_Info *info);
-static FT_Info *festivalDefaultInfo();
+FT_Info *festivalDefaultInfo();
void festivalEmptySocket(FT_Info *info);
+int save_FT_Wave_snd(FT_Wave *wave, const char *filename);
+FT_Wave* festivalGetDataMulti(FT_Info *info, char **callback, int *stop_flag,
int stop_by_close);
int festival_check_info(FT_Info *info, char *fnname);
int festival_read_response(FT_Info *info, char **expr);
--
1.6.0.4
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH 4/9] moved module_main.c from festival.c to Makefile.am,
Andrei Kholodnyi <=