Skip to content

Instantly share code, notes, and snippets.

@CodeOfficer
Created June 11, 2009 18:06
Show Gist options
  • Save CodeOfficer/128120 to your computer and use it in GitHub Desktop.
Save CodeOfficer/128120 to your computer and use it in GitHub Desktop.
require 'tempfile'
def say(cmd, voice='Fred')
temp_file = Tempfile.new('sayfile')
tf = File.new(temp_file.path, "w+")
tf.puts(cmd)
tf.close
`cat #{temp_file.path} | /usr/bin/say -v #{voice}`
temp_file.unlink
end
def ding_dong
say("Ding dong!", 'Bells')
end
def echo_date
t = Time.now
say(t.strftime("The time is now %I %p"))
end
ding_dong
sleep 1
echo_date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment