met4citizen / TalkingHead

Talking Head (3D): A JavaScript class for real-time lip-sync using Ready Player Me full-body 3D avatars.
MIT License
349 stars 107 forks source link

Get the text of the current audio chunk played in real time #61

Closed audreytimbani closed 2 months ago

audreytimbani commented 2 months ago

Let's suppose that the avatar has to say: ‘Hello World . I'm John’, is there a way of knowing which word the avatar is on so that it can be displayed on the screen in real time?

met4citizen commented 2 months ago

For the speakText and speakAudio methods, you can provide your callback function as the third parameter to get the word currently being spoken. Here’s a simple example:

head.speakText("Hello World. I'm John.", {}, (word) => {
  console.log(word);
});
audreytimbani commented 2 months ago

Thanks