macotron.speech
Speak text aloud with the system voice or another voice that is installed on the Mac.
// Say the name of each USB device when it is plugged in.
macotron.on("usb:changed", (info) => {
if (info.action === "add") macotron.speech.say(info.name + " connected");
});
Speaking
say(text, { voice? }): void
Starts to speak text and returns at once. When speech is already in progress, the new text waits until it is done, so two plugins do not speak at the same time.
voice is a voice identifier, for example "com.apple.voice.compact.en-US.Samantha", or a voice name, for example "Samantha". When the voice is not installed, or you do not give one, Macotron uses the default voice for the system language. Add more voices in System Settings > Accessibility > Spoken Content.
See also
- macotron.notify to show a banner or a toast.
- The
usb.jsplugin.