SpokestackBuilder

@objc
public class SpokestackBuilder : NSObject

Fluent builder interface for configuring Spokestack.

  • Example: using all the builder functions

    let spokestack = try! SpokestackBuilder()
    .addDelegate(self)
    .usePipelineProfile(.vadTriggerAppleSpeech)
    .setConfiguration(SpeechConfiguration)
    .setProperty("tracing", Trace.Level.DEBUG)
    .setDelegateDispatchQueue(DispatchQueue.main)
    .build()
    

See also

Spokestack

  • Create a Spokestack builder with a default configuration.

    Declaration

    Swift

    @objc
    public override init()
  • Delegate events will be sent to the specified listener.

    Declaration

    Swift

    @objc
    public func addDelegate(_ delegate: SpokestackDelegate) -> SpokestackBuilder

    Parameters

    listener

    A SpokestackDelegate instance.

    Return Value

    An updated instance of SpokestackBuilder

  • Applies configuration from SpeechPipelineProfiles to the current builder, returning the modified builder.

    Declaration

    Swift

    @objc
    public func usePipelineProfile(_ profile: SpeechPipelineProfiles) -> SpokestackBuilder

    Parameters

    profile

    Name of the profile to apply.

    Return Value

    An updated instance of SpokestackBuilder for call chaining.

  • Sets a SpeechConfiguration configuration value.

    Note

    “tracing” key must have a value of Trace.Level, eg Trace.Level.DEBUG.

    Declaration

    Swift

    @objc
    public func setProperty(_ key: String, _ value: Any) -> SpokestackBuilder

    Parameters

    key

    Configuration property name

    value

    Configuration property value

    Return Value

    An updated instance of SpeechPipelineBuilder for call chaining.

  • Replaces the default speech configuration with the specified configuration.

    Warning

    All preceeding setProperty calls will be erased by setting the configuration explicitly.

    Declaration

    Swift

    @objc
    public func setConfiguration(_ config: SpeechConfiguration) -> SpokestackBuilder

    Parameters

    config

    An instance of SpeechConfiguration that the pipeline will use.

  • Delegate events will be sent using the specified dispatch queue.

    Declaration

    Swift

    @objc
    public func setDelegateDispatchQueue(_ queue: DispatchQueue) -> SpokestackBuilder

    Parameters

    queue

    A DispatchQueue instance

    Return Value

    An updated instance of SpeechPipelineBuilder for call chaining.

  • Sets a transcript editor used to alter ASR transcripts before they are classified by the NLU subsystem.

    If a transcript editor is set, registered listeners will still receive the didRecognize event from the speech pipeline with the unedited transcript, but the editor will automatically run on that transcript before the NLU module operates on it. Thus, the utterance inside the NLUResult returned by classification will reflect the edited version of the transcript.

    This can be used to alter ASR results that frequently contain a spelling for a homophone that’s incorrect for the domain; for example, an app used to summon a genie whose ASR transcripts tend to contain “Jen” instead of “djinn”.

    Note

    Transcript editors are not run automatically on inputs to the classify(string:) convenience method.

    Declaration

    Swift

    @objc
    public func setTranscriptEditor(_ editor: TranscriptEditor) -> SpokestackBuilder

    Parameters

    editor

    A transcript editor used to alter ASR results before NLU classification.

    Return Value

    An updated instance of SpeechPipelineBuilder for call chaining.

  • Build this configuration into a Spokestack instance.

    Throws

    An NLUError if the NLU module was unable to build.

    Declaration

    Swift

    @objc
    public func build() throws -> Spokestack

    Return Value

    An instance of Spokestack.