How to make your own Raspberry Pi Musicbox

This is not about NLP, but I think it is worth sharing, so here we go 😉

I really like the project PiMusicbox, the raspberry pi is just the perfect device to host a music server, especially the model B1, which is also a little bit slow when it comes to video playback. But there are a few drawbacks, like that updates are quite hard and you cannot easily customize it. So I just set up the system in a different way, directly from scrath on Raspbian. In the next steps I show you how.

Thoughts before you start

This is what comes to my mind if someone asks me if she whether should take the normal version of PiMusicbox or mine.

Pros

  • You can update all the time. PiMusicbox you have to reinstall with every new release.
  • You can customize it as you want. The normal PiMusicbox does not provide Podcasts or Files.

Cons

  • Configuration is done manually. You should be able to connect to your pi via ssh. Alternatively use the Websettings package.
  • You do not have a way shutdown button integrated. But you can use RaspiCheck.
  • It is slower. In PiMusicbox a few tweaks are done to improve booting of the system. I did not do that.

Download Raspbian minimal image

You can get this directly from the website of Raspbian: https://www.raspberrypi.org/downloads/raspbian/

Install mopidy + run as system service

In order to start it when the system boots, you only have to type (source)

sudo systemctl enable mopidy

Install add-ons

I used Spotify, Podcast and files, because these are all I use with the raspi. You can get an overview at the documentation of Mopidy. Generally speaking you can download all extensions either via pip or via apt, depending on in which repo they are. This makes it sometimes a little bit confusing, but you’ll find everything, I am sure 😉 You can find all of the extensions for playback (the documentation calls them backend-extensions in the mopidy-documentation).

Also, you need an extension for a HTML-frontend. I used the one made for the PiMusicbox. An overview can be found here.

Mounting your external storage automatically

For this I used usbmount, which is a small programm that just mounts external storage devices automatically. This can of course be done via scripts as  well, but I did not want to mess around with scripts, so I used this approach.

Configurations

The config file for mopidy can be found at /etc/mopidy/mopidy.conf, if you run it as a system service, not in your user’s directory. To shorten this paragraph I just paste my config file here and make some comments:

[core]
cache_dir = /var/cache/mopidy
config_dir = /etc/mopidy
data_dir = /var/lib/mopidy

[logging]
config_file = /etc/mopidy/logging.conf
debug_file = /var/log/mopidy/mopidy-debug.log

[local]
data_dir = /var/lib/mopidy/local
media_dir = /var/lib/mopidy/media

[m3u]
playlists_dir = /var/lib/mopidy/playlists

[musicbox_webclient]
enabled = true


username = # your username
password =  # your password
bitrate = 320 # better sound quality

[http]
hostname=0.0.0.0 # VERY important. Otherwise you cannot reach it from outside

[mpd]
hostname=0.0.0.0 # VERY important. Otherwise you cannot reach it from outside

[podcast]
enabled = true #only need to activate it. 
browse_root = #Path where your .opml-file with all your podcasts is

[file]
enabled = true
media_dirs = /media/usb #this is where your external storage is mounted via usbmount
show_dotfiles = false
follow_symlinks = false
metadata_timeout = 1000

I hope this tutorial helped you.

Bonus: Setting up SMB share

If you have a hard disk connected to your Raspi, you can easily share the files in all your network. I used the tutorial given by putokaz to install and configure it. I just configured it like the share for the torrent files at the end of the tutorial, but this is up to you.

Named Entity Recognition

Named Entities are nouns that – simply speaking – refer to something in the real world. An example would be the noun Los Angeles, which refers to a city in the US, unlike the noun apple, which describes a fruit. For tasks in information retrieval it is very useful to know whether a noun refers to a named entity or not because it is a common task in search to find named entities, for example if you want to make a trip to Los Angeles. It will then be important because people do not want to find information about the two words los and angeles, but information about this particular city.

So how do you recognize it? There are several techniques, that are used and combined. One way is analyzing parts of speech and trying to detect when a certain pattern of for example two nouns occurs (like USB device). Another way is to look at the sentences for keywords that may refer to named entities and then analyze if in this part of the sentence there are named entities. For instance, in patent retrieval new inventions are described in a way that does not make clear what it really means in order to make the patent claims broader. For instance, a floppy disc drive can be

At the end you can combine these techniques with machine learning, so you can mark named entities at a data set and let an algorithm learn, which of the nouns are named entities.

Another difficulty is the mapping of named entities. For example you have a text about politics in Germany. This text talks about the chancellor of Germany. You can use this information, but you still do not know if Angela Merkel or one of her predecessors. You will need more information to figure out about whom this person is talking, like the date when the article was written. Another awesome example is Java, which is an island and a programming language. There is also a book that uses this ambiguity. It is named Java ist auch eine Insel – Java is also an island.

You can find more information about this topic for example at Marrero et al. and more general information at Wikipedia.

Query Clarity

In IR you got your query and from this query you get a result. But how good is this result? One way to measure this is by calculating the clarity of the result. The clarity means – generally speaking – how much the found results differ. You can measure this when you look a the result sets and try to find out how much the words in the found documents differ. Query clarity can tell you, how much ambiguity you have in your query.

Of course there are different ways to calculate the query clarity. The basic model is the one introduced by Cronen-Townsend et al. Others are the Improved Clarity Score by Hauff et al. and the Simplified Clarity Score by He and Ounis.