This forum has been archived. All content is frozen. Please use KDE Discuss instead.

remotely rate songs and announce titles with lirc and espeak (w/example .lircrc)

Tags: None
(comma "," separated)
seventyeights
Registered Member
Posts
3
Karma
0
No one asked, but I thought it might help if I posted what I managed to accomplish in ubuntu feisty today. It seems that no one has covered this yet.

I can already use my streamzap remote to control amarok's basic functions, but I added the ability to give a rating (w/ voice feedback) and to vocally announce the artist, title, or current rating.

For example, I figured out that you can open a terminal and announce the current song with the following line:
Code: Select all
$ dcop amarok player title | tee >(espeak -s 100 -v english)

(dcop pulls the info from amarok, then tee sends the info to espeak)

However, this command will not work with irexec in the .lircrc file! Does anyone know why?
Code: Select all
begin
   prog   = irexec
   button = BLUE
   config = dcop amarok player title | tee >(espeak -s 100 -v english)
end



Anyway, heres my workaround...

I made three text files with the following names:

amarok_say_artist
Code: Select all
dcop amarok player artist | tee 1>/home/seventyeights/out.txt | espeak -s 100 -v english -f /home/seventyeigths/out.txt


amarok_say_title
Code: Select all
dcop amarok player title | tee 1>/home/seventyeights/out.txt | espeak -s 100 -v english -f /home/seventyeights/out.txt


amarok_say_rating
Code: Select all
dcop amarok player rating | tee 1>/home/seventyeights/out.txt | espeak -s 100 -v english -f /home/seventyeights/out.txt


(Dcop pulls the info from amarok, tee puts the info in a text file, then espeak reads the text file.)

Then I made the three files executable:
Code: Select all
$ chmod +x amarok_say_artist
$ chmod +x amarok_say_title
$ chmod +x amarok_say_rating


I can run the files in two ways:
Code: Select all
$ ./amarok_say_title
$ exec /home/seventyeights/amarok_say_title


Now that that those are set up, here they are at the end of my .lircrc:
Code: Select all
#begin amarok
begin
       prog   = irexec
       button = MUTE
       config = dcop amarok player mute
end

begin
       prog   = irexec
       button = PAUSE
       config = dcop amarok player playPause
end


begin
   prog = irexec
   button = STOP
   config = dcop amarok player stop
end

begin
   prog = irexec
   button = >>|
   config = dcop amarok player next
end

begin
   prog = irexec
   button = |<<
   config = dcop amarok player prev
end

begin
   prog = irexec
   button = VOL_UP
   repeat = 1
   config = dcop amarok player volumeUp
end

begin
   prog = irexec
   button = VOL_DOWN
   repeat = 1
   config = dcop amarok player volumeDown
end

begin
       prog   = irexec
       button = 1
       config = dcop amarok player setRating 1 | espeak -v english 1
end

begin
       prog   = irexec
       button = 2
       config = dcop amarok player setRating 2 | espeak -v english 2
end

begin
       prog   = irexec
       button = 3
       config = dcop amarok player setRating 3 | espeak -v english 3
end

begin
       prog   = irexec
       button = 4
       config = dcop amarok player setRating 4 | espeak -v english 4
end

begin
       prog   = irexec
       button = 5
       config = dcop amarok player setRating 5 | espeak -v english 5
end

begin
       prog   = irexec
       button = 6
       config = dcop amarok player setRating 6 | espeak -v english 6
end

begin
       prog   = irexec
       button = 7
       config = dcop amarok player setRating 7 | espeak -v english 7
end

begin
       prog   = irexec
       button = 8
       config = dcop amarok player setRating 8 | espeak -v english 8
end

begin
       prog   = irexec
       button = 9
       config = dcop amarok player setRating 9 | espeak -v english 9
end

begin
       prog   = irexec
       button = 0
       config = dcop amarok player setRating 10 | espeak -v english ten
end

begin
   prog   = irexec
   button = RED
   config = exec /home/seventyeights/amarok_say_artist &

end

begin
   prog   = irexec
   button = GREEN
   config = exec /home/seventyeights/amarok_say_title &

end

begin
   prog   = irexec
   button = BLUE
   config = exec /home/seventyeights/amarok_say_rating &

end

#end amarok

(The & helps keep irexec from hanging on that line.)

You can see a list of other amarok functions by typing:
Code: Select all
$ dcop amarok player


I hope this gives you enough info to figure it out if you are trying to set something like this up yourself.
User avatar
dangle_wtf
Moderator
Posts
1252
Karma
0
nice work! I love it when people come up with unique ways to interface with Amarok :)


"There are two theories to arguing with women. Neither one works."
.
If men could get pregnant, we'd learn the true meaning of "screaming nancyboy wuss"


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot], Yahoo [Bot]