Last active
August 29, 2015 14:23
-
-
Save mzemel/8c4b20783b085453bc2d to your computer and use it in GitHub Desktop.
Bird sounds for the Raspberry Pi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open-uri' | |
puts "URL: " + (url_string = "http://www.xeno-canto.org/164#{rand(100..999)}/download") | |
begin | |
File.open("sound.mp3", "wb") do |f| | |
open(url_string) do |url| | |
url.each_line {|u| f.write u} | |
end | |
end | |
rescue OpenURI::HTTPError | |
retry | |
end | |
`omxplayer -o local sound.mp3` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Disable login
Put it in a cronjob