macruby で声を出してみた ― 2011/05/22 20:55
# macrubyで が サンプルあったので
# おはようを言わせてみた
# macruby ***.rb
# 以下 ソースです
framework 'AppKit'
class AppDelegate
def applicationDidFinishLaunching(notification)
voice_type = "com.apple.speech.synthesis.voice.GoodNews"
@voice = NSSpeechSynthesizer.alloc.initWithVoice(voice_type)
end
def windowWillClose(notification)
puts "Bye!"
exit
end
def say_japan(sender)
@voice.startSpeakingString("o ha yo oh !")
puts "おはよう !"
end
end
app = NSApplication.sharedApplication
app.delegate = AppDelegate.new
window = NSWindow.alloc.initWithContentRect([200, 300, 300, 100],
styleMask:NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask,
backing:NSBackingStoreBuffered,
defer:false)
window.title = 'MacRuby: The Definitive Guide'
window.level = NSModalPanelWindowLevel
window.delegate = app.delegate
button = NSButton.alloc.initWithFrame([80, 10, 120, 80])
button.bezelStyle = 4
button.title = 'おはよう!'
button.target = app.delegate
button.action = 'say_japan:'
window.contentView.addSubview(button)
window.display
window.orderFrontRegardless
app.run
# おはようを言わせてみた
# macruby ***.rb
# 以下 ソースです
framework 'AppKit'
class AppDelegate
def applicationDidFinishLaunching(notification)
voice_type = "com.apple.speech.synthesis.voice.GoodNews"
@voice = NSSpeechSynthesizer.alloc.initWithVoice(voice_type)
end
def windowWillClose(notification)
puts "Bye!"
exit
end
def say_japan(sender)
@voice.startSpeakingString("o ha yo oh !")
puts "おはよう !"
end
end
app = NSApplication.sharedApplication
app.delegate = AppDelegate.new
window = NSWindow.alloc.initWithContentRect([200, 300, 300, 100],
styleMask:NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask,
backing:NSBackingStoreBuffered,
defer:false)
window.title = 'MacRuby: The Definitive Guide'
window.level = NSModalPanelWindowLevel
window.delegate = app.delegate
button = NSButton.alloc.initWithFrame([80, 10, 120, 80])
button.bezelStyle = 4
button.title = 'おはよう!'
button.target = app.delegate
button.action = 'say_japan:'
window.contentView.addSubview(button)
window.display
window.orderFrontRegardless
app.run
voiceの種類 ― 2011/05/22 21:12
nsspeechsynthesizerクラスの音の種類 全部はテストしてないので どんな声か解らない
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSSpeechSynthesizer_Class/Reference/Reference.html
com.apple.speech.synthesis.voice.Agnes
com.apple.speech.synthesis.voice.Albert
com.apple.speech.synthesis.voice.Alex
com.apple.speech.synthesis.voice.BadNews
com.apple.speech.synthesis.voice.Bahh
com.apple.speech.synthesis.voice.Bells
com.apple.speech.synthesis.voice.Boing
com.apple.speech.synthesis.voice.Bruce
com.apple.speech.synthesis.voice.Bubbles
com.apple.speech.synthesis.voice.Cellos
com.apple.speech.synthesis.voice.Deranged
com.apple.speech.synthesis.voice.Fred
com.apple.speech.synthesis.voice.GoodNews
com.apple.speech.synthesis.voice.Hysterical
com.apple.speech.synthesis.voice.Junior
com.apple.speech.synthesis.voice.Kathy
com.apple.speech.synthesis.voice.Organ
com.apple.speech.synthesis.voice.Princess
com.apple.speech.synthesis.voice.Ralph
com.apple.speech.synthesis.voice.Trinoids
com.apple.speech.synthesis.voice.Vicki
com.apple.speech.synthesis.voice.Victoria
com.apple.speech.synthesis.voice.Whisper
com.apple.speech.synthesis.voice.Zarvox
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSSpeechSynthesizer_Class/Reference/Reference.html
com.apple.speech.synthesis.voice.Agnes
com.apple.speech.synthesis.voice.Albert
com.apple.speech.synthesis.voice.Alex
com.apple.speech.synthesis.voice.BadNews
com.apple.speech.synthesis.voice.Bahh
com.apple.speech.synthesis.voice.Bells
com.apple.speech.synthesis.voice.Boing
com.apple.speech.synthesis.voice.Bruce
com.apple.speech.synthesis.voice.Bubbles
com.apple.speech.synthesis.voice.Cellos
com.apple.speech.synthesis.voice.Deranged
com.apple.speech.synthesis.voice.Fred
com.apple.speech.synthesis.voice.GoodNews
com.apple.speech.synthesis.voice.Hysterical
com.apple.speech.synthesis.voice.Junior
com.apple.speech.synthesis.voice.Kathy
com.apple.speech.synthesis.voice.Organ
com.apple.speech.synthesis.voice.Princess
com.apple.speech.synthesis.voice.Ralph
com.apple.speech.synthesis.voice.Trinoids
com.apple.speech.synthesis.voice.Vicki
com.apple.speech.synthesis.voice.Victoria
com.apple.speech.synthesis.voice.Whisper
com.apple.speech.synthesis.voice.Zarvox
最近のコメント