Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Create spoken caller ID ringtones for iPhone via AppleScript iOS devices
For a long time, I've wanted the ability for the iPhone to speak the name of the caller, based on matching the inbound number to the numbers in Contacts. I waited and waited for iPhone OS 2.x ad then 3.x to do this for me, and do it better, but got sick of waiting. So instead, I wrote an AppleScript app I call Contact Caller ID + Sound Ringtone Maker [44KB download; Mac OS X Hints mirror (v 1.1)]. I've used this script to generate over 100 in-use ringtones, and use it to customize a ringtone for a contact or two almost daily now.

This AppleScript will generate a spoken name file, optionally looking for first, last, and nicknames, for selected Address Book Contacts. For example, "Jennifer Frickin' Connelly is calling....". It will optionally add a traditional (or other) ringtone of your choice to either the beginning or end of a new spoken-text ringtone file:

"Rob Griffiths is calling... [old phone ring here]; [repeat]"
"[old phone ring here] ... Steve Jobs is calling... ; [repeat]"

The script will then add that newly-created file to iTunes, ready for your next sync with iPhone.

You may optionally enter Custom Text (hint: phonetic spelling) when Alex fails to pronounce some of your more exotic friends' and family's names. But it is worth easily minutes of giggles to hear what he comes up with on his own.

You can test these custom entries over and over until you are ready to commit to a finished ringtone. You may enter any text you wish spoken, but the longer it is, the bigger the finished ringtone file, and the longer it takes to repeat a loop on your phone. I suggest six to ten seconds, with 30 seconds max. There's a reason most ringtones are short; don't try to make 'In a Gadda Da Vida' into a ringtone.

On that note, I have not tested this script with overly large add-on ringtones; QuickTime may slow down considerably when trying to export very large files, and may thus produce timing and/or timeout errors. If your files hang, try smaller ones, or add delays after the export command in the script. If you still have problems, try this script with this Old Ring.m4r ringtone.

Make one ringtone first and try it out on your iPhone before you make a bunch. While you can just make them all again (this script is designed to overwrite existing same-name files), you may want to use QuickTime to permanently adjust the volume in your source add-on file to be louder or quieter. There's nothing to do for the spoken portion of the ringtone without manual manipulation, on a case by case basis in QuickTime. It would require a different routine to combine these automatically, and I don't really care to implement it.

This script was written and tested for iTunes 8.2 using QuickTime Player Pro 7.6.2 and Quicktime Player (non-Pro) 7.6.2 and Mac OS X 10.5.7 on a Mac Pro Quad 2.8Ghz; no other compatibility testing has been performed, but if you have problems, I will try to help.

I really don't know if it will work reliably on all file types without QuickTime Pro (or especially with slower hardware). I have only tested this script against AAC, AIFF, SND, MOV, CAF and MPEG files; you may require QuickTime Pro to use other file types. One weird thing is that you cannot export using the File menu in non-Pro QuickTime Player, but you can use AppleScript's QuickTime library to export anyway. You can switch off the QuickTime check below if it works OK for you as is.

This Script should be installed to ~/Library/Scripts/Applications/Address Book, and run via the Scripts Menu or FastScripts for best performance. Google either for instructions to enable. Alternatively, you may open and run the script via Script Editor (or other AppleScript engine), or use Save As... to save it as an Application and run manually, but it will be slower and dialogs won't show up where you expect, as I've designed it to run in background.

You can also add activate commands to improve performance in QuickTime, if you are willing to leave the keyboard and mouse alone while it's working. If you screw around, you will likely lose the clipboard. On that note, do not use the clipboard while making large batches of ringtones! This script relies on copy/replace.

You can change the spoken voice with the global useVoice variable at the top of the page.

You can set QuickTime export quality to a higher setting than default 128kbps/Better settings; on my first run I just set it manually once in QuickTime, then used 'Most Recent Settings'. Later I had it yank a static link to a better profile in my home folder for permanent use when I add a new contact to Address Book and subsequent Ringtone.

It is possible to have System Events or Standard Additions write a temporary QuickTime export profile to disk, then ask QuickTime to use that profile when exporting. I have included the QuickTime settings file for 192kbps in an inactive routine at the end of this file; feel free to get it working as an option, or just use the profile as a static link on disk. Change ExportHigh to true if you want to play with it. Read the AppleScript dictionary for generating and using QuickTime settings profiles. Why Quicktime Player, especially Pro, won't just let me save and use a profile is beyond me. You could probably add a profile to the plist and get it to show up in QuickTime Pro using defaults write via shell.

Finally, I have not written any significant AppleScripts in five years; there's some stupid workarounds and improper use of globals, etc.; I also wish I had had time to use script properties. I'd love for someone to clean up and return said clean code. The script is pretty obvious in its variables and uses per naming conventions, but I've applied pretty liberal comments for newbies. I have no interest in really improving it myself, as it suits my own limited purposes, but I'd love to relearn where i should have done better. Someone really should wrap this in AppleScript Studio, Smile, or, better, just make it over in Objective C and make it free, of course.

[robg adds: I tested this for a couple of contacts, and it worked as described.]
    •    
  • Currently 2.64 / 5
  You rated: 5 / 5 (11 votes cast)
 
[29,610 views]  

Create spoken caller ID ringtones for iPhone via AppleScript | 21 comments | Create New Account
Click here to return to the 'Create spoken caller ID ringtones for iPhone via AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Create spoken caller ID ringtones for iPhone via AppleScript
Authored by: sfgecko on Jun 30, '09 08:31:52AM

i've actually done this manually for a few of my contacts, so i've been looking for a script like this to automate the process.

however when i tried to make one with a ringtone + name, i get an applescript error:

QuickTime Player got an error: Can't make {} into type integer.

in the script editor, this line gets highlighted:
document (index of (every window whose name is RingPlusName & "." & ext))

this occurs after i select the .m4r ringtone file i want to use with the name. the m4r file opens in quicktime, then it shows the error.



[ Reply to This | # ]
Create spoken caller ID ringtones for iPhone via AppleScript
Authored by: sfgecko on Jun 30, '09 08:55:06AM

ok i figured it out. when quicktime opens some m4r files, it doesn't show the extension in the title of the window. so instead of showing abc.m4r, it just show abc in the quicktime player window title. so in the script i just removed the part where it's looking for the .m4r extension in the line i mentioned above:

& "." & ext

script works fine now. thanks!



[ Reply to This | # ]
Create spoken caller ID ringtones for iPhone via AppleScript
Authored by: tgp_tgp on Jun 30, '09 12:13:34PM

I'm getting the same error, but removing " & "." & ext" didn't help. Great idea for a script, and I imagine this is an obstacle that can be overcome.



[ Reply to This | # ]
Create spoken caller ID ringtones for iPhone via AppleScript
Authored by: Frederico on Jun 30, '09 01:54:53PM

Heya,

You know about the only source file I did not test against was M4R. Go figure. All my best sound source files are in AIFF format.

I will thrown some in and see what I can come up with. Probably just need a simple if/or statement to account for the extension being displayed or not.

Sorry for the failure; I tested and tested and tested before submission, but there's always at least one use scenario you overlook.

F



[ Reply to This | # ]
Create spoken caller ID ringtones for iPhone via AppleScript
Authored by: Frederico on Jun 30, '09 03:26:50PM
I've tested this with several different M4R files now, and even when naming with extension off and setting the file to hide extensions, I can't get this to replicate without creating a non-m4r file masquerading as one.

Still, I can provide a probable workaround; please test and let me know if this works so I can add it and fix some other bugs and re-upload.



-- Under:

if (addRingtone is true) then -- open and copy data from an existing sound file
open RingPlusPath -- open our ringtone add-on

-- ... Replace this:

			set RingPlus to document (index of (every window whose name is RingPlusName & "." & ext)) --  tested against multiple open docs

 -- ...with  this:

			try
				set RingPlus to document (index of (every window whose name is RingPlusName & "." & ext)) --  tested against multiple open docs
			on error
				try
					set RingPlus to document (index of (every window whose name is RingPlusName)) --  only partially tested; cannot replicate reported problem
				on error errMSG number errNUM
					display dialog (errNUM as string) & ": " & errMSG & return & return & 
					"Sorry I must abort this script; there is a problem with the name or extension of the add-on source you chose. 
					Please try another type (kind) of sound source file, and please report this error to Frederico AHT mac DAHT com"
					return
				end try
			end try

			-- end replace

tell ringplus -- etc.; leave this line intact from here on


[ Reply to This | # ]
Create spoken caller ID ringtones for iPhone via AppleScript
Authored by: sfgecko on Jun 30, '09 07:54:33PM

it gets past the previous error, but now i get an error at the end that says:

"This operation could not be completed. You really shouldn't be getting an error here..."

and the process cancels. so i just changed it back to this and it works fine:

set RingPlus to document (index of (every window whose name is RingPlusName))



[ Reply to This | # ]
Create spoken caller ID ringtones for iPhone via AppleScript
Authored by: sfgecko on Jun 30, '09 08:13:47PM
here's a sample ringtone if you want to test out your code:

http://drop.io/vhdftuq

[ Reply to This | # ]
Create spoken caller ID ringtones for iPhone via AppleScript
Authored by: Frederico on Jun 30, '09 10:43:46PM

Cool; thanks; that offered the answer as to why:

The file you provided has the annotated file attribute 'Title' assigned to the display name less the extension. iTunes does not do this when creating AAC(MP4) files, nor does Quicktime do so by default when doing a standard Export.

One may assign such attributes (e.g., Author, Album, Comment, etc.) as you may in iTunes MP3 and AAC metatags that are embedded in the file itself. So, whomever created this file had a reason to add the title Attribute, and QT respected the Title as listed, instead of displaying the file name as title, which is default.

I should have predicted this; sorry for the trouble.

Now, that said, my error handler works perfectly on this end. Would love to understand what is happening on your side, but I understand if you are satisfied with your changes and don't have the time.

If you do, let me know message me and I will send you a test script with more detailed error handling to try out.

Cheers

Rico



[ Reply to This | # ]
Create spoken caller ID ringtones for iPhone via AppleScript
Authored by: sfgecko on Jul 01, '09 09:02:39AM

i'd like to figure out why it's throwing an error for me. it seems to fail right after it tries to export the new file. you're not getting an error when you use the ringtone file i shared?



[ Reply to This | # ]
Create spoken caller ID ringtones for iPhone via AppleScript
Authored by: Frederico on Jul 01, '09 11:53:32PM

No, I am not. Contact me directly, please, and let's work on it. My email is in the script and in the error message. Can't recall if you can message me from my name link on this post. -- F



[ Reply to This | # ]
Create spoken caller ID ringtones for iPhone via AppleScript
Authored by: Frederico on Jun 30, '09 02:20:23PM
Just been working with another reader in email.

Turns out that, even though heavily tested, I missed a small piece of syntax that fails when this script is saved as a standalone application. Until I can correct and test, you will have to run from a script menu with Address Book in focus or directly in Script Editor; only run the latter if you are familiar with SE and know how to switch between apps to find dialogs that may present in SE, QT or AB while running.

Sorry about that.

You can activate Script Menu (free, and already on your machine) by opening /Applications/AppleScript/AppleScript Utility; then switch on 'Show Script Menu'

You will then need to save the script I gave you to ~/Library/Scripts/Applications/Address Book/, (in your own home folder path) and you will probably have to create the last two folders. But if you intend to use it more than once, it is worth the effort.

You can learn about FastScripts (also free, but nice if you pay for) here:

<http://www.apple.com/downloads/macosx/system_disk_utilities/fastscripts.html>;



[ Reply to This | # ]
Creating the scripts folders easily
Authored by: u2mr2os2 on Jun 30, '09 06:05:25PM

Once you turn on the scripts menu, open Address Book, then in the script menu at the top, choose: "Open Scripts Folder > Open Address Book Scripts Folder". This will create the required folders under ~/Library/Scripts and open the folder. Works for any other app as well.



[ Reply to This | # ]
Add Ringtone Before AND After
Authored by: rajington on Jun 30, '09 09:05:36PM
Call me gimmicky but I love that whole "fade out" "fade in" thing that the iPhone does when people call you. No, I didn't add fading to this, that's way beyond my capability but I did add the ability to add a song before AND after a spoken name. It's my first time using AppleScript so it's really bad code but it works.

Download here

It's up to you to create a file that fades out to put before it and another one that fades in to put after it. You can use the free Audacity or try out Amadeus 2 (my preferred editor)

I definitely would've been completely lost without Frederico's great code and comments, and of course because he made it completely "open source" so-to-speak. He easily could've gotten a couple of bucks off of this if he sold it (at least from me!). I apologize for the bad code but my skill isn't anywhere close to his.

Note that I also removed the "call from".

[ Reply to This | # ]
Add Ringtone Before AND After
Authored by: Frederico on Jun 30, '09 10:12:42PM

Heya,

Thanks for the kind words; I'm glad it was of use to you.

But I'm a bit confused; my script already offered the ability to place the ringtone either before, after, or none at all, to a spoken name (or any text you like via custom entry).

Was this not clear, or did you not get the option to choose position in the third dialog????



[ Reply to This | # ]
Add Ringtone Before AND After
Authored by: palahala on Jul 01, '09 02:39:48AM

Like you wrote yourself: it seems the original can add a ringtone EITHER before OR after the spoken text. The adjusted versions seems to allow for a ringtone BOTH before AND after the text?

However, I wonder how useful a ringtone BOTH before AND after the text is, given the fact that the sequence is repeated? :-)



[ Reply to This | # ]
Create spoken caller ID ringtones for iPhone via AppleScript
Authored by: rajington on Jul 01, '09 07:00:32PM

yeah, i agree it doesn't make too much sense and probably is only useful for me i just posted it in case anyone else is weird like me.

1. no vibrate-then-ring (circa 1990?) feature on iPhone! this way you can put silence so it just vibrates, then says the name, then ringtone.

2. i don't like people hearing who's calling me, especially if i'm hanging out with random people. this gives me time before it says "MOM AND DAD". I only need about 4 seconds, doing "song before" with a 4 second song works but i don't like it looping the whole thing 5 times.

3. usually if it's in my coat or in the other room i can't get to it in time to clearly hear the name if i put it before, this gives me more time.



wow, just writing it all down makes me sound more insane. i never knew i was this picky.



[ Reply to This | # ]
Create spoken caller ID ringtones for iPhone via AppleScript
Authored by: Frederico on Jul 02, '09 02:09:04AM

No, you're not terribly weird at all. I misunderstood your modification would put the ringtone both in front *and* behind. Truthfully, it errored when I did try it, and I wasn't terribly motivated to debug your mods without understanding why the given options were not enough.

If would not be hard at all to modify to add to both ends, either spoken or sounds, but I'm not sure of the utility for most, as the poster above points out, the continued recycle of the ringtone when played on the iPhone effectively creates the alternating pattern, anyway.

Now, that said, you seem to indicate what *YOU* really want is '[silence]-[spoken name]-[sound]', repeat.

You can actually do this yourself pretty easily by just adding silence to each ringtone created by my script using GarageBand or QT. If you want it automated, you could easily script it to post-process anything my script creates.

Now, this as an aside, I really miss my Sony Ericsson T-68i; it allowed you to create not only groups of callers to which you could assign ringtones and vibrate yes/no en masse, but you could also create locations, and tell the phone how to behave for each group, group type (business, family, friends, etc.), for each location.

I've repeatedly sent this feature suggestion to Apple, but until they implement genuine Groups in Contacts to begin with, event the first part is impossible.

Oh, and the silent ring thing? I've got a bunch of telemarketers who call me all the time; I just add their phone numbers to a single contact and assigned a custom all-silent ringtone to it. I still get vibrate, when enabled, but otherwise I know not to answer.



[ Reply to This | # ]
Create spoken caller ID ringtones for iPhone via AppleScript
Authored by: palahala on Jul 02, '09 10:14:49AM

Ok, you've mentioned it, now you'll have to create it somehow: a morse code vibrating thingy! :-)



[ Reply to This | # ]
Doesn't work if there are no ringtones in iTunes - add a ringtone before running the script
Authored by: chill2k on Jul 01, '09 09:48:49PM

FYI:

I had never installed any ringtones into iTunes, and so when I tried running the script from the script menu nothing happened.

I then tried the script from the Script Editor and received an error message informing me that there was an invalid path to the ringtones.

I added a single ringtone to iTunes, now the script runs fine.



[ Reply to This | # ]
Doesn't work if there are no ringtones in iTunes - add a ringtone before running the script
Authored by: Frederico on Jul 02, '09 12:01:38AM

OK, now, I tested for this; the script should not have actually errored; it should have prompted you to find or create a Ringtones folder -- any folder location will work with the script, as long as you have read/write permissions.

Another poster had problems running this as a saved Application (applet), and now you seem to indicate you ran this from the iTunes script menu? Not the Address Book using Script Menu or Fast Scripts?

I did not test for that variable; my instructions indicate where to install and how to run it from AB or SE; it is possible that the command to find the Ringtones folder breaks if iTunes is the overall app running it, not Address Book.

Any reason why you ran it from iTunes, not AB?

I will retest this portion of the script, though, and see what I can come up with.

F



[ Reply to This | # ]
Create spoken caller ID ringtones for iPhone via AppleScript
Authored by: MacTodd on Dec 26, '09 07:08:50PM
I don't want to 'double dip', so here's a link to my other post on this topic.

There's now an app for that (AutoRingtone - www.AutoRingtone.com, and it's FREE (though for more advanced features and commercial voices, it's just $0.99 for AutoRingtone PRO)

http://www.macosxhints.com/comment.php?mode=view&cid=114707

[ Reply to This | # ]