[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacspeak, alsa, alternate sound card and independent streams

Hi Folks,

A few weeks back T.V. Raman said in passing that getting your speech
output to go to an alternate sound card was "not easy" - I have been
trying to get emacspeak working reliably in a way that will allow me
to move easily between earphones, speaker and bluetooth headset.  I am
not quite there yet.  However, I can move speech easily around between
my sound cards and a usb headset or second sound card as well as
control volume for speech as its own stream so I thought I would pass
along how I do that.

What follows is an expansion of the idea Robert Hill posted to this
list last April in his message titled "Controlling volume of audio
streams independently"

All these changes can be done within a running emacspeac session.  All
can be done without rebooting your computer. Here is an overview.
First, setup separate softvol devices for music and emacs.  I also
have a third for system alerts, but that is me. Then you modify
linux-outloud to use one of the new softvol device rather than the
default alsa device.  Once you have done these things, you can move
speech to different cards by editing a line in your .asoundrc.

Please note, this is a modification that I use with outloud.  So if
you don't use outloud for speech, then this does not apply to your
setup.  You may be able to do something similar with other software
speech but this posting does not go into that.  I have done this
modification on four systems without a hitch but that is of course no
guarantee it will work for you.  Please read through this before
trying anything.  The riskyest part is the recompile of atcleci and if
you have compiled it on your system before, then that should not be a
problem.  If somehow you have not ever compiled it, then you should do
that and make sure that is working for you before trying any of this.

O.K., lets start.  If you don't already use softvol, then go read
Robert's post and set up a softvol device as shown in his post.  Don't
continue here until you have that working.  Here is the URL for
Robert's post:


So, you now have one working softvol device for your music, now we
add a second one for outloud to use.

Edit .asoundrc.  Here are the lines to add:

##### add to .asoundrc for emacs  #####

pcm.emacs {
    type            softvol
    slave {
        pcm         "default:CARD=0"
    control {
        name        'emacs'
        card        0

#####  end emacs adds to .asoundrc #####

Save .asoundrc and then restart alsa to get it to read your changes. 
In debian or ubuntu at a command line do:

     sudo /etc/init.d/alsa-util restart

Now get alsa to create your new device by sending it something to
play.  At a command line do:

   speaker-test -D emacs -c 2 -t wav

You should hear a voice that is not emacspeak saying "front left",
"front right" again and again.  While this is happening emacspeak will
be jabbering at you as well.  If you ran speaker-test in an emacs
shell then press C-c C-c to kill speaker-test.  Otherwise a single C-c
should do it.

Next, copy the linux-outloud directory in your emacspeak/servers
directory.  For me that is in
/usr/share/emacs/site-lisp/emacspeak/servers so I need to make that
copy as root:

     cd /usr/share/emacs/site-lisp/emacspeak/servers

     sudo cp -r linux-outloud  linux-outloud-pre-softvol

This way if for some reason this does not work, you still have your
working version available.

The new thing here is getting linux-outloud not to use the default
sound device but to use your new softvol device "emacs" instead.  
Edit the file atcleci.cpp in the linux-outloud directory.

If you are running emacspeak as you (and not root) this file is not
writable by you.  If that is the case then from a shell change the
permisions using sudo

       cd /usr/share/emacs/site-lisp/emacspeak/servers/linux-outloud
       sudo chmod o+w ./atcleci.cpp

Edit atcleci.cpp.  You will find only one line that contains the word
default surounded by double quotes, here is the line:

  const char           *device = "default";

it is in the section of code that sets up alsa and is defining the
alsa device to use for outloud (ttsynth).  Replace the word "default"
on this line with "emacs", in both cases the word is surounded by the
double quote character. That line of your atcleci.cpp file shoul now

  const char           *device = "emacs";

save the file.  Change the permisions back on the atcleci.cpp file:

    sudo chmod o-w ./atcleci.cpp

Then in the linux-outloud directory, give the command "sudo make".
This will rebuild your outloud support telling it to use the new
device when next restarted.

    sudo make

It should compile without incident.  If the compile did not work,
don't continue until you figure out why and get it to compile.
Assuming you have in the past compiled outloud (your using it, right?)
then this should not be a problem.  If for some reason it does not
compile then put back the old linux-outloud directory untill you
figure out the compile problem.

Give the new device a try!

At this point you can try it out. You can simply give the command
tts-restart which as you know is bound to C-e C-s.

You can now adjust the volume of outloud using "M-x amixer" and giving
it the control name of "emacs".

As for moving speech to another sound card, to do that simply edit
your .asoundrc file, and change the line

        pcm         "default:CARD=0"


        pcm         "default:CARD=1"

or some other number if you have several cards.  Then restart alsa,
then restart the speach server in emacs.  The sound will move to the
new device.

Please note that since you did not change the line in the control
section of the pcm.emacs description, the control for the device will
show up with the controls for your first card even though it will
control the device on the second card.  That way you can still use
"M-x amixer" to control it with out making any other changes.  This
works nicely for occational use second sound cards like usb headsets.
I am not sure it is what you want to do if you allways use a second
sound card.  In that case, you probably want to change the line in
your .asoundrc from

    control {
        name        'emacs'
        card        0

To read

    control {
        name        'emacs'
        card        1

But that is up to you.  I do not do it that way.

So there you have it. Hope it is useful,



 Greg Priest-Dorman

To unsubscribe from the emacspeak list or change your address on the
emacspeak list send mail to "emacspeak-request@cs.vassar.edu" with a
subject of "unsubscribe" or "help".

If you have questions about this archive or had problems using it, please send mail to:

priestdo@cs.vassar.edu No Soliciting!

Emacspeak List Archive | 2007 | 2006 | 2005 | 2004 | 2003 | 2002 | 2001 | 2000 | 1999 | 1998 | Pre 1998

Emacspeak Files | Emacspeak Blog | Search the archive