Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/conversation-on-hold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@elevenlabs/client": minor
---

Add `setOnHold` / `isOnHold` to voice conversations, for apps that hand control back and forth between the agent and something else on the page. Putting a conversation on hold stops the agent mid-utterance instead of letting it play to completion, silences audio that keeps arriving, mutes the microphone so nothing nearby starts a turn, and sends `user_activity` periodically so the agent does not speak up on its own while it is held. The connection, conversation id and context all stay, so releasing the hold costs no reconnect: the microphone and the volume the caller asked for come back, and audio buffered during the hold is dropped rather than resumed mid-sentence. `setVolume` and `setMicMuted` calls made during a hold are applied when it is released.
4 changes: 4 additions & 0 deletions packages/client/src/BaseConversation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ class TestConversation extends BaseConversation {

public setVolume(): void {}
public setMicMuted(): void {}
public setOnHold(): void {}
public isOnHold(): boolean {
return false;
}
public getInputByteFrequencyData(): Uint8Array {
return new Uint8Array(0);
}
Expand Down
8 changes: 8 additions & 0 deletions packages/client/src/BaseConversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,14 @@ export abstract class BaseConversation {

public abstract setVolume(options: { volume: number }): void;
public abstract setMicMuted(isMuted: boolean): void;
/**
* Puts the conversation on hold, or takes it off hold again. A held
* conversation keeps its connection, its id and its context, but the agent
* is neither heard nor spoken to until the hold is released.
*/
public abstract setOnHold(isOnHold: boolean): void;
/** Whether the conversation is currently on hold. */
public abstract isOnHold(): boolean;
/**
* Returns byte frequency data (0-255) for the input audio, focused on the
* human voice range (100-8000 Hz).
Expand Down
8 changes: 8 additions & 0 deletions packages/client/src/TextConversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ export class TextConversation extends BaseConversation {
throw new Error("setMicMuted is not supported in text conversations");
}

public setOnHold(): void {
throw new Error("setOnHold is not supported in text conversations");
}

public isOnHold(): boolean {
return false;
}

public getInputByteFrequencyData(): Uint8Array {
return EMPTY_FREQUENCY_DATA;
}
Expand Down
Loading