Mac Developer Library

Developer

AppKit Framework Reference NSSpeechRecognizer Class Reference

Options
Deployment Target:

On This Page
Language:

NSSpeechRecognizer

The NSSpeechRecognizer class is the Cocoa interface to Speech Recognition on OS X. Speech Recognition is architected as a “command and control” voice recognition system. It uses a finite state grammar and listens for phrases in that grammar. When it recognizes a phrase, it notifies the client process. This architecture is different from that used to support dictation. More...

Inheritance


Conforms To


Import Statement


import AppKit @import AppKit;

Availability


Available in OS X v10.3 and later.
  • Initializes and returns an instance of the NSSpeechRecognizer class.

    Declaration

    Swift

    init()

    Objective-C

    - (instancetype)init

    Discussion

    Returns nil if initialization did not succeed.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Returns an array of strings defining the commands for which the receiver should listen.

    Declaration

    Swift

    var commands: [AnyObject]?

    Objective-C

    @property(copy) NSArray *commands

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Sets the list of commands for which the receiver should listen to commands.

    Declaration

    Swift

    var commands: [AnyObject]?

    Objective-C

    @property(copy) NSArray *commands

    Discussion

    If the receiver is already listening, the current command list is updated and listening continues. commands should be an array of NSString objects. The commands must be in U.S. English.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.3 and later.

    See Also

    – commands

  • Returns the title of the commands section or nil if there is no title.

    Declaration

    Swift

    var displayedCommandsTitle: String?

    Objective-C

    @property(copy) NSString *displayedCommandsTitle

    Discussion

    Commands are displayed in the Speech Commands window indented under a section with this title.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Sets whether the speech-recognition commands should be displayed indented under a section title in the Speech Commands window, and if so, sets the title string to display.

    Declaration

    Swift

    var displayedCommandsTitle: String?

    Objective-C

    @property(copy) NSString *displayedCommandsTitle

    Discussion

    When title is a non-empty string, the receiver’s commands are displayed under a section with title. If title is nil or an empty string, the commands are displayed at the top level of the Speech Commands window. This default is not to display the commands under a section title.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Returns whether the receiver should only enable its commands when the receiver’s application is the frontmost one.

    Declaration

    Swift

    var listensInForegroundOnly: Bool

    Objective-C

    @property BOOL listensInForegroundOnly

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Sets whether the receiver should only enable its commands when the receiver’s application is the frontmost one.

    Declaration

    Swift

    var listensInForegroundOnly: Bool

    Objective-C

    @property BOOL listensInForegroundOnly

    Discussion

    If flag is YEStrue, the receiver’s commands are only recognized when the receiver’s application is the frontmost application—normally the application displaying the menu bar. If flag is NOfalse, the commands are recognized regardless of the visibility of applications, including agent applications (agent applications, which have the LSUIElement property set, do not appear in the Dock or Force Quit window). The default is YEStrue.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Returns whether the receiver should block all other recognizers (that is, other applications attempting to understand spoken commands) when listening.

    Declaration

    Swift

    var blocksOtherRecognizers: Bool

    Objective-C

    @property BOOL blocksOtherRecognizers

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Sets whether the receiver’s commands should be the only enabled commands on the system.

    Declaration

    Swift

    var blocksOtherRecognizers: Bool

    Objective-C

    @property BOOL blocksOtherRecognizers

    Discussion

    If flag is YEStrue, all other speech recognition commands on the system are disabled until the receiver object is released, listening is stopped, or this method is called again with flag as NOfalse. Because this option effectively takes over the computer at the expense of other applications using speech recognition, you should use it only in circumstances that warrant it, such as when listening for a response important to overall system operation or when an application is running in full-screen mode (such as games and presentation software). The default is NOfalse.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Returns the receiver’s delegate.

    Declaration

    Swift

    unowned(unsafe) var delegate: NSSpeechRecognizerDelegate?

    Objective-C

    @property(assign) id<NSSpeechRecognizerDelegate> delegate

    Return Value

    The receiver’s delegate.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Sets the receiver’s delegate.

    Declaration

    Swift

    unowned(unsafe) var delegate: NSSpeechRecognizerDelegate?

    Objective-C

    @property(assign) id<NSSpeechRecognizerDelegate> delegate

    Parameters

    anObject

    The delegate to set as the receiver’s. The delegate must conform to the NSSpeechRecognizerDelegate Protocol protocol.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.3 and later.

    See Also

    – delegate

  • Tells the speech recognition engine to begin listening for commands.

    Declaration

    Swift

    func startListening()

    Objective-C

    - (void)startListening

    Discussion

    When a command is recognized the message speechRecognizer:didRecognizeCommand: is sent to the delegate.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Tells the speech recognition engine to suspend listening for commands.

    Declaration

    Swift

    func stopListening()

    Objective-C

    - (void)stopListening

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.3 and later.