Platforms to show: All Mac Windows Linux Cross-Platform
/MacCocoa/Speech/NSSpeechRecognizer
Required plugins for this example: MBS MacCocoa Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCocoa/Speech/NSSpeechRecognizer
This example is the version from Sat, 19th Jul 2013.
Project "NSSpeechRecognizer.xojo_binary_project"
FileTypes
Filetype text
End FileTypes
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
EventHandler Sub Open()
if TargetMachO=false then
MsgBox "This example needs a MachO target running on Mac OS X."
quit
end if
RecognizerWindow.Show
End EventHandler
End Class
Class RecognizerWindow Inherits Window
Control List Inherits ListBox
ControlInstance List Inherits ListBox
EventHandler Sub Change()
if me.ListIndex=-1 then
RemoveButton.Enabled=False
else
RemoveButton.Enabled=true
end if
End EventHandler
End Control
Control AddButton Inherits PushButton
ControlInstance AddButton Inherits PushButton
EventHandler Sub Action()
List.AddRow EditField1.text
EditField1.text=""
End EventHandler
End Control
Control EditField1 Inherits TextField
ControlInstance EditField1 Inherits TextField
EventHandler Sub TextChange()
if me.text="" then
AddButton.Enabled=false
else
AddButton.Enabled=true
end if
End EventHandler
End Control
Control RemoveButton Inherits PushButton
ControlInstance RemoveButton Inherits PushButton
EventHandler Sub Action()
List.RemoveRow(List.ListIndex)
End EventHandler
End Control
Control PushButton3 Inherits PushButton
ControlInstance PushButton3 Inherits PushButton
EventHandler Sub Action()
dim a(-1) as string
dim i,c as integer
c=List.ListCount-1
redim a(c)
for i=0 to c
a(i)=List.Cell(i,0)
next
s.SetCommands a
End EventHandler
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action()
s.StartListening
End EventHandler
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action()
s.StopListening
End EventHandler
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control lastword Inherits Label
ControlInstance lastword Inherits Label
End Control
EventHandler Sub Open()
s=new MyNSSpeechRecognizerMBS
s.DisplayedCommandsTitle = "Realbasic"
End EventHandler
Property Protected s As MyNSSpeechRecognizerMBS
End Class
Class MyNSSpeechRecognizerMBS Inherits NSSpeechRecognizerMBS
EventHandler Sub DidRecognizeCommand(command as string)
dim d as date
d=new date
RecognizerWindow.lastword.text=command+" at "+d.LongTime
End EventHandler
End Class
End Project
The items on this page are in the following plugins: MBS MacCocoa Plugin.