Sophie

Sophie

distrib > * > 2008.0 > x86_64 > by-pkgid > 8d8d9fd6d780749b177b557b988eb3d4 > files > 5

festival-1.96-1mdv2008.0.src.rpm

diff -Naur festival/README.asterisk festival.oden/README.asterisk
--- festival/README.asterisk	1970-01-01 01:00:00.000000000 +0100
+++ festival.oden/README.asterisk	2004-04-21 01:31:13.000000000 +0200
@@ -0,0 +1,30 @@
+
+app_festival is an application that allows one to send text-to-speech commands
+to a background festival server, and to obtain the resulting waveform which
+gets sent down to the respective channel. app_festival also employs a waveform 
+cache, so invariant text-to-speech strings ("Please press 1 for instructions") 
+do not need to be dynamically generated all the time. 
+
+You need : 
+
+1) festival, patched to produce 8khz waveforms on output. Patch for Festival
+1.4.2 RELEASE are included. The patch adds a new command to festival 
+(asterisk_tts). 
+
+
+2) You may wish to obtain and install the asterisk-perl
+module by James Golovich <james@gnuinter.net>, from 
+either CPAN, or his site: http://asterisk.gnuinter.net,
+as this contains a good example of how variable text
+can be tts'd via asterisk, namely the examples/tts-*.agi
+files there. It has been noted that the current expression
+evaluation capabilities of asterisk are not best suited
+for the generation and manipulation of text. AGI scripting
+can be ideal for these sorts of needs. For simpler usage,
+fixed, pre-recorded messages may be more amenable for your
+purposes.
+
+3) Before running asterisk, you have to run festival-server with a command 
+like : 
+
+/usr/local/festival/bin/festival --server > /dev/null 2>&1 &
diff -Naur festival/lib/tts.scm festival.oden/lib/tts.scm
--- festival/lib/tts.scm	2003-01-09 16:39:22.000000000 +0100
+++ festival.oden/lib/tts.scm	2004-09-10 22:32:26.563743002 +0200
@@ -234,6 +234,17 @@
        (utt.synth
 	(eval (list 'Utterance 'Text string))))))
 
+;; begin tts_textasterisk
+(define (tts_textasterisk string mode)
+  "(tts_textasterisk STRING MODE)
+Apply tts to STRING.  This function is specifically designed for
+use in server mode so a single function call may synthesize the string.
+This function name may be added to the server safe functions."
+  (utt.send.wave.asterisk 
+   (utt.synth
+    (eval (list 'Utterance 'Text string)))))
+;; end tts_textasterisk
+
 (define (tts_return_to_client)
   "(tts_return_to_client)
 This function is called by clients who wish to return waveforms of
diff -Naur festival/src/arch/festival/wave.cc festival.oden/src/arch/festival/wave.cc
--- festival/src/arch/festival/wave.cc	2003-01-13 20:09:55.000000000 +0100
+++ festival.oden/src/arch/festival/wave.cc	2004-09-10 22:32:26.564743023 +0200
@@ -381,6 +381,7 @@
 	type = "nist";
     else
 	type = get_c_string(ltype);
+
     w->save(tmpfile,type);
 #ifdef WIN32
     send(ft_server_socket,"WV\n",3,0);
@@ -393,6 +394,44 @@
     return utt;
 }
 
+// begin utt_send_wave_asterisk()
+static LISP utt_send_wave_asterisk(LISP utt)
+{
+    // Send the waveform to a client (must be acting as server)
+    EST_Utterance *u = utterance(utt);
+    EST_Wave *w;
+    EST_String tmpfile = make_tmp_filename();
+    LISP ltype;
+    EST_String type;
+
+    w = get_utt_wave(u);
+    if (ft_server_socket == -1)
+    {
+       cerr << "utt_send_wave_client: not in server mode" << endl;
+       festival_error();
+    }
+       
+    ltype = ft_get_param("Wavefiletype");
+    if (ltype == NIL)
+       type = "nist";
+    else
+       type = get_c_string(ltype);
+    w->resample(8000);
+    w->rescale(5);
+
+    w->save(tmpfile,type);
+#ifdef WIN32
+    send(ft_server_socket,"WV\n",3,0);
+#else
+    write(ft_server_socket,"WV\n",3);
+#endif
+    socket_send_file(ft_server_socket,tmpfile);
+    unlink(tmpfile);
+
+    return utt;
+}
+// end utt_send_wave_asterisk()
+
 static LISP send_sexpr_to_client(LISP l)
 {
     EST_String tmpfile = make_tmp_filename();
@@ -465,6 +504,15 @@
  "(utt.send.wave.client UTT)\n\
   Sends wave in UTT to client.  If not in server mode gives an error\n\
   Note the client must be expecting to receive the waveform.");
+
+// begin asterisk mod
+    init_subr_1("utt.send.wave.asterisk",utt_send_wave_asterisk,
+ "(utt.send.wave.asterisk UTT)\n\
+  Sends wave in UTT to client.  If not in server mode gives an error\n\
+  Note the client must be expecting to receive the waveform. The waveform\n\
+  is rescaled and resampled according to what asterisk needs");
+// end asterisk mod
+
     init_subr_1("send_sexpr_to_client", send_sexpr_to_client,
  "(send_sexpr_to_client SEXPR)\n\
 Sends given sexpression to currently connected client.");