<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSSpeechRecognizer",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSSpeechRecognizer"
  },
  "title" : "NSSpeechRecognizer"
}
-->

# NSSpeechRecognizer

The Cocoa interface to speech recognition in macOS.

```
class NSSpeechRecognizer
```

## Overview

[`NSSpeechRecognizer`](/documentation/AppKit/NSSpeechRecognizer) provides a “command and control” style of voice recognition system, where the command phrases must be defined prior to listening, in contrast to a dictation system where the recognized text is unconstrained. Through an [`NSSpeechRecognizer`](/documentation/AppKit/NSSpeechRecognizer) instance, Cocoa apps can use the speech recognition engine built into macOS to recognize spoken commands. With speech recognition, users can accomplish complex tasks with spoken commands—for example, “Move pawn B2 to B4” and “Take back move.”

The [`NSSpeechRecognizer`](/documentation/AppKit/NSSpeechRecognizer) class has a property that lets you specify which spoken words should be recognized as commands ([`commands`](/documentation/AppKit/NSSpeechRecognizer/commands)) and methods that let you start and stop listening ([`startListening()`](/documentation/AppKit/NSSpeechRecognizer/startListening()) and [`stopListening()`](/documentation/AppKit/NSSpeechRecognizer/stopListening())). When the speech recognition facility recognizes one of the designated commands, [`NSSpeechRecognizer`](/documentation/AppKit/NSSpeechRecognizer) invokes the delegation method [`speechRecognizer(_:didRecognizeCommand:)`](/documentation/AppKit/NSSpeechRecognizerDelegate/speechRecognizer(_:didRecognizeCommand:)), allowing the delegate to perform the command.

Speech recognition is just one of the macOS speech technologies. The speech synthesis technology allows applications to “pronounce” written text in U.S. English and over 25 other languages, with a number of different voices and dialects for each language  ([`NSSpeechSynthesizer`](/documentation/AppKit/NSSpeechSynthesizer) is the Cocoa interface to this technology). Both speech technologies provide benefits for all users, and are particularly useful to those users who have difficulties seeing the screen or using the mouse and keyboard. By incorporating speech into your application, you can provide a concurrent mode of interaction for your users: In macOS, your software can accept input and provide output without requiring users to change their working context.

## Topics

### Creating Speech Recognizers

[`init()`](/documentation/AppKit/NSSpeechRecognizer/init())

Initializes and returns an instance of the `NSSpeechRecognizer` class.

### Handling the Recognition of a Spoken Command

[`delegate`](/documentation/AppKit/NSSpeechRecognizer/delegate)

The delegate for the speech recognizer object.

[`NSSpeechRecognizerDelegate`](/documentation/AppKit/NSSpeechRecognizerDelegate)

A set of optional methods implemented by delegates of [`NSSpeechRecognizer`](/documentation/AppKit/NSSpeechRecognizer) objects.

### Configuring Speech Recognizers

[`commands`](/documentation/AppKit/NSSpeechRecognizer/commands)

An array of strings defining the commands for which the speech recognizer object should listen.

[`displayedCommandsTitle`](/documentation/AppKit/NSSpeechRecognizer/displayedCommandsTitle)

The title of the commands section in the Speech Commands window or `nil` if there is no title.

[`listensInForegroundOnly`](/documentation/AppKit/NSSpeechRecognizer/listensInForegroundOnly)

A Boolean value that indicates whether the speech recognizer object should only enable its commands when its application is the frontmost one.

[`blocksOtherRecognizers`](/documentation/AppKit/NSSpeechRecognizer/blocksOtherRecognizers)

A Boolean value that indicates whether the speech recognizer object should block all other recognizers (that is, other applications attempting to understand spoken commands) when listening.

### Listening

[`startListening()`](/documentation/AppKit/NSSpeechRecognizer/startListening())

Tells the speech recognition engine to begin listening for commands.

[`stopListening()`](/documentation/AppKit/NSSpeechRecognizer/stopListening())

Tells the speech recognition engine to suspend listening for commands.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)