Skip to content

Instantly share code, notes, and snippets.

@prestomation
Last active April 12, 2019 20:04
Show Gist options
  • Save prestomation/bfe7920f86449ae8b76e1745a4fa1045 to your computer and use it in GitHub Desktop.
Save prestomation/bfe7920f86449ae8b76e1745a4fa1045 to your computer and use it in GitHub Desktop.
javascript snippet for creating dynamic speech in a Sumerian Host
//Put the below in a script in the ScriptComponent attached to the host entity
//It must be attached to the host entity so that `ctx.entity` below refers to the host
//If this script is attached elsewhere, the lip syncing will not work
const speech = new sumerian.Speech();
speech.body = "The sentene to be spoken by the host";
speech.type = 'ssml';
// This sets up the entity so the right ssml events fire (We can make the host lip sync and move)
speech.updateConfig({ entity: ctx.entity });
const speechComponent = ctx.entity.getComponent('SpeechComponent');
speechComponent.addSpeech(speech);
return speech.play().then(() => {
//scripts here will run after the speech completes
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment