maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Overriding ringtone with a custom sound (https://talk.maemo.org/showthread.php?t=45723)

pillar 2010-02-24 19:27

Overriding ringtone with a custom sound
 
I am in the lookout of someone in the knowhow of how it would be possible to override ringtone on incoming call with a custom sound. Now before you think I'm crazy, I have a very specific use case for this: Saying out loud the caller id (default feature on symbian).

This feature has been requested and discussed in here.

It seems that the ringtone has very high priority and will override other sounds and do not yield for other sounds until over. Is it possible to get around this? I would like it so that ringtone is muted for a second or two and the name is said then. After that the ringtone is continued.

This might require deep platform information and if you know a contact from Nokia that could tell more, that would be appreciated.

maxximuscool 2010-02-24 19:37

Re: Overriding ringtone with a custom sound
 
ummm by far that I know off it's not yet possible with N900. Or should I say it may not possible.

Swirnoff 2010-02-24 19:56

Re: Overriding ringtone with a custom sound
 
EDIT: nm, didnt read your post through

ndi 2010-02-24 20:05

Re: Overriding ringtone with a custom sound
 
Oh dear God I want that so much. It's invaluable to driving to know who calls so you know whether to ignore and call later or if it's an emergency or if it's worth getting up.

I would certainly buy/donate on that.

I'm thinking it can be worked around via a ringtone that naturally mutes/fades to lower from second 2 to second 5, allowing the speech synth to be heard. One still needs the hook for the ringing event. I saw voice synth is already available via CLI so that should be easy.

Just execute the CLI command on second 2 and remember to break it if there's answer event - you don't want voice-over-voice.

I can live with a sagging volume curve ringtone.

pillar 2010-02-24 20:20

Re: Overriding ringtone with a custom sound
 
The problem is that ringtone overrides all other sounds if started beforehand, if started during ringtone, they are never heard. The sound level of ringtone is irrelevant.

I think this is not possible without the aid of Nokia, that's why I also asked for contacts.

ndi 2010-02-24 22:11

Re: Overriding ringtone with a custom sound
 
Ok, how about no ringtone and the app plays itself?

pillar 2010-02-24 22:23

Re: Overriding ringtone with a custom sound
 
Quote:

Originally Posted by ndi (Post 545016)
Ok, how about no ringtone and the app plays itself?

Interesting idea, doesn't seem to be possible to select no ringtone at all though.

ndi 2010-02-24 22:29

Re: Overriding ringtone with a custom sound
 
How about an extension of the silent profile?

Does it still play but at no volume or is it muted? Maybe a custom silent profile with the already-available applications could cut it, since an app is not bound forcefully to silent profile guidelines.

qwerty12 2010-02-24 22:53

Re: Overriding ringtone with a custom sound
 
I believe the file /usr/share/policy/etc/current/pulse/xpolicy.conf may shed some light into the situation. Search for "ringtone" and look at the rest of the file to figure out how to get your program tagged as one that plays ringtones.

pillar 2010-02-25 11:54

Re: Overriding ringtone with a custom sound
 
Great tip qwerty12. The file looks like the right place to try stuff. Since I am using espeak inside my app I tried this:

[stream]
exe = espeak
group = ringtone

.. but nothing seemed to change.

robbie 2010-02-25 12:06

Re: Overriding ringtone with a custom sound
 
Quote:

Originally Posted by pillar (Post 545676)
Great tip qwerty12. The file looks like the right place to try stuff. Since I am using espeak inside my app I tried this:

[stream]
exe = espeak
group = ringtone

.. but nothing seemed to change.

Just a hunch. Did you restart? Some settings are only loaded once.

pillar 2010-02-25 12:09

Re: Overriding ringtone with a custom sound
 
Quote:

Originally Posted by robbie (Post 545702)
Just a hunch. Did you restart? Some settings are only loaded once.

Yeah, I tried once without a restart and then again after restart, I had the same hunch :)

Matan 2010-03-04 23:18

Re: Overriding ringtone with a custom sound
 
Try

group = alwayson

Programs in this group can play while a ringtone is playing.

pillar 2010-03-09 14:29

Re: Overriding ringtone with a custom sound
 
Tried always on, but didn't notice any difference.

Matan 2010-03-09 14:36

Re: Overriding ringtone with a custom sound
 
It works for me:

Added
Code:

[stream]
exe = mplayer
group = alwayson

To /etc/pulse/xpolicy.conf (it is a sym link to the same file).

Created a silent mp3 and set it as ringtone (it works with noisy ringtone as well, but easier with silent).

Rebooted phone (to make sure all changes take effect).

Played an mp3 file using mplayer (-ao pulse).

Called the N900 (using skype, as I don't have a SIM in it. This is the only issue that might matter in my opinion).

mplayer continues to play while the phone is "ringing".

I also tried starting mplayer while ringing, and it also works.

Where does your experience deviate from mine?

lcuk 2010-03-22 01:07

Re: Overriding ringtone with a custom sound
 
this is a decent idea, i can see why you miss it.
some questions which need answering:

is there a dbus message emitted when a call starts ringing? (assume yes)
does it have enough info to lookup the contacts database? (assume yes)
can you get flite to play the contacts name? (assume yes)
can we use the contacts database to store custom ringtone? (assume yes)

integrate the ui with the contacts database and allow per contact selection: std/custom/named

nice little extension with minimal effort and would make people happy (based on this and other threads) :)

pillar 2010-03-22 08:16

Re: Overriding ringtone with a custom sound
 
@lcuk Dbus message is emitted and it contains the phone number, which is enough to look for the contact. I'm not familiar with flite, have been using espeak to test this. No idea about the contacts database being able to store custom ringtones. It would also need a way to override the original completely.
I am all for it though, if someone can help to override the ringtone!

@Matan: I haven't tried with mplayer, only with espeak and alwayson. Maybe I should try with mplayer too since with espeak just saying a name can go pretty fast and is not ideal for troubleshooting the issue. Thanks.

volt 2010-03-22 19:54

Re: Overriding ringtone with a custom sound
 
Neat thread, real progress on a somewhat important feature. Kudos.

gobuki 2010-03-23 00:14

Re: Overriding ringtone with a custom sound
 
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

ndi 2010-03-24 01:50

Re: Overriding ringtone with a custom sound
 
I'm not sure if this has been suggested before, I understand little of the above. Still, I waa thinking:

If e-speak is hard to run but mplayer works, how about pre-rendered wave files? Some program runs through all the numbers and renders a number.wav with contact name in it.

No need to look anything up at ring time, just get the incoming number and play the number.wav. E.g. 0123456789.mp3/wav/whatever would have a voice that says "Jim" in plain English.

pillar 2010-03-24 08:36

Re: Overriding ringtone with a custom sound
 
Arto Rusanens eSpeakCaller worked. I don't know what is different. The only problem is that the ringtone doesn't get muted when it says the caller's name, which makes it quite hard to hear it. But I think this is already quite nice.

ndi 2010-03-24 14:39

Re: Overriding ringtone with a custom sound
 
That's easily fixable by editing the ringtone to lower volume between seconds 3 and 6, e.g.


All times are GMT. The time now is 01:12.

vBulletin® Version 3.8.8