Skip to content

Instantly share code, notes, and snippets.

@mzemel
Last active August 29, 2015 14:23
Show Gist options
  • Save mzemel/8c4b20783b085453bc2d to your computer and use it in GitHub Desktop.
Save mzemel/8c4b20783b085453bc2d to your computer and use it in GitHub Desktop.
Bird sounds for the Raspberry Pi
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`
@mzemel
Copy link
Author

mzemel commented Jun 27, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment