[CBLX] Ubuntu Lucid + Orca + speech-dispatcher/libao + pulseaudio + ibmtts fonctionne enfin!

[ Thread Index | Date Index | More lists.tuxfamily.org/carrefourblinux Archives ]


Je passe cette info postée par Bill Cox sur un autre forum, parce que ENFIN
il y a du progrès, et pas un peu, dans le bon sens!
Le mariage des éléments cités dans le sujet de ce mail, semblent être
effectif et efficace: 


----- Forwarded message from Bill Cox <waywardgeek gmail.com> -----

From: Bill Cox <waywardgeek gmail.com>
Date: Fri, 18 Dec 2009 12:18:42 -0500
To: orca-list gnome.org, vinux-development googlegroups.com
Subject: Ubuntu Lucid + Orca + speech-dispatcher/libao +
	pulseaudio +  ibmtts works great!

The performance of the IBM TTS voice using Luke's libao patch works
great through speech-dispatcher/lbiao with pulseaudio.  I am not sure
if I can tell the difference between speed of this setup vs what I get
when I disable pulseaudio.  However, I do I run puseaudio at nice -11,
rtprior 9, and I think this makes a minor difference.  In 32-bit mode,
Lucid works with Compiz on my machine as well, which provides that
awesome Compiz magnifier.

However, there are still goobers in Lucid + Orca.  In particular,
Firefox is reported as inaccessible.  Also, it's title announcement is
cut short, but other window titles are spoken correctly.  Still, this
is great progress!  These are the steps I followed in full to get the
setup working.  I'm simply copying from other e-mails from Hammer
Attila, Halim Sahin, and others:

- Install Lucid x32 from http://cdimage.ubuntu.com/daily-live/current.
 The x64 build works, but to build the IBM TTS plugin for
speech-dispatcher, you need to do it on an x32 installation.  I
believe the resulting sd_ibmtts driver an simply be copied to an x64
machine once built.

- Buy Voxin (about $6) and install it.  You need the latest version
(0.25).  It can be found at http://voxin.oralux.net/get.php.  When
installing, say 'yes' to install speech drivers, 'yes' to install the
speech-dispatcher driver, and 'no' to the Gnome Speech Services
driver.

- Download the speech-dispatcher source package, apply Lukes patch,
and rebuild it according to Hammer's instructions:

1. In Lucid, I downloaded speech-dispatcher source code from following
command with a directory:
sudo apt-get source speech-dispatcher

2. Please do following commands:
sudo apt-get install libao-dev (this is important)
sudo apt-get build-dep speech-dispatcher

3. I navigate the speech-dispatcher source directory.

4. Applyed the new patch:
patch -p1 <../speechd-libao.diff
Please replace the patch path if you storing Halim sent diff file with
another place. :-):-)

5. I run dpkg-buildpackage command.

6. I installed with following packages with prewious directory (need
do a sudo cd .. command):
speech-dispatcher, python-speechd, libspeechd2.
Possible your system needs another packages, but you found with
rebuilded packages with your needs. Possible the version number is
change with your system.

7. I change the /etc/libao.conf with default_driver=alsa to
default_driver=pulse.

8. Final, reconfiguring speech-dispatcher with using libao audio
output module. Don't worry, my machine spd-conf ask me the suggested
way is Alsa, Pulse, Oss, but don't need correct your answer. :-):-)

- There should be an sd_ibmtts file in the speech-dispatcher tree
under src/modules.  Make sure this is identical to
/usr/lib/speech-dispatcher-modules/sd_ibmtts.  If not, copy it over
there.  Be sure to uncomment the ibmtts line in
~/.speech-dispatcher/conf/speechd.conf.  For some reason, the
sd_ibmtts in my modules directory didn't work the first time.  To test
it, I run ./sd_ibmtts, and then type 'INIT' as it's first command.  It
should respond with

    299-Ibmtts: Initialized successfully.
    299 OK LOADED SUCCESSFULLY

If it doesn't, you need to work on getting it built properly.  I
manually edited the Makefile in the modules directory to add
.../audio/.libs as a library directory, and to turn off optimization
(no -O2), and rebuilt.  The resulting sd_ibmtts simply worked.

Bill

--

You received this message because you are subscribed to the Google Groups "The Vinux Development Forum" group.
To post to this group, send email to vinux-development@xxxxxxxxxxxxxxxx.
To unsubscribe from this group, send email to vinux-development+unsubscribe@xxxxxxxxxxxxxxxx.
For more options, visit this group at http://groups.google.com/group/vinux-development?hl=en.



diff -ruN speechd/configure.in myspeechd/configure.in
--- speechd/configure.in	2009-12-16 11:47:43.000000000 +0100
+++ myspeechd/configure.in	2009-12-16 11:49:25.000000000 +0100
@@ -203,6 +203,25 @@
 
 AM_CONDITIONAL(nas_support, test $nas_aud = "true")
 
+AC_CHECK_LIB(ao,
+        ao_play,
+	libao_aud="true";echo "Compiling with libao support.";,
+        libao_aud="false";echo "*** libao library missing. Compiling without libao support! See INSTALL.";)
+
+AC_ARG_WITH(libao, AS_HELP_STRING(--with-libao, Compile with libao support),
+		 if test $withval = "no"; then 
+		    echo "Forced compilation without libao support.";
+		    libao_aud="false";
+		 else 
+		    if test $libao_aud = "false"; then
+		       echo "libao support is not available. Sorry."; exit 1;
+		    fi
+                 fi
+ 		 echo "")
+
+AM_CONDITIONAL(libao_support, test $libao_aud = "true")
+
+
 AC_CHECK_LIB(asound,
         snd_pcm_open,
 	alsa_aud="true";echo "Compiling with ALSA support.";,
diff -ruN speechd/src/audio/Makefile.am myspeechd/src/audio/Makefile.am
--- speechd/src/audio/Makefile.am	2009-12-16 11:47:43.000000000 +0100
+++ myspeechd/src/audio/Makefile.am	2009-12-16 11:49:25.000000000 +0100
@@ -18,12 +18,16 @@
 ALSA_FLAGS = -DWITH_ALSA
 ALSA_LIBS = -lasound
 endif
+if libao_support
+LIBAO_FLAGS = -DWITH_LIBAO
+LIBAO_LIBS = -lao
+endif
 
 
-EXTRA_DIST = alsa.c oss.c nas.c pulse.c
+EXTRA_DIST = alsa.c libao.c oss.c nas.c pulse.c
 
-AM_CFLAGS = $(am_cflags) $(NAS_FLAGS) $(PULSE_FLAGS) $(ALSA_FLAGS)
-libsdaudio_la_LDFLAGS = -version-info @LIB_SDAUDIO_CURRENT@:@LIB_SDAUDIO_REVISION@:@LIB_SDAUDIO_AGE@ -lpthread $(NAS_LIBS) $(PULSE_LIBS) $(ALSA_LIBS)
+AM_CFLAGS = $(am_cflags) $(NAS_FLAGS) $(PULSE_FLAGS) $(ALSA_FLAGS) $(LIBAO_FLAGS)
+libsdaudio_la_LDFLAGS = -version-info @LIB_SDAUDIO_CURRENT@:@LIB_SDAUDIO_REVISION@:@LIB_SDAUDIO_AGE@ -lpthread $(NAS_LIBS) $(PULSE_LIBS) $(ALSA_LIBS) $(LIBAO_LIBS)
 
 spdlib_LTLIBRARIES = libsdaudio.la
 
diff -ruN speechd/src/audio/libao.c myspeechd/src/audio/libao.c
--- speechd/src/audio/libao.c	1970-01-01 01:00:00.000000000 +0100
+++ myspeechd/src/audio/libao.c	2009-12-16 11:50:50.000000000 +0100
@@ -0,0 +1,191 @@
+/*
+ * libao.c -- The libao backend for the spd_audio library.
+ *
+ * Author: Marco Skambraks <marco@xxxxxxxxxxxxx>
+ * Date:  2009-12-15
+ *
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Leser General Public License as published by the Free
+ * Software Foundation; either version 2.1, or (at your option) any later
+ * version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this package; see the file COPYING.  If not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ */
+
+#include <sys/time.h>
+#include <time.h>
+#include <string.h>
+#include <ao/ao.h>
+
+/* send a packet of XXX bytes to the sound device */
+#define AO_SEND_BYTES 256
+/* Put a message into the logfile (stderr) */
+#define MSG(level, arg...) \
+ if(level <= log_level){ \
+     time_t t; \
+     struct timeval tv; \
+     char *tstr; \
+     t = time(NULL); \
+     tstr = strdup(ctime(&t)); \
+     tstr[strlen(tstr)-1] = 0; \
+     gettimeofday(&tv,NULL); \
+     fprintf(stderr," %s [%d]",tstr, (int) tv.tv_usec); \
+     fprintf(stderr," libao:: "); \
+     fprintf(stderr,arg); \
+     fprintf(stderr,"\n"); \
+     fflush(stderr); \
+     xfree(tstr); \
+  }
+
+#define ERR(arg...) \
+ { \
+     time_t t; \
+     struct timeval tv; \
+     char *tstr; \
+     t = time(NULL); \
+     tstr = strdup(ctime(&t)); \
+     tstr[strlen(tstr)-1] = 0; \
+     gettimeofday(&tv,NULL); \
+     fprintf(stderr," %s [%d]",tstr, (int) tv.tv_usec); \
+     fprintf(stderr," libao ERROR: "); \
+     fprintf(stderr,arg); \
+     fprintf(stderr,"\n"); \
+     fflush(stderr); \
+     xfree(tstr); \
+  }
+
+int libao_stop (AudioID * id);
+
+int libao_open (AudioID * id, void **pars);
+
+int libao_close (AudioID * id);
+
+int libao_play (AudioID * id, AudioTrack track);
+
+int libao_set_volume (AudioID * id, int volume);
+
+static volatile int ao_stop_playback = 0;
+
+static int default_driver;
+
+ao_device *device = NULL;
+
+int libao_open (AudioID * id, void **pars)
+{
+
+  ao_initialize ();
+  default_driver = ao_default_driver_id ();
+  return 0;
+}
+
+int libao_play (AudioID * id, AudioTrack track)
+{
+  int bytes_per_sample;
+
+  int num_bytes;
+
+  int outcnt = 0;
+
+  signed short *output_samples;
+
+  int i;
+
+  ao_sample_format format;
+
+  if (id == NULL)
+    return -1;
+  if (track.samples == NULL || track.num_samples <= 0)
+    return 0;
+
+  /* Choose the correct format */
+  format.bits = track.bits;
+  if (track.bits == 16)
+    bytes_per_sample = 2;
+  else if (track.bits == 8)
+    bytes_per_sample = 1;
+  else
+   {
+     ERR ("Audio: Unrecognized sound data format.\n");
+     return -10;
+   }
+  format.channels = track.num_channels;
+  format.rate = track.sample_rate;
+  format.byte_format = AO_FMT_LITTLE;
+  MSG (3, "Starting playback");
+  output_samples = track.samples;
+  num_bytes = track.num_samples * bytes_per_sample;
+  if (device == NULL)
+    device = ao_open_live (default_driver, &format, NULL);
+  if (device == NULL)
+   {
+     ERR ("error opening libao dev");
+     return -2;
+   }
+  MSG (3, "bytes to play: %d, (%f secs)", num_bytes,
+       (((float) (num_bytes) / 2) / (float) track.sample_rate));
+
+  ao_stop_playback = 0;
+  outcnt = 0;
+  i = 0;
+
+  while ((outcnt < num_bytes) && !ao_stop_playback)
+   {
+     if ((num_bytes - outcnt) > AO_SEND_BYTES)
+       i = AO_SEND_BYTES;
+     else
+       i = (num_bytes - outcnt);
+
+     if (!ao_play (device, (char *) output_samples + outcnt, i))
+      {
+        ao_close (device);
+        device = NULL;
+        ERR ("Audio: ao_play() - closing device - re-open it in next run\n");
+      }
+     outcnt += i;
+   }
+
+  return 0;
+
+}
+
+/* stop the libao_play() loop */
+int libao_stop (AudioID * id)
+{
+
+  ao_stop_playback = 1;
+  return 0;
+}
+
+int libao_close (AudioID * id)
+{
+
+  if (device != NULL)
+    ao_close (device);
+  device = NULL;
+
+  ao_shutdown ();
+  id = NULL;
+
+  return 0;
+}
+
+int libao_set_volume (AudioID * id, int volume)
+{
+  return 0;
+}
+
+/* Provide the libao backend. */
+AudioFunctions libao_functions =
+  { libao_open, libao_play, libao_stop, libao_close, libao_set_volume };
+
+#undef MSG
+#undef ERR
diff -ruN speechd/src/audio/spd_audio.c myspeechd/src/audio/spd_audio.c
--- speechd/src/audio/spd_audio.c	2009-12-16 11:47:43.000000000 +0100
+++ myspeechd/src/audio/spd_audio.c	2009-12-16 11:49:25.000000000 +0100
@@ -27,7 +27,7 @@
  * playing 8 or 16 bit data, immediate stop and synchronization. This library
  * currently provides OSS, NAS, ALSA and PulseAudio backend. The available backends are
  * specified at compile-time using the directives WITH_OSS, WITH_NAS, WITH_ALSA, 
- * WITH_PULSE, but the user program is allowed to switch between them at run-time.
+ * WITH_PULSE, WITH_LIBAO but the user program is allowed to switch between them at run-time.
  */
 
 #include "spd_audio.h"
@@ -47,6 +47,9 @@
 #ifdef WITH_OSS
 #include "oss.c"
 #endif
+#ifdef WITH_LIBAO
+#include "libao.c"
+#endif
 
 /* The NAS backend */
 #ifdef WITH_NAS
@@ -116,6 +119,7 @@
 	*error = strdup("The sound library wasn't compiled with OSS support.");
 	return NULL;
 #endif       
+
     }
     else if (type == AUDIO_ALSA){
 #ifdef WITH_ALSA
@@ -180,6 +184,27 @@
 	return NULL;
 #endif
     }
+    else if (type == AUDIO_LIBAO){
+#ifdef WITH_LIBAO
+	id->function = (Funct*) &libao_functions;
+
+	if (id->function->open != NULL){
+	    ret = id->function->open(id, pars);
+	    if (ret != 0){
+		*error = (char*) strdup("Couldn't open libao");
+		return NULL;
+	    }
+	}
+	else{
+	    *error = (char*) strdup("Couldn't open libao  module.");
+	    return NULL;
+	}
+	id->type = AUDIO_LIBAO;
+#else
+	*error = strdup("The sound library wasn't compiled with libao support..");
+	return NULL;
+#endif
+    }
     else{
 	*error = (char*) strdup("Unknown device");
 	return NULL;
diff -ruN speechd/src/audio/spd_audio.h myspeechd/src/audio/spd_audio.h
--- speechd/src/audio/spd_audio.h	2009-12-16 11:47:43.000000000 +0100
+++ myspeechd/src/audio/spd_audio.h	2009-12-16 11:49:25.000000000 +0100
@@ -54,7 +54,7 @@
 
 #define AUDIO_BUF_SIZE 4096
 
-typedef enum{AUDIO_OSS = 0, AUDIO_NAS = 1, AUDIO_ALSA=2, AUDIO_PULSE=3} AudioOutputType;
+typedef enum{AUDIO_OSS = 0, AUDIO_NAS = 1, AUDIO_ALSA=2, AUDIO_PULSE=3, AUDIO_LIBAO=4} AudioOutputType;
 typedef enum{SPD_AUDIO_LE, SPD_AUDIO_BE} AudioFormat;
 
 AudioFormat spd_audio_endian;
diff -ruN speechd/src/modules/module_utils.c myspeechd/src/modules/module_utils.c
--- speechd/src/modules/module_utils.c	2009-12-16 11:47:43.000000000 +0100
+++ myspeechd/src/modules/module_utils.c	2009-12-16 11:49:25.000000000 +0100
@@ -1150,6 +1150,15 @@
 		    module_audio_output_method = AUDIO_OSS;
 		    audio_output_set = 1;
 		}
+	    } else if (len == 5 && strncmp("libao", outputs, len) == 0){
+		DBG("Using libao audio output method");
+		module_audio_pars[0] = NULL;
+		module_audio_pars[1] = NULL;
+		module_audio_id = spd_audio_open(AUDIO_LIBAO, (void**) module_audio_pars, &error);
+		if (module_audio_id){
+		    module_audio_output_method = AUDIO_LIBAO;
+		    audio_output_set = 1;
+		}
 	    } else if (len == 4 && strncmp("alsa", outputs, len) == 0){
 		DBG("Using Alsa audio output method");
 		module_audio_pars[0] = audio_settings.audio_alsa_device;


----- End forwarded message -----

== 
  Dig that crazy beat on the drums:  VINUX !!!  The best is getting better!
  ----------------------------------<http://vinux.org.uk>------------------
 
 

---
--
   CarrefourBLinuX MailingListe
   Pour obtenir de l'aide, envoyez le sujet  help  à:
   carrefourblinux-request@xxxxxxxxxxxxxxxxxxx
   Archives:
   http://listengine.tuxfamily.org/lists.tuxfamily.org/carrefourblinux


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/