Difference between revisions of "Manual:Text-to-Speech"

From Mudlet
Jump to navigation Jump to search
(Added initial TTS commands)
 
m (Table of contents to right)
Line 1: Line 1:
 +
{{TOC right}}
 
== Basics ==
 
== Basics ==
 
You can make Mudlet speak outloud by doing the following:
 
You can make Mudlet speak outloud by doing the following:

Revision as of 19:38, 9 August 2018

Basics

You can make Mudlet speak outloud by doing the following:

ttsSpeak("Wow my Mudlet can talk!")

Note Note: Available in Mudlet 3.12.

The same works from an alias or a trigger - try adding an alias with a pattern ^say (.+)$ and the code of:

ttsSpeak(matches[2])

Doing say hello world! will say your text for you. That's all you need to get started!

Advanced

If you've added a few triggers and played around with it for a bit, you might notice one problem - ttsSpeak() is great and simple, but it also won't wait for current spoken text to finish. If you start saying something else in the middle of it, the current speech will be interrupted and the new text will start. Sometimes this is good, sometimes it's not. When you'd like to add text to a queue, you can use ttsQueueSpeech():

ttsQueueSpeech("We begin with some text")
ttsQueueSpeech("And we continue it without interruption")

You can see what's currently in the text queue with ttsGetSpeechQueue(), pause/resume the speech with ttsPauseSpeech()/ttsResumeSpeech(), clear the queue ttsClearQueue(), and get the text that is currently being spoken with ttsGetCurrentLine().

See the current state of the TTS engine (ready, paused, speech started, error, unknown) with ttsGetState().

Tweaking Text-to-Speech

Different voices will be available depending on the computer you use (Windows/macOS/Linux). You can get the list of available voices with ttsGetVoices(), get the current one in use with ttsGetCurrentVoice(), and choose a particular voice with ttsSetVoiceByName()/ttsSetVoiceByIndex().

Once you've set upon using a particular voice, you can tweak the speech speed with ttsSetSpeechRate(), adjust the volume with ttsSetSpeechVolume(), and adjust the pitch with ttsSetSpeechPitch().

Troubleshooting

If Text-to-Speech is not saying anything at all, check that ttsGetVoices() has any voices - they might not be available on your platform.