Make VoiceOver speak the currently playing track in iTunes with a global hotkey

With the release of Apple Music Radio, I've found the need for quickly checking the title and artist of the currently playing song in iTunes, even when I'm not in the app. I wrote an AppleScript to do that.
It can be assigned to a key in keyboard commander if desired. Here's the code, simply paste it into the script editor and save it where you keep your other scripts:

tell application "iTunes"
if player state is playing then
set myTrack to name of current track
set myArtist to artist of current track
end if
end tell
tell application "VoiceOver" to say (myTrack & ", by " & myArtist)

Tags: 

Disclaimer

The guide on this page has generously been submitted by a member of the AppleVis community. As AppleVis is a community-powered website, we make no guarantee, either express or implied, of the accuracy or completeness of the information contained in this guide.

4 Comments

#1 Script additions

Hello Malthe,
thanks for the excellent idea and script!
Once I began playing with your script, I thought that it would be a great idea to further extend its capabilities. For example, I wanted the script to be able to recognize other playback states (paused, stopped) and to reduce playback volume while announcing the currently playing track. I've actually never written an Apple Script before, but with some research I was actually able to achieve just what I wanted!
Here's my modified version of the script:

tell application "iTunes"
if player state is playing then
set myTrack to name of current track
set myArtist to artist of current track
set myVolume to sound volume
set sound volume to 50
tell application "VoiceOver" to say (myTrack & ", by " & myArtist)
set sound volume to myVolume
end if
end tell
tell application "iTunes"
if player state is paused then
tell application "VoiceOver" to say ("Playback is currently paused.")
end if
end tell
tell application "iTunes"
if player state is stopped then
tell application "VoiceOver" to say ("Playback is currently stopped.")
end if
end tell

Well, there it is! I'm really not sure if this is the most elegant approach with all those if statements, since I'm sure there's gotta be an 'else' somewhere... Additionally, if your iTunes volume is actually less then 50% when you run this then yes, it will increase your volume rather than reducing it! But like I said I really have zero experience with Apple Script, so I'm just really happy about the fact that I actually managed to get this done! :-)

#2 Another one

Some time ago I played around with the same idea and I wanted my script reading name and artist of a song for whatever is playing. This one should also work for internet radio:

on isVoiceOverRunning()
set isRunning to false
tell application "System Events"
set isRunning to (name of processes) contains "VoiceOver"
end tell
return isRunning
end isVoiceOverRunning

on isVoiceOverRunningWithAppleScript()
if isVoiceOverRunning() then
set isRunningWithAppleScript to true

-- is AppleScript enabled on VoiceOver --
tell application "VoiceOver"
try
set x to bounds of vo cursor
on error
set isRunningWithAppleScript to false
end try
end tell
return isRunningWithAppleScript
end if
return false
end isVoiceOverRunningWithAppleScript

tell application "iTunes"
set playingornot to player state

if playingornot is playing then
set urlwatcher to current stream URL
set urlwatcher2 to current stream title
set tracktitle to name of current track
set trackartist to artist of current track
set list2display to {trackartist, " - ", tracktitle}
if urlwatcher is missing value then
set musicdisplay to "Playing: " & list2display as text
else
set musicdisplay to "Playing: " & urlwatcher2
end if
else
if playingornot is paused then
set urlwatcher to current stream URL
set urlwatcher2 to current stream title
set tracktitle to name of current track
set trackartist to artist of current track
set list2display to {trackartist, " - ", tracktitle}
if urlwatcher is missing value then
set musicdisplay to "Paused: " & list2display as text
else
set musicdisplay to "Paused: " & urlwatcher2
end if
else
set musicdisplay to "Nothing is playing."
end if
end if

end tell

if isVoiceOverRunningWithAppleScript() then
tell application "VoiceOver"
output musicdisplay
end tell
else
say musicdisplay
delay 2
end if

#3 apple script

hi there is there a easy way to learn how to do apple script for blind people?

#4 Found a keyboard shortcut

You can get this functionality with the app Bowtie. http://bowtieapp.com

I can get my system to read out my song name and artist by hitting Control+Shift+S. iTunes does not need to be in focus and this keyboard shortcut also works with Spotify.