RealtimeTTSPlayer
Methods
addEventListener
addEventListener(event: , callback: Function
): void
Adds a handler for the specified PlayerEvents event. Use only functions as handlers; anything except a function leads to the error and scenario termination when a handler is called.
Parameters
event:
Event class (i.e., PlayerEvents.PlaybackFinished)
callback:
Function
Handler function. A single parameter is passed - object with event information
Returns
type:
void
append
Use RealtimeTTSPlayer.sendText instead
append(text: string
, endOfTurn: false
| true
): void
Append text to a ElevenLabs.RealtimeTTSPlayer.The [Player.PlaybackFinished] event is triggered only if this method is called.
Parameters
text:
string
A text string to append
endOfTurn:
false
OptionalWhether to force audio generation. Set this value to true when you have finished sending text, but want to keep the websocket connection open<br><br>This is useful when you want to ensure that the last chunk of audio is generated even when the length of text sent is smaller than the value set in chunk_length_schedule (e.g. 120 or 50)
Returns
type:
void
id
id(): string
Returns the player's id.
Returns
type:
string
pause
pause(): void
Pauses playback. To continue the playback use the Player.resume method.
Returns
type:
void
removeEventListener
removeEventListener(event: , callback: Function
): void
Removes a handler for the specified PlayerEvents event.
Parameters
event:
Event class (i.e., PlayerEvents.PlaybackFinished)
callback:
Function
OptionalOptional. Handler function. If not specified, all handler functions are removed
Returns
type:
void
sendMediaTo
sendMediaTo(mediaUnit: , parameters: ): void
Starts sending media from the player to the media unit.
Parameters
mediaUnit:
Media unit that receives media
parameters:
OptionalOptional. WebSocket interaction only parameters
Returns
type:
void
sendText
sendText(parameters: Object
): void
Append text to a ElevenLabs.RealtimeTTSPlayer.
Parameters
parameters:
Object
Object provides the parameters directly to the ElevenLabs provider sendText method. Find more information in the documentation.
Returns
type:
void
stop
stop(): void
Stops playback. The current player's instance is destroyed.
Returns
type:
void
stopMediaTo
stopMediaTo(mediaUnit: ): void
Stops sending media from the player to the media unit.
Parameters
mediaUnit:
Media unit that does not need to receive media from this conference anymore
Returns
type:
void