Bug 467531

Summary: make festival work with pulseaudio
Product: [Fedora] Fedora Reporter: Matthias Clasen <mclasen>
Component: festivalAssignee: David Zeuthen <davidz>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: rawhideCC: davidz, lpoetter, mattdm, mclasen, redhat-bugzilla, rstrode
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-10-27 21:59:55 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 457945    

Description Matthias Clasen 2008-10-17 21:38:02 EDT
I wonder why we don't configure festival to make it work with pulseaudio.

Running festival with our package, while music is playing, yields:

[mclasen@localhost ~]$ festival --tts text
Linux: can't open /dev/dsp

This can be fixed by adding the following lines to /etc/festival/siteinit.scm:

(Parameter.set 'Audio_Command "aplay $FILE")
(Parameter.set 'Audio_Method 'Audio_Command)
(Parameter.set 'Audio_Required_Format 'snd)
Comment 1 Matthew Miller 2008-10-18 09:13:42 EDT
Thanks for the suggestion. I have a big update planned for after then F10 release and I'll get this in then.
Comment 2 Matthias Clasen 2008-10-18 17:07:20 EDT
If you don't mind, I'd really like to get this in before F10. We're shipping with PA on by default, and it would be a bit of a bummer to have non-working speech as a consequence of that.
Comment 3 Matthew Miller 2008-10-18 20:42:35 EDT
I'm fine with that -- I just don't have time to work on it. 

Some notes:

This should go in /usr/share/festival/lib/init.scm rather than in /etc/festival/siteinit.scm since it's a system default rather than a local customization.

Are there any downsides to using this method?
Comment 4 Matthias Clasen 2008-10-18 22:03:01 EDT
Ok, I do the work to get this in the package, and I can put it into lib/init.scm.
I've asked Lennart for his opinion about the best way to make festival work with PA, I'll wait for his response before building this.
Comment 5 Lennart Poettering 2008-10-20 11:19:01 EDT
If festival behaves correctly we could simply run festival prefixed with "padsp".
Comment 6 Matthew Miller 2008-10-20 11:25:16 EDT
> If festival behaves correctly we could simply run festival prefixed with
> "padsp".

Who is "we"? Any program which uses festival?
Comment 7 Matthias Clasen 2008-10-20 14:23:36 EDT
For F11, we should probably take a look at using speech-dispatcher with orca.
Comment 8 Matthias Clasen 2008-10-20 14:24:53 EDT
see http://live.gnome.org/Orca/SpeechDispatcher
Comment 9 Ray Strode [halfline] 2008-10-24 17:15:45 EDT
Two thoughts:

1) should probably use paplay instead of aplay since it gives us the ability to name the stream in pavucontrol

2) isn't this a bad idea in general? I mean doesn't it mean festival will write out all audio to a file, and play the file adding lots of latency for orca users?
Comment 10 Lennart Poettering 2008-10-24 17:26:24 EDT
They use aplay? Oh my! That's horrible!
Comment 11 Matthias Clasen 2008-10-24 17:34:31 EDT
Does orca currently work at all when pulseaudio is running ?

As I said: longer-term, sound-dispatcher may be a better option. 
Or maybe just write a pa backend for festival.
Comment 12 Ray Strode [halfline] 2008-10-24 17:40:13 EDT
Lennart, it doesn't use aplay right now, but Matthias's proposal in comment 0 was to use aplay.

Matthias, yea I was using orca the other day to test gnome bug 535827 and i was getting audio okay.
Comment 13 Ray Strode [halfline] 2008-10-24 17:41:17 EDT
also interesting is the festival source tree seems to suggest it has a libesound backend, which should work with pa...
Comment 14 Ray Strode [halfline] 2008-10-24 17:42:47 EDT
Actually, I can't reproduce the failure in comment 0.

Maybe it was broken for some reason and has since been fixed?

Can you still reproduce the original issue?
Comment 15 Ray Strode [halfline] 2008-10-24 17:44:06 EDT
scratch comment 13.  i missed the "while playing music" bit.  i can reproduce if rhythmbox is playing music.
Comment 16 Lennart Poettering 2008-10-27 11:42:51 EDT
Anyone tried whether this would work?

(Parameter.set 'Audio_Command "pacat --channels=1 --rate=$SR $FILE")
Comment 17 Ray Strode [halfline] 2008-10-27 12:09:38 EDT
so running

(Paramter.get 'Audio_Method)

yields, linux16audio instead of esdaudio

doing

(Parameter.set 'Audio_Method 'esdaudio)

then starting rhythmbox and playing music, followed by:

(SayText "hello")

gives the message "hello" on top of the music.

I think we just need to change the default audio backend to esdaudio.
Comment 18 Ray Strode [halfline] 2008-10-27 12:11:29 EDT
Matthias pointed out this might break festival for runlevel 3 users.  

Lennart, do you know if it will?
Comment 19 Matthias Clasen 2008-10-27 12:36:18 EDT
To answer that question:

ESD: error writing - Bad file descriptor
#<Utterance 0xb7197818>
Comment 20 Lennart Poettering 2008-10-27 13:14:42 EDT
The thing with esd-style autospawning is that it is racy, does not do locking while testing whether to startup a new instance. I'd prefer if we didn't rely n esd style autospawning.

Which leaves us the options. a) use pacat or b) make sure that pulseaudio --start was rung and completed before festival becomes active.
Comment 21 Ray Strode [halfline] 2008-10-27 15:01:40 EDT
pacat doesn't work if pulseaudio isn't running, right?
Comment 22 Matthias Clasen 2008-10-27 16:15:29 EDT
Yes, I think the only solution that has a chance of working in the absense of PA is aplay (which is why I put that in the initial comment, btw...)
Comment 23 Lennart Poettering 2008-10-27 19:53:39 EDT
Since pacat links against libpulse it would use the race-free PA-style autospawning. Hence using pacat is fine.
Comment 24 Matthew Miller 2008-10-27 20:37:23 EDT
(In reply to comment #16)
> Anyone tried whether this would work?
> 
> (Parameter.set 'Audio_Command "pacat --channels=1 --rate=$SR $FILE")

So, on my rawhide system, this makes a horrible loud static noise. But this system has been constantly tracking rawhide for a year and a half or, and pulseaudio has always worked inconsistently.
Comment 25 Ray Strode [halfline] 2008-10-27 20:50:09 EDT
It works on my system in X.  Haven't tried from runlevel 3.
Comment 26 Ray Strode [halfline] 2008-10-27 21:59:55 EDT
okay i built festival with the pacat workaround for now.

We should revisit this at some point, though.