First skill - can't get mycroft to play SomaFM MP3 URL

I’m a first-time skill maker and a relative newbie to Python. But I wanted to create a simple skill to learn more about how to build Mycroft skills. My thought was a simple play command for playing SomaFM streams.

I’ve seen a number of radio playing skills but rather than try to get those working, I want to create a simple skill to learn.

So I used mycroft-msk to create a basic skill. I followed/reviewed the code of similar skills like news, and followed a Common Playback Framework tutorial on Mycroft’s site. The resulting skill seems to be valid, and works as expected with 1 omission: Mycroft goes to play the MP3 URL and makes no sound at all.

I was following a more complex skill’s capabilities, because when I install that skill I see Mycroft does stream SomaFM if I speak the right command: GitHub - hughwilliams94/radio-browser-skill: Find and play radio streams using Mycroft

But then I found all sorts of skills doing this simple task all sorts of different ways. The CPF documentation doesn’t seem helpful to me…

So I’m hoping the community of skill builders can help me out. Here’s my skill: GitHub - kbridger/somafm-player-skill: Plays somafm streams

Here’s the logs when I trigger the skill successfully

 23:30:37.332 | INFO     | 203218 | Playback Control Skill | Resolving Player for: salad
 23:30:44.102 | INFO     | 203218 | Playback Control Skill | Playing with: somafm-player-skill
 23:30:44.187 | INFO     | 203218 | SomafmPlayer | Playing from:
 23:30:44.230 | INFO     | 203218 | Playback Control Skill | Audio service status: {}

What happens is Mycroft speaks as expected, and then silence. No audio. I am almost certain that it isn’t related to Mycroft but rather my skill, because I was able to get this working with some other skills.

Any advice on how to properly get Mycroft to stream SomaFM? Should it be a CPF skill? Am I not using that correctly? Help and insight appreciated!

1 Like

I added a lot of self.log.log() calls so as to better understand what the code is doing.

-Mike Mac

I went through the logging video here: Logging - Mycroft AI I’ve got all sorts of logs working and I can see that everything is working from my skill side. But I think the URL is being passed to the Mycroft code and I’m not sure what’s happening in there.

I switched to debug mode in the CLI, and see nothing being output. I’m not sure how to trace things back through the code but will be trying that next. Basically I see

20:01:27.514 | INFO     | 603909 | Playback Control Skill | Audio service status: {}

and I want to understand if this is usual, how to output more about what’s going on in the Mycroft code so I can follow the flow of info.

I’ve confirmed that mycroft.conf has mpg123 as the MP3 player, and that playing the URL from the same terminal does play it properly.

So how do I dig into what’s going on in the Mycroft code? Is it just following the python rabbit hole?

I’m in the same boat.

So I add/massage some log messages in the common playback skill:

$ pwd
$ diff
<"handle_next(): Moving to next track")
<"handle_prev(): Moving to previous track")
<"handle_pause(): Pausing audio")
<"handle_play(): Playing audio")
<'stop(): Audio service status: '
>'Audio service status: '
<"play(): Resolving Player for: "+phrase)
>"Resolving Player for: "+phrase)
<   "_play_query_timeout(): CommonPlay Resolution: {}".format(search_phrase))
>             self.log.debug("CommonPlay Resolution: {}".format(search_phrase))
<       "_play_query_timeout(): {} using {}".format(handler["conf"],
>                 self.log.debug("    {} using {}".format(handler["conf"],
<           "_play_query_timeout(): Skills tied, choosing randomly")
>           "Skills tied, choosing randomly")
<           "_play_query_timeout(): Skills: " +
>                     self.log.debug("Skills: " +
<       "_play_query_timeout(): Playing with: {}".format(selected["skill_id"]))
>       "Playing with: {}".format(selected["skill_id"]))
<       "_play_query_timeout(): No matches")
>       "   No matches")

It’s a start, I plan to refine over the next week or so.

Hope this helps.

-Mike Mac

@kirkb I had the same desire and idea, I think it would be pretty neat to have a SomaFM skill for my MarkII, now running Neon. Is there current documentation, community success recipe, or advice on the current “correct” way to play an audio stream off the web? ( SomaFM appears to be ICEcast, if that makes any difference).