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

Create a radio station with announcements via Nicecast Apps
I love my music library, iTunes, and I love news. I have used this hint in the past to automate insertion of CNN and NPR news podcasts into the current Party Shuffle, where I can enjoy music with CNN at the top and NPR at the bottom of the hour.

When I discovered Nicecast last year, I began enjoying my own radio station at work with news and New Music Tuesdays continuously. While debugging a modification to the original AppleScript which would also use the AppleScript say command to announce the time, I accidentally discovered that the time would announce via Nicecast, given activation of iTunes. Read on to see the series of scripts I use...

To announce current song or play Party Shuffle: To speak the time: Radio station ID: Play New Music Tuesday (NMT) uses this hint:
-- Insert the newest iTunes NMT update into the party shuffle, if we're listening to it.
tell application "System Events"
  if (name of processes) contains "iTunes" then
    tell application "iTunes"
      -- Get the newest iTunes news update
      set podcastPlaylist to playlist "Podcasts"
      tell podcastPlaylist
        set iTunesUpdates to (every track whose artist is "Apple Inc." and date added is greater than ((current date) - 961 * minutes))
        -- Only add the very latest update.
        set iTunesUpdate to (a reference to item 1 of iTunesUpdates)
      end tell
      -- Don't insert this if we're not listening to the Party Shuffle
      if (player state is playing and name of current playlist is "Party Shuffle") then
        my ps_play_next_ref(iTunesUpdate)
        say ("Eye Tunes New Music Tuesday Broadcast, up next.")
      end if
    end tell
  end if
end tell
-- Append Ref to Party Shuffle after current song
  on ps_play_next_ref(theTrackReference)
    tell application "iTunes"
      set thePlaylist to playlist "Party Shuffle"
      try
        play thePlaylist
        set isPlaying to container of current track is thePlaylist
        if (isPlaying) then set startIndex to index of current track
      on error
          set isPlaying to false
          set startIndex to 0
      end try
    tell thePlaylist
      set oldTracks to a reference to (every track whose index > startIndex and index is less than or equal to (count tracks))
      duplicate theTrackReference to thePlaylist
      duplicate oldTracks
      delete oldTracks
    end tell
  end tell
end ps_play_next_ref
[robg adds: I haven't tested these scripts.]
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[10,229 views]  

Create a radio station with announcements via Nicecast | 9 comments | Create New Account
Click here to return to the 'Create a radio station with announcements via Nicecast' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Create a radio station with announcements via Nicecast
Authored by: Undertakr on Apr 07, '08 11:41:31PM

How do you use these scripts? Are you cron'ing them? What interval? How do you get the announce song title script to announce at the beginning of each new song (or randomly at the start or end of each song?) It looks like it just triggers when you launch it. You didn't explain HOW you use the scripts.

Thanks



[ Reply to This | # ]
Create a radio station with announcements via Nicecast
Authored by: Señor Epiphyte on Apr 09, '08 08:29:13PM

My original submission must have been too wordy, it was edited...sorry:

* The trigger for beginning of a song I don't have figured out yet, but I am tinkering with countdown timers and such...
* The remainder of your question is related to cron settings. cron intervals for news are hourly, NMT I limit to Tues-Wed and Sat, etc...you make the call.

Reference to the prior, linked hint for how to use cron.



[ Reply to This | # ]
Create a radio station with announcements via Nicecast
Authored by: Señor Epiphyte on Apr 09, '08 09:15:51PM

This is where I am with the announcements. I am trying to decide whether to:

* run a single script forever...perhaps timeout if iTunes isn't running for 5 minutes.
* Call the script every five to 6 minutes with cron and capture most songs.
* other

-- Play Party Shuffle to keep it going.
tell application "System Events"
if (name of processes) contains "iTunes" then
tell application "iTunes"
-- Don't insert this if we're not listening to the Party Shuffle
if (player state is playing) then

set currenttrack to the name of current track
set currentartist to the artist of current track
set tracktime to the duration of current track
set trackremainder to the player position
set waittime to (tracktime - trackremainder)

-- back off a bit from the end to allow for crossfade and say it before the song is completed
delay (waittime - 10)
say "That was"
say (currenttrack)
say "by"
say (currentartist)

else
-- If we're not listening to the Party Shuffle, then we should
say time string of (current date)
say "Me Likey Music!"
play playlist "Party Shuffle"

end if
end tell
end if
end tell



[ Reply to This | # ]
Create a radio station with announcements via Nicecast
Authored by: DougAdams on Dec 22, '08 09:42:54AM

Put it in a stay-open script application with an idle handler.

---
Doug's AppleScripts for iTunes
dougscripts.com



[ Reply to This | # ]
Create a radio station with announcements via Nicecast
Authored by: BMurray on Apr 19, '08 10:14:14PM

This looks like a great hint!

I'm having some trouble getting the audio to work perfectly. When the speech is broadcast i can hear the music and the speech slow down and they are pitch shifted lower. When the speech stops, the music goes back to the correct speed and pitch.

I've tried a few different quality settings in Nicecast, thinking that it was a bitrate incompatibility or something, but the several settings I tried all seem to have the same issue.

If I try the voice without any music playing, it sounds correct.

Anyone else experiencing this same thing?



[ Reply to This | # ]
Create a radio station with announcements via Nicecast
Authored by: Señor Epiphyte on Dec 22, '08 08:33:59AM

I have noticed that but can't figure a solution, the best bet is to try calculations to interrupt songs at the end or beginning rather than mid.

I will post my current solution.



[ Reply to This | # ]
Cause iTunes to Speak, But at Track End
Authored by: Señor Epiphyte on Dec 22, '08 09:13:06AM
Sort of a work around for the slowing of music and track information as the script 'speaks' over the song by moving the vocalization to the end of the track.

I can't figure out how to post code here or in the forum so here's my best attempt at providing a path-to-update.

http://macosx.com/forums/apple-scripts/304816-cause-itunes-speak-track-names-cron.html


[ Reply to This | # ]
Cause iTunes to Speak, But at Track End
Authored by: Señor Epiphyte on Dec 22, '08 04:20:10PM
tell application "System Events"
	if (name of processes) contains "iTunes" then
		-- First let's be sure the application is active, if not then we abort
		tell application "iTunes"
			
			if (player state is playing and name of current playlist is "Party Shuffle") then
				-- Don't insert this if we're not listening to the Party Shuffle, because that would be rude
				
				set currenttrack to the name of current track
				set currentartist to the artist of current track
				
				set tracklength to (duration of current track)
				
				if tracklength < 300 then
					-- long songs are typically news items or podcasts, so we'll skip them because they aren't fun
					-- for shorter songs then we will calculate position
					
					set waittime to (((tracklength) - (player position)) - 12)
					--back off a bit from the end to allow for crossfade and say

					delay waittime
					say "That was "
					say (currenttrack)
					say "by"
					say (currentartist)
					
				else
					-- if it is a long track, then lets say something radio station-ish or comment this out if not desireable
					say "Hope you are enjoying roddy rotten dot calm!"
					say "The time is currently"
					say time string of (current date)
					
				end if
				
			end if
		end tell
	end if
end tell


[ Reply to This | # ]
Cause iTunes to Speak, But at Track End
Authored by: BMurray on Oct 04, '11 04:42:42PM

I realize this is thread is a few years old now...

Anyway, I created a wonderful personal radio station script that I've been enjoying for the past few years. I recently upgraded the machine that it was running on from PPC to Intel.

And now I cannot seem to get the same results with Applescript say.

tell application "System Events"
if (name of processes) contains "iTunes" then
tell application "iTunes"
say "testes 1 2 3, wait, 3 testes?"
end tell
end if
end tell

This script does not have the same effect that it once did. I do not hear speech coming thru Nicecast when it's source is iTunes.

Nicecast v1.10.0
iTunes v10.4.1

I've tried several of the [Advanced] settings from the audio source dialog in Nicecast, no change.

Can anyone with a newer machine / setup reproduce this?

Thanks



[ Reply to This | # ]