Class: Uhlive

Constructors

constructor

+ new Uhlive(identifier: string, token: string, options?: UhliveOptions): Uhlive

Create an Uhlive instance by passing your private token and identifier.

example

const uhlive = new Uhlive("my-identifier", "my-token", {
timeout: 3,
url: "wss://api.uh.live",
});

Parameters:

NameType
identifierstring
tokenstring
options?UhliveOptions

Returns: Uhlive

Events Methods

onClose

onClose(callback: () => void): Uhlive

Subscribe to Uhlive onClose event.

example

const uhlive = new Uhlive("my-identifier", "my-token");
uhlive.onClose(() => {
// Choose what to do when the connection is closed.
});

Parameters:

NameType
callback() => void

Returns: Uhlive


onError

onError(callback: () => void): Uhlive

Subscribe to Uhlive onError event.

example

const uhlive = new Uhlive("my-identifier", "my-token");
uhlive.onError(() => {
// Choose what to do when we encounter an error.
});

Parameters:

NameType
callback() => void

Returns: Uhlive


Other Methods

connect

connect(): Uhlive

Connect to the websocket.

example

const uhlive = new Uhlive("my-identifier", "my-token");
uhlive.connect();

Returns: Uhlive


disconnect

disconnect(): Uhlive

Disconnect from the websocket.

example

const uhlive = new Uhlive("my-identifier", "my-token");
uhlive.connect();
uhlive.join("my-conversation");
uhlive.disconnect();

Returns: Uhlive


join

join(conversationId: string, options: ConversationOptions): Conversation

Join a conversation and start recording immediately.

example

const uhlive = new Uhlive("my-identifier", "my-token");
uhlive.connect();
uhlive.join("my-conversation", {
speaker: "john",
});
uhlive.disconnect();

example

const uhlive = new Uhlive("my-identifier", "my-token");
uhlive.connect();
uhlive.join("my-conversation", {
ignoreEntities: ["NumberFound"],
readonly: true,
wrapper: "my-custom-wrapper",
});
uhlive.disconnect();

Parameters:

NameTypeDefault value
conversationIdstring-
optionsConversationOptions{
        country: this.getCountryFromBrowser(),
        ignoreDecodingEvents: [],
        ignoreEntities: [],
        interim_results: true,
        model: this.getLocaleFromBrowser(),
        origin: 0,
        readonly: false,
        rescoring: true,
        speaker: Uhlive.generateSpeakerId(),
        wrapper: "uhlive",
    } |

Returns: Conversation


leave

leave(conversationId: string): Uhlive

Leave a conversation.

example

const uhlive = new Uhlive("my-identifier", "my-token");
uhlive.connect();
uhlive.join("my-conversation");
uhlive.leave("my-conversation");
uhlive.disconnect();

Parameters:

NameType
conversationIdstring

Returns: Uhlive


leaveAllConversations

leaveAllConversations(): Uhlive

Leave all conversations at once.

example

const uhlive = new Uhlive("my-identifier", "my-token");
uhlive.connect();
uhlive.join("my-conversation1");
uhlive.join("my-conversation2");
uhlive.leaveAllConversations();
uhlive.disconnect();

Returns: Uhlive