Discussions

Ask a Question
Back to All

How to get the message chunk of what the avatar is talking

Hello!
I would like to know if there is any method in the JS SDK to receive the avatar's responses in chunks, in order to provide a smoother and more real-time experience — for example, displaying subtitles progressively as the avatar "speaks", rather than write the full text.

I found these earlier discussions:

https://docs.heygen.com/discuss/672f03841261a40070a486bc

https://docs.heygen.com/discuss/67921f6e285326006b60f10e

At the time, it was mentioned that StreamingEvents.AVATAR_TALKING_MESSAGE would emit these chunks. However, when I log the messages from this event, I receive the entire response at once, not in partial segments. I'm wondering if there have been any changes to the SDK or if additional configuration is now required to enable chunked streaming.

Thanks in advance!

avatarRef.current?.on(StreamingEvents.AVATAR_TALKING_MESSAGE, (e) => {
      Logger.debug(LOG_TAG, "[Event] Avatar talking message.", e);
     
      console.log(e.detail.message);
  		// the "message" object has all the text that the avatar will speak and not the chunk
 			
  		//....
}