Inworld provides a real-time TTS player that can send generated audio to calls, WebSockets, and other VoxEngine media units.
Use Inworld.createRealtimeTTSPlayer(...) to create a RealtimeTTSPlayer for the current scenario. After the player is created, call methods such as send, sendMediaTo, and addEventListener on that player instance.
Use Inworld as the realtime TTS layer in an OpenAI voice pipeline.
See where realtime speech synthesis fits into VoxEngine call flows.
Add the module before using the namespace:
Create a player, send provider messages, and bridge playback with sendMediaTo or VoxEngine.sendMediaBetween.
Creates a new Inworld.RealtimeAPIClient instance.
The required parameters object is typed as Inworld.RealtimeAPI.
Parameters
Returns
Creates a new Inworld.RealtimeTTSPlayer instance. You can attach media streams later via the Inworld.RealtimeTTSPlayer.sendMediaTo or VoxEngine.sendMediaBetween methods.
The optional parameters object is typed as Inworld.RealtimeTTS.
Parameters
Returns
Clears an Inworld.RealtimeTTSPlayer buffer.
Parameters
This method does not accept parameters.
Returns
Send message object to the Inworld provider context.
Parameters
Returns
Example parameters:
Inworld.RealtimeTTSPlayer extends the shared player base (BasePlayer in the typings). Those base methods use the same playback contract documented on the public Player page, and they emit PlayerEvents.
Inherited from the shared player base. See Player.addEventListener.
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
Returns
Inherited from the shared player base. See Player.id.
Returns the player’s id.
Parameters
This method does not accept parameters.
Returns
Inherited from the shared player base. See Player.pause.
Pauses playback. To continue the playback use the Player.resume method.
Parameters
This method does not accept parameters.
Returns
Inherited from the shared player base. See Player.removeEventListener.
Removes a handler for the specified PlayerEvents event.
Parameters
Returns
Inherited from the shared player base. See Player.resume.
Resumes playback after the Player.pause method is called.
Parameters
This method does not accept parameters.
Returns
Inherited from the shared player base. See Player.sendMediaTo.
Starts sending media from the player to the media unit.
Parameters
Returns
Inherited from the shared player base. See Player.stop.
Stops playback. The current player’s instance is destroyed.
Parameters
This method does not accept parameters.
Returns
Inherited from the shared player base. See Player.stopMediaTo.
Stops sending media from the player to the media unit.
Parameters
Returns
These are inherited PlayerEvents. Event callbacks receive the shared player event object; player is the Inworld.RealtimeTTSPlayer instance that emitted the event. Some events include additional playback fields noted below.
Triggers by the createURLPlayer and createTTSPlayer methods when
Event constant: PlayerEvents.PlaybackReady
Payload
Triggered when playback is started. Note that if the createURLPlayer method is called with the onPause parameter set to true, the event is not triggered; it is triggered after the Player.resume method call.
Event constant: PlayerEvents.Started
Payload
Triggers as a result of the Player.stop method call.
Event constant: PlayerEvents.Stopped
Payload
Triggered when playback has finished successfully or with an error.
Event constant: PlayerEvents.PlaybackFinished
Payload
Triggered when playback has finished with an error.
Event constant: PlayerEvents.Error
Payload
Triggered when Player.addMarker is reached.
Event constant: PlayerEvents.PlaybackMarkerReached
Payload
Triggered when an audio file is playing faster than it is being loaded.
Event constant: PlayerEvents.PlaybackBuffering
Payload
Triggered when an audio chunk playback is finished. Note that this event is triggered only for RealtimeTTSPlayer instances.
Event constant: PlayerEvents.AudioChunksPlaybackFinished
Payload