Skip to main content

Methods Introduction

The Speechify API has several useful methods that allow for various actions to be performed, configuration updated, and information to be fetched.

Example

Here's an example that mounts the player, updates the configuration to make the play button red after 5 seconds, and hides the inline player after 15 seconds:

import(
"https://storage.googleapis.com/speechify-api-cdn/speechifyapi.min.mjs"
).then(async (speechifyWidget) => {
// initialize and mount the widget
const widget = speechifyWidget.makeSpeechifyExperience({
rootElement: document.getElementById("article"),
useSpeechifyRoot: true,
});

// mount the player with the mount method
await widget.mount();

// update config after 5 seconds
setTimeout(async () => {
await widget.updateConfiguration({
customStyles: { playButton: { backgroundColor: "#ff0000" } },
});
}, 5000);

// hide the inline player after 15 seconds
setTimeout(async () => {
await widget.hideInlinePlayer();
}, 15000);
});

Methods

Below are all the built-in methods in the Speechify API (aside from addEventListener described in Events) that can used.