[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: |
Sun, 5 Sep 2010 01:42:22 +0200 |
---
src/modules/Makefile.am | 2 +-
src/modules/festival.c | 67 +++++++++++++++++++++++++--
src/modules/festival_client.c | 99 ++--------------------------------------
src/modules/festival_client.h | 39 +++++++++++++++-
4 files changed, 105 insertions(+), 102 deletions(-)
diff --git a/src/modules/Makefile.am b/src/modules/Makefile.am
index a8dd548..2232b99 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..0945f48 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,6 +67,65 @@ 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 */
void* _festival_speak(void*);
@@ -1061,6 +1121,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..f04f7be 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){
@@ -810,67 +781,7 @@ VoiceDescription** festivalGetVoices(FT_Info *info)
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..fcd085a 100644
--- a/src/modules/festival_client.h
+++ b/src/modules/festival_client.h
@@ -41,6 +41,8 @@
#ifndef _FESTIVAL_CLIENT_H_
#define _FESTIVAL_CLIENT_H_
+#include "fdset.h"
+
#define FESTIVAL_DEFAULT_SERVER_HOST "localhost"
#define FESTIVAL_DEFAULT_SERVER_PORT 1314
#define FESTIVAL_DEFAULT_TEXT_MODE "fundamental"
@@ -79,6 +81,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 */
@@ -95,10 +128,12 @@ int festivalKey(FT_Info *info, const char *text);
int festivalSpell(FT_Info *info, const char *text);
FT_Wave* festivalStringToWaveGetData(FT_Info *info);
+VoiceDescription** festivalGetVoices(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);
#endif
--
1.6.0.4
- [PATCH 1/9] moved module_main.c from the dummy.c to Makefile.am, Andrei Kholodnyi, 2010/09/04
- [PATCH 2/9] moved module_main.c from cicero.c to Makefile.am, Andrei Kholodnyi, 2010/09/04
- [PATCH 3/9] moved module_main.c from espeak.c to Makefile.am, Andrei Kholodnyi, 2010/09/04
- [PATCH 4/9] moved module_main.c from festival.c to Makefile.am,
Andrei Kholodnyi <=
- [PATCH 5/9] moved module.main.c from flite.c to Makefile.am, Andrei Kholodnyi, 2010/09/04
- [PATCH 6/9] moved module_main.c from generic.c to Makefile.am, Andrei Kholodnyi, 2010/09/04
- [PATCH 7/9] moved module_main.c from ibmtts.c to Makefile.am, Andrei Kholodnyi, 2010/09/04
- [PATCH 8/9] moved module_main.c from ivona.c to Makefile.am, Andrei Kholodnyi, 2010/09/04
- [PATCH 9/9] moved fdsetconv.c from module_utils.c to Makefile.am, Andrei Kholodnyi, 2010/09/04
- [PATCH 9/9] moved fdsetconv.c from module_utils.c to Makefile.am, Christopher Brannon, 2010/09/08
- [PATCH 9/9] moved fdsetconv.c from module_utils.c to Makefile.am, Andrei Kholodnyi, 2010/09/08
- [PATCH 8/9] moved module_main.c from ivona.c to Makefile.am, Christopher Brannon, 2010/09/06
- [PATCH 8/9] moved module_main.c from ivona.c to Makefile.am, Andrei Kholodnyi, 2010/09/06
- [PATCH 4/9] moved module_main.c from festival.c to Makefile.am, Christopher Brannon, 2010/09/06