View Single Post
gobuki's Avatar
Posts: 60 | Thanked: 46 times | Joined on Jan 2010 @ Europe
#19
Here is a little script i hacked together that does ... or better ... would speak the number of the caller.

Code:
#!/usr/bin/env python
import gobject, dbus
from dbus.mainloop.glib import DBusGMainLoop
from subprocess import call
from subprocess import Popen

tempfile = "/tmp/espeak.tmp.wav"

def handle_call(obj_path, callernumber):
    if (callernumber != ''):
        print "%s is calling" % callernumber
        speak("%s is calling" % callernumber)
    else:
        print "caller id not submitted"
        speak("unknown caller")
        

def speak(msg):
  call(["/usr/bin/espeak", "-w", tempfile, msg])
  call(["/usr/bin/mplayer","-ao","pulse", tempfile])
   
speak("waiting for incoming calls")   
DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()
bus.add_signal_receiver(handle_call, path='/com/nokia/csd/call', dbus_interface='com.nokia.csd.Call', signal_name='Coming')
gobject.MainLoop().run()
I use the this dirty tempfile hack because i don't know a way (if there is one) to make espeak use pulse.
The only real problem is i can't get mplayer to keep playing. When a call is coming in while i listen to something, at first i get .4s silence, then the ringtone is played. And if i quickly hang up the last digits of the caller id are spoken.

I put this into my /etc/pulse/xpolicy.conf and rebooted btw. But it didn't help.
Code:
[stream]
exe   = mplayer
group = alwayson
Edit:

I tried group = ringtone. That didn't work either.

You might also want to take a look at Arto Rusanens eSpeakCaller which is more of a real implementation than this script. I just discovered it through this thread: http://talk.maemo.org/showthread.php?t=34982
__________________
Zen master ordering a hotdog: "Make me one with all!"

Last edited by gobuki; 2010-03-23 at 00:46. Reason: typo
 

The Following 4 Users Say Thank You to gobuki For This Useful Post: