Created
July 29, 2012 03:30
-
-
Save yhirose/3195925 to your computer and use it in GitHub Desktop.
MacRuby
This file contains 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
#------------------------------------------------------------------------------ | |
# play_sound | |
#------------------------------------------------------------------------------ | |
def play_sound(url_string) | |
url = NSURL.URLWithString(url_string) | |
s = NSSound.alloc.initWithContentsOfURL(url, byReference: false) | |
s.delegate = self | |
s.play | |
end | |
def sound(sound, didFinishPlaying: state) | |
end | |
#------------------------------------------------------------------------------ | |
# alertOk | |
#------------------------------------------------------------------------------ | |
def alertOk(caption, message) | |
NSAlert.alertWithMessageText(caption, | |
defaultButton: "OK", | |
alternateButton: nil, | |
otherButton: nil, | |
informativeTextWithFormat: message).runModal | |
end | |
#------------------------------------------------------------------------------ | |
# say | |
#------------------------------------------------------------------------------ | |
def say(text) | |
NSSpeechSynthesizer.availableVoices().each do |voice_type| | |
voice = NSSpeechSynthesizer.alloc.initWithVoice(voice_type) | |
voice.startSpeakingString(text) | |
while voice.isSpeaking | |
end | |
voice = nil | |
end | |
end | |
#------------------------------------------------------------------------------ | |
# gntp | |
#------------------------------------------------------------------------------ | |
require 'rubygems' | |
require 'ruby_gntp' | |
GNTP.notify({ | |
:app_name => "TestMacRuby", | |
:title => "Voice Name", | |
:text => vt, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment