SimliClient is a powerful tool for integrating real-time audio and video streaming capabilities into your web applications using WebRTC. This guide will walk you through the process of setting up and using SimliClient in your project.
Before you begin, make sure you have:
Install the simli-client
package in your project:
First, import the SimliClient
class into your project:
In your React component, create video and audio elements with refs:
Create an instance of SimliClient and initialize it with your configuration:
Make sure to replace 'YOUR_SIMLI_API_KEY'
with your actual Simli API key, and 'YOUR_FACE_ID'
with the desired face ID for your application.
If you’re using listenToMediastreamTrack() set handleSilence: false
to avoid
audio artifacts
Call the start
method to set up the WebRTC connection:
Once the connection is established, you can start sending audio data:
Ensure that your audio data is in PCM16 format with a 16KHz sample rate.
Initialize(config: SimliClientConfig)
: Initializes the SimliClient with the provided configuration.start()
: Sets up the WebRTC connection and prepares for streaming.close()
: Closes the WebRTC connection and cleans up resources.sendAudioData(audioData: Uint8Array)
: Sends audio data to the server.listenToMediastreamTrack(stream: MediaStreamTrack)
: Listens to a MediaStreamTrack and sends audio data to the server. Can be used as an alternative to sendAudioData
.ClearBuffer()
: Clears the audio buffer, best used when you want the avatar to stop talking.connected
when the data channel is open and ready to usedisconnected
when the data channel is closedfailed
when the webRTC connection fails to connectspeaking
when the avatar starts speakingsilent
when the avatar stops speakingSimliClient provides console logging for various events and errors. It’s recommended to implement proper error handling in your application to manage potential issues, such as network disconnections or initialization failures.
The SimliClient uses a default STUN server for ICE candidate gathering. If you need to use custom ICE servers or other WebRTC configurations, you may need to modify the createPeerConnection
method in the SimliClient class.
Fork and contribute to the simli-client repository on GitHub or clone for your own usecase.
If you encounter issues:
Reach out to our support team for further assistance on Discord.
SimliClient is a powerful tool for integrating real-time audio and video streaming capabilities into your web applications using WebRTC. This guide will walk you through the process of setting up and using SimliClient in your project.
Before you begin, make sure you have:
Install the simli-client
package in your project:
First, import the SimliClient
class into your project:
In your React component, create video and audio elements with refs:
Create an instance of SimliClient and initialize it with your configuration:
Make sure to replace 'YOUR_SIMLI_API_KEY'
with your actual Simli API key, and 'YOUR_FACE_ID'
with the desired face ID for your application.
If you’re using listenToMediastreamTrack() set handleSilence: false
to avoid
audio artifacts
Call the start
method to set up the WebRTC connection:
Once the connection is established, you can start sending audio data:
Ensure that your audio data is in PCM16 format with a 16KHz sample rate.
Initialize(config: SimliClientConfig)
: Initializes the SimliClient with the provided configuration.start()
: Sets up the WebRTC connection and prepares for streaming.close()
: Closes the WebRTC connection and cleans up resources.sendAudioData(audioData: Uint8Array)
: Sends audio data to the server.listenToMediastreamTrack(stream: MediaStreamTrack)
: Listens to a MediaStreamTrack and sends audio data to the server. Can be used as an alternative to sendAudioData
.ClearBuffer()
: Clears the audio buffer, best used when you want the avatar to stop talking.connected
when the data channel is open and ready to usedisconnected
when the data channel is closedfailed
when the webRTC connection fails to connectspeaking
when the avatar starts speakingsilent
when the avatar stops speakingSimliClient provides console logging for various events and errors. It’s recommended to implement proper error handling in your application to manage potential issues, such as network disconnections or initialization failures.
The SimliClient uses a default STUN server for ICE candidate gathering. If you need to use custom ICE servers or other WebRTC configurations, you may need to modify the createPeerConnection
method in the SimliClient class.
Fork and contribute to the simli-client repository on GitHub or clone for your own usecase.
If you encounter issues:
Reach out to our support team for further assistance on Discord.