My Audio setup

In this article I will give a little big of background to my music system and why I use the certain components.

First, the speakers: I use some speakers which enable me to give input via USB. This has the great advantage I can use whatever computer I want to push the music signals to the speakers. (side note: I am using some speakers by Nubert, which also have digital and analogue input for other sources) My music comes directly from a raspberry pi with Mopidy and Raspotify. These two tools allow me to play basically all the music I have on hard disk or to stream it from the internet. I also programmed some small software, that shows the title and artist on a small display and I added some buttons, so I can pause the track and turn the pi off.

The connection using USB is actually very great since it reduces the amount of cables a lot. Before this, I used an external sound card, which also worked well, but needed more space. Another option would be HiFiBerry, but I do not have any experience about sound quality.

Why did I use this setup and not buy directly speakers like from Sonos or other systems? I like to keep my system as easy to repair and change as possible. My speakers will probably last longer than my raspberry, so I want to able to change the way music comes to the speakers. Also, I want to be able to change my streaming service. All this might or might not be possible using out-of-the-box systems.

And finally, the raspberry pi and mopidy are open systems, where you can add your own code in order to improve your setup.

Raspotify – Turn your pi into a Spotify server

As some of you know I really like to use a raspberry pi as music server. Therefore I want to introduce a nice tool: Raspotify. This little program turns your raspberry pi into a Spotify server as you might also get it when listening on your computer or on other systems like Sonos. The really cool thing is: it just works out of the box and you can use your phone as a remote control. I actually prefer it right now over the usage of Mopidy-Spotify, which has some problems since Spotify is blocking the API more and more. For instance, it is not possible anymore to load playlists.

I do not know if this will improve in the future or if Spotify nudges us to use their service. I would prefer to have a system working directly together with mopidy, still bundles everything, but we will see.

The installation procedure of Raspotify is actually as easy as it can get: you only need to type one command and it does everything. But pay attention to change the settings (in the paragraph Configuration at the page) to get higher quality playback.

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.