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

From Mudlet
Jump to navigation Jump to search
m (Update version note)
(Update functions for removal of 'speech')
 
(3 intermediate revisions by 2 users not shown)
Line 7: Line 7:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
{{Note}} Available in Mudlet 3.13.
+
{{Note}} Available in Mudlet 3.17.
  
 
The same works from an alias or a trigger - try adding an alias with a pattern <code>^say (.+)$</code> and the code of:
 
The same works from an alias or a trigger - try adding an alias with a pattern <code>^say (.+)$</code> and the code of:
Line 18: Line 18:
  
 
== Advanced ==
 
== 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():
+
If you've added a few triggers and played around with it for a bit, you might notice one problem - [[Manual:Text to Speech Functions#ttsSpeak|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 [[Manual:Text to Speech Functions#ttsQueue|ttsQueue()]]:
  
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
ttsQueueSpeech("We begin with some text")
+
ttsQueue("We begin with some text")
ttsQueueSpeech("And we continue it without interruption")
+
ttsQueue("And we continue it without interruption")
 
</syntaxhighlight>
 
</syntaxhighlight>
  
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().
+
You can see what's currently in the text queue with [[Manual:Text to Speech Functions#ttsGetQueue|ttsGetQueue()]], pause/resume the speech with [[Manual:Text to Speech Functions#ttsPause|ttsPause()]]/[[Manual:Text to Speech Functions#ttsResume|ttsResume()]], clear the queue [[Manual:Text to Speech Functions#ttsClearQueue|ttsClearQueue()]], and get the text that is currently being spoken with [[Manual:Text to Speech Functions#ttsGetCurrentLine|ttsGetCurrentLine()]].
  
See the current state of the TTS engine (ready, paused, speech started, error, unknown) with ttsGetState().
+
See the current state of the TTS engine (ready, paused, speech started, error, unknown) with [[Manual:Text to Speech Functions#ttsGetState|ttsGetState()]].
  
 
== Tweaking Text-to-Speech ==
 
== 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().
+
Different voices will be available depending on the computer you use (Windows/macOS/Linux). You can get the list of available voices with [[Manual:Text to Speech Functions#ttsGetVoices|ttsGetVoices()]], get the current one in use with [[Manual:Text to Speech Functions#ttsGetCurrentVoice|ttsGetCurrentVoice()]], and choose a particular voice with [[Manual:Text to Speech Functions#ttsSetVoiceByName|ttsSetVoiceByName()]]/[[Manual:Text to Speech Functions#ttsSetVoiceByIndex|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().
+
Once you've set upon using a particular voice, you can tweak the speech speed with [[Manual:Text to Speech Functions#ttsSetRate|ttsSetRate()]], adjust the volume with [[Manual:Text to Speech Functions#ttsSetVolume|ttsSetVolume()]], and adjust the pitch with [[Manual:Text to Speech Functions#ttsSetPitch|ttsSetPitch()]].
  
 
== Troubleshooting ==
 
== 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.
+
If Text-to-Speech is not saying anything at all, check that [[Manual:Text to Speech Functions#ttsGetVoices|ttsGetVoices()]] has any voices - they might not be available on your platform.

Latest revision as of 07:58, 30 January 2019

Basics

You can make Mudlet speak outloud by doing the following:

ttsSpeak("Wow my Mudlet can talk!")

Note Note: Available in Mudlet 3.17.

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 ttsQueue():

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

You can see what's currently in the text queue with ttsGetQueue(), pause/resume the speech with ttsPause()/ttsResume(), 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 ttsSetRate(), adjust the volume with ttsSetVolume(), and adjust the pitch with ttsSetPitch().

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.