Manages interactions with the sandai iframe, including sending and stopping speech messages.

Constructors

Methods

  • Transforms the options sent to the iframe, including:

    • audio files sent through [options.audioFile]

    The array it returns contains all the references that should have their ownership transferred

    Parameters

    • options: undefined | { audioFile?: string | ArrayBuffer | Blob | File }

    Returns Promise<
        | { options: {}; references: never[] }
        | { options?: undefined; references: ArrayBuffer[] },
    >

  • Cleans up all registered message event listeners previously added by _listenForMessage. Call this method when the instance is being destroyed or no longer needs to listen to messages.

    Returns void

  • Sends a message to make the character respond using the built-in LLM, and waits for a response.

    Parameters

    • message: string

      The message content the model responds to.

    • Optionalcontext: string

      Optional context for the model.

    Returns Promise<string>

    Resolves with the model's response.

  • Sends a message to make the character say something, and waits until speech has started.

    Parameters

    • message: string

      The message content to be spoken.

    • Optionaloptions: { audioFile?: string | ArrayBuffer | Blob | File }

    Returns Promise<void>

    Resolves when the iframe signals that speech has started.

  • Sends a message to make the character stop speaking, and waits until speech has actually stopped.

    Returns Promise<void>

    Resolves when the iframe signals that speech has stopped.