AppleSpeechRecognizer

@objc
public class AppleSpeechRecognizer : NSObject
extension AppleSpeechRecognizer: SpeechProcessor

This pipeline component uses the Apple SFSpeech API to stream audio samples for speech recognition.

Once speech pipeline coordination via startStreaming is received, the recognizer begins streaming buffered frames to the Apple ASR API for recognition. Once speech pipeline coordination via stopStreaming is received, or when the Apple ASR API indicates a completed speech event, the recognizer completes the API request and either sends a timeout or didRecognize event with the updated global speech context (including the speech transcript and confidence).

Public properties

NSObject implementation

  • Initializes a AppleSpeechRecognizer instance.

    A recognizer is initialized by, and receives startStreaming and stopStreaming events from, an instance of SpeechPipeline.

    The AppleSpeechRecognizer receives audio data frames to process from a tap into the system AudioEngine.

    Declaration

    Swift

    @objc
    public init(_ configuration: SpeechConfiguration, context: SpeechContext)

    Parameters

    configuration

    Configuration for the recognizer.

    context

    Global state for the speech pipeline.

  • Triggered by the speech pipeline, instructing the recognizer to begin streaming and processing audio.

    Declaration

    Swift

    @objc
    public func startStreaming()
  • Triggered by the speech pipeline, instructing the recognizer to stop streaming audio and complete processing.

    Declaration

    Swift

    @objc
    public func stopStreaming()
  • Processes an audio frame, recognizing speech.

    Note

    Processes audio in an async thread.

    Remark

    The Apple ASR hooks up directly to its own audio tap for processing audio frames. When the AudioController calls this process, it checks to see if the pipeline is activated, and if so kicks off its own VAD and ASR independently of any other components in the speech pipeline.

    Declaration

    Swift

    @objc
    public func process(_ frame: Data)

    Parameters

    frame

    Audio frame of samples.