As I promised in my last post, A Twitter account for Oliver, I have been working on a bark-to-text translator for Oliver's twitter account (@OliverBarkBark). The overall process ended up being rather simple. Since the original recordings often capture multiple bark sounds, I needed to split the audio files into distinct barks. With that done, all that was left classifying the different bark noises that Oliver makes. For that I reused the pyAudioAnalysis library from the bark vs. junk classification step in detecting Oliver's barks.

However, due to some issues that I'll get into shortly, Oliver's current, random tweets are going to remain the way they are. This bark-to-text project will go unused, but will still be available on the Github page for this project.

Anyway, onto the details. Here is a typical clip of Oliver barking as captured by the raspberry pi setup:

As you can hear, multiple bark sounds are often captured in the same file. In order to classify each distinct bark, I needed to separate each of the sounds out. I used a thresholding system similar to what I used to capture the clips originally, but this time I had access to the whole clip and could therefore look at the level of the background noise which made things a bit easier.

My final solution took the maximum amplitude of the audio over some period to get an approximate volume. After throwing arbitrary constants at the problem for about half an hour, I settled on a period of 2500 samples (about 0.05 seconds) and assumed that a bark started when the volume between two periods at least doubled. I then split the audio file along start of each bark and end up with rather well separated bark sounds.

Here are examples of a few of the different sounds that Oliver makes:

A "bark":

A "woof":

With the splitting accomplished, it was fairly simple to reuse the classification process from the original project on each separate bark sound and produce a string accurate to the original audio file. Here are some examples of the end result:

  • Woof bark bark bark bark
  • Bark bark bark
  • Bark
  • Bark bark
  • Bark bark bark bark
  • Bark
  • Bark
  • Woof
  • Bark bark
  • Bark
  • Woof
  • Woof
  • Bark bark

Now you might start to see why I chose not to implement this fully. Oliver just does not produce enough distinct kinds of barks. Most of his barks can only be transcribed as "bark," and so it all starts to look very similar and boring. However, it is more than that. Twitter's API, as part of a spam filtering system, will ignore any tweets that match any of your "recent" tweets. So, not only does this provide less of an entertaining experience than the random tweets, most of them will just be blocked and we can't have that.