You are not logged in.

#1 2013-03-27 00:27:33

Registered: 2010-01-06
Posts: 27

How to have script provide input to another running program

I'm trying to build a decent voice controlled computer. I'm currently using google's servers for both tts and stt. What I want to do is be able to run pandora on my machine and voice control it. So far, pianobar seems to run pandora nicely from the terminal, but it takes in text input. (eg,I want to tell it to like a song when it's running and to do that normally I just type "+" and it does, but I don't know how to do that with voice control. I can get the speech to text but don't know how to get that text into pianobar)


#2 2013-04-05 14:25:30

From: Earth
Registered: 2012-12-23
Posts: 57

Re: How to have script provide input to another running program

I have to admit I do not know any of the programs you want to use.  But the usual way to automate terminal input is a shell pipe.  To use this for your case, you need a program that outputs a "+" when you give the voice command, let's call it "voicelike".  Then you would start:

voicelike | pianobar

(or perhaps a different command instead of pianobar, as I said I don't know it...)

Officer, I had to drive home - I was way too drunk to teleport!


#3 2013-04-05 15:38:05

From: WAIS
Registered: 2009-10-23
Posts: 1,841

Re: How to have script provide input to another running program

Again, I don't know pianobar, but if it's already running you can only input to it by sending stuff to whatever it may be listening on (socket, dbus, etc.).
These scripts look like they use notify-send to talk to pianobar. You could use them as a template, or possibly even just wrap them (I haven't looked in deatail to see if the latter's possible).

" cannot be angry when one looks at a penguin."  - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle


#4 2013-04-05 15:56:19

Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 14,213

Re: How to have script provide input to another running program

I use piano bar and have written my own mini-frontend to it, as while the program as a whole is great, the interface is very odd.  I'm not sure it will read from stdin as suggested above.

It does, however, have built in modes for reading from a control fifo, and this works extremely well.

In the pianobar config you can have a line "fifo = /path/to/myfifo", then call pianobar as follows

mkfifo /path/to/myfifo
pianobar >/dev/null 2>&1 &

You'll probably want to be sure the fifo is removed between each start.  This can be done with any sort of check beforehand that `rm`s the fifo if it's there, or simply

rm /path/to/myfifo >/dev/null 2>&1

which will remove it if it's there, or not complain (visibly) if it isn't.

EDIT: I guess I need to give the relevant part too ... then you just have your voice-to-text convert your verbal commands to pianobar text commands, and write them to the fifo.

myvoicetool > /path/to/myfifo

Last edited by Trilby (2013-04-05 15:57:58)

• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.


Board footer

Powered by FluxBB