summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--redhat/changelog10
-rw-r--r--redhat/rules12
-rw-r--r--src/Makefile40
-rw-r--r--src/festivy.c129
4 files changed, 191 insertions, 0 deletions
diff --git a/redhat/changelog b/redhat/changelog
new file mode 100644
index 0000000..2eb51cb
--- /dev/null
+++ b/redhat/changelog
@@ -0,0 +1,10 @@
+$Version = "0.1";
+$Release = 1;
+
+$ChangeLog = '
+
+ * Fri Feb 1 2002 Stéphane Chatty <chatty@intuilab.com>
+- Generation of version 0.1-1
+- First version of festivy
+
+';
diff --git a/redhat/rules b/redhat/rules
new file mode 100644
index 0000000..0ee2cfe
--- /dev/null
+++ b/redhat/rules
@@ -0,0 +1,12 @@
+$Summary = "Festivy, a relay between a Festival server and an Ivy bus";
+$Name = "festivy";
+$Copyright = "Stephane Chatty";
+$Distribution = "IntuiKit";
+$Group = "Applications/Office";
+$Url = "http://www.intuilab.com/";
+$Requires = "festival, ivy-c";
+$BuildArchitectures = "i386";
+$Description = "Festivy sends requests to the Festival speech synthesis server
+upon the reception of appropriate messages on the Ivy bus it is connected to.";
+
+
diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 0000000..d6d9b44
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,40 @@
+#
+# Ivy, C interface
+#
+# Copyright (C) 1997-2000
+# Centre d'Études de la Navigation Aérienne
+#
+# Makefile
+#
+# Authors: François-Régis Colin <fcolin@cena.fr>
+# Stéphane Chatty <chatty@cena.fr>
+#
+# $Id$
+#
+# Please refer to file version.h for the
+# copyright notice regarding this software
+#
+
+
+MAJOR=0
+MINOR=1
+
+CC=gcc
+CFLAGS = -g
+# not yiet need Modified Glut ivyglutprobe
+
+.c.o:
+ $(CC) $(CFLAGS) -c $*.c
+
+all: festivy
+
+festivy: festivy.o
+ $(CC) $(CFLAGS) -o festivy festivy.o -livy
+
+clean:
+ -rm -f festivy *.o *.a *.so *.so.* *~
+
+
+install: festivy
+ test -d $(PREFIX)/usr/bin || mkdirhier $(PREFIX)/usr/bin
+ install -m755 festivy $(PREFIX)/usr/bin
diff --git a/src/festivy.c b/src/festivy.c
new file mode 100644
index 0000000..ab6a896
--- /dev/null
+++ b/src/festivy.c
@@ -0,0 +1,129 @@
+/*
+ * Festival - Ivy relay
+ *
+ * Copyright (C) 2002
+ * IntuiLab
+ *
+ * Main and only file
+ *
+ * Authors: Stéphane Chatty <chatty@intuilab.com>
+ *
+ * $Id$
+ *
+ * Please refer to file version.h for the
+ * copyright notice regarding this software
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <netinet/in.h>
+#include <netdb.h>
+
+#include "ivyloop.h"
+#include "ivysocket.h"
+#include "ivy.h"
+
+const char* default_host = "localhost";
+const default_port = 1314;
+int festival_fd;
+
+int
+ServerOpen ()
+{
+ int sock;
+ static struct sockaddr_in addr;
+ struct hostent *hp;
+ const char* host;
+ const char* port_number;
+ int port;
+
+ /* determine host name and port */
+ host = getenv ("FESTIVAL_HOST");
+ if (!host)
+ host = default_host;
+
+ port_number = getenv ("FESTIVAL_PORT");
+ if (port_number) {
+ port = atoi (port_number);
+ } else {
+ port = default_port;
+ }
+
+ hp = gethostbyname (host);
+ if (hp == 0) {
+ fprintf (stderr, "Unknown host %s\n", host);
+ return 0;
+ }
+
+ /* create socket */
+ sock = socket (AF_INET, SOCK_STREAM, 0);
+ if (sock < 0) {
+ perror ("Can't create socket: ");
+ return 0;
+ }
+
+ /* build address from host addr and port */
+ memcpy (&addr.sin_addr, hp->h_addr, hp->h_length);
+ addr.sin_family = AF_INET;
+ addr.sin_port = htons (port);
+
+ /* connect socket on address */
+ if (connect (sock, &addr, sizeof (addr)) < 0) {
+ perror ("Can't connect socket: ");
+ return 0;
+ }
+
+ return sock;
+}
+
+void
+HandleServerReplies (Channel channel, HANDLE fd, void *data)
+{
+ /* basically ignore replies... */
+ char reply[1024];
+ read (festival_fd, reply, 1024);
+}
+
+void
+HandleIvyEvents (IvyClientPtr app, void *user_data, int argc, char *argv[])
+{
+ write (festival_fd, "(SayText \"", 10);
+ write (festival_fd, argv[0], strlen (argv[0]));
+ write (festival_fd, "\")", 2);
+}
+
+
+int
+main (int argc, char *argv[])
+{
+ int c;
+ char busbuf [1024] = "";
+ const char* bus = 0;
+
+ /* handle arguments */
+ while ((c = getopt (argc, argv, "b:")) != EOF)
+ switch (c) {
+ case 'b':
+ strcpy (busbuf, optarg);
+ bus = busbuf;
+ break;
+ }
+
+ /* Ivy side */
+ IvyInit ("Festivy", "Festivy ready", 0, 0, 0, 0);
+ IvyBindMsg (HandleIvyEvents, 0, "Say (.*)");
+
+ /* Festival side */
+ festival_fd = ServerOpen ();
+ IvyChannelSetUp (festival_fd, 0, 0, HandleServerReplies);
+
+ /* Let's get going */
+ IvyStart (bus);
+ IvyMainLoop (0);
+
+ return 0;
+}