20#define SPEECH_PROGRAM "say"
22#define SPEECH_PROGRAM "festival --tts -"
25static FILE *
fp = NULL;
33 cm_msg(
MERROR,
"Speaker",
"No speech synthesizer attached");
51 char str[256], *pc, *sp;
52 static DWORD last_beep = 0;
55 printf(
"%s\n", (
char *) (
message));
58 fputs(
"Speech synthesizer not enabled - terminating\n", stderr);
65 pc = strchr((
char *) (
message),
']') + 2;
66 sp = pc + strlen(pc) - 1;
67 while (*sp ==
' ' || *sp ==
'\t')
90 sprintf(
str,
"say %s.", pc);
93 fprintf(
fp,
"%s.\n", pc);
103int main(
int argc,
char *argv[])
120 for (
i = 1;
i < argc;
i++) {
121 if (argv[
i][0] ==
'-' && argv[
i][1] ==
'D')
123 else if (argv[
i][0] ==
'-') {
124 if (
i + 1 >= argc || argv[
i + 1][0] ==
'-')
126 if (argv[
i][1] ==
'e')
128 else if (argv[
i][1] ==
'h')
130 else if (argv[
i][1] ==
'c')
131 speech_program = argv[++
i];
132 else if (argv[
i][1] ==
't')
134 else if (argv[
i][1] ==
'u')
136 else if (argv[
i][1] ==
's')
141 (
"usage: mlxspeaker [-h Hostname] [-e Experiment] [-c command] [-D] daemon\n");
142 printf(
" [-t mt_talk] Specify the mt_talk alert command\n");
143 printf(
" [-u mt_user] Specify the mt_user alert command\n");
144 printf(
" [-s shut up time] Specify the min time interval between alert [s]\n");
145 printf(
" The -t & -u switch require a command equivalent to:\n");
146 printf(
" '-t play --volume=0.3 file.wav'\n");
147 printf(
" [-c command] Used to start the speech synthesizer,\n");
148 printf(
" which should read text from it's standard input.\n");
149 printf(
" eg: mlxspeaker -c 'festival --tts -'\n\n");
156 printf(
"Becoming a daemon...\n");
164 fp = popen(speech_program,
"w");
166 cm_msg(
MERROR,
"Speaker",
"Unable to start \"%s\": %s\n",
167 speech_program, strerror(errno));
179 printf(
"Midas Message Speaker connected to %s. Press \"!\" to exit.\n",
host_name[0] ?
host_name :
"local host");
196#if defined(SIGPIPE) && defined(SIG_IGN)
197 signal(SIGPIPE, SIG_IGN);
INT cm_yield(INT millisec)
INT cm_connect_experiment(const char *host_name, const char *exp_name, const char *client_name, void(*func)(char *))
INT cm_disconnect_experiment(void)
INT cm_get_environment(char *host_name, int host_name_size, char *exp_name, int exp_name_size)
INT ss_getchar(BOOL reset)
INT ss_daemon_init(BOOL keep_stdout)
INT ss_sleep(INT millisec)
INT ss_system(const char *command)
INT cm_msg_register(EVENT_HANDLER *func)
INT cm_msg(INT message_type, const char *filename, INT line, const char *routine, const char *format,...)
char exp_name[NAME_LENGTH]
char host_name[HOST_NAME_LENGTH]
#define message(type, str)
void sigpipehandler(int sig)
void receive_message(HNDLE hBuf, HNDLE id, EVENT_HEADER *header, void *message)
void siginthandler(int sig)