TTS text to speech demo by Tim

Share your scripts and packages with other Mudlet users.
Post Reply
atari2600tim
Posts: 8
Joined: Sun Apr 05, 2020 4:39 am

TTS text to speech demo by Tim

Post by atari2600tim »

I made a very simple package that has 2 parts. A trigger will speak every incoming line. A "tts" alias will let you type some things to do extra stuff.

It does not do anything more complicated than that such as let you navigate back and that sort of thing that they're planning to build into the regular program.

It does show off the TTS features that are currently available to LUA scripts though. Someone could improve on this by making something that selects something other than just the last 5 lines, maybe using keyboard shortcuts to roll back a page or something. Just using Lua script I assume you can probably do most of the things that are planned down the line. I'll leave that for someone else if you want to try that. Also it does not filter anything out, so you might have it say "underscore" hundreds of times if your game has some text art.

Here are the available commands, just type "tts", a space, and then one of these commands:
help - list the commands
stop - stop speaking, empty the speech queue
repeat - add the last 5 lines from the screen onto the speech queue
faster or slower - speed can range from 1 to -1, this one just moves 0.25 steps in either direction
louder or softer - volume can range from 0 to 1, moves by 0.25
higher or lower - pitch can go from 1 to -1, moves by 0.25
pause - stops speaking and keeps speech queued up, but if it isn't speaking then pause doesn't do anything
resume - continues after a pause
voice - rotates between available voices
status - tells your current options

On two of my computers, changing the volume and then speaking at the adjusted volume will crash the program. This happens on Raspberry Pi OS on my Pi 4 using mudlet that I compiled myself. It also happens on Debian on my Intel Chromebook using the official release AppImage file. It works fine on 2 Windows 10 machines I tried. Therefore, in order to avoid crashing, I made a thing where you have to confirm that you accept the risk before you can move the volume down from the initial 1.0.

EDIT: I'm removing all the downloads from the rest of the thread and just updating the download on this initial post. The file attached to this has all the updates mentioned in the replies.
Attachments
tts-tim.mpackage
(2.05 KiB) Downloaded 67 times
Last edited by atari2600tim on Sat Feb 27, 2021 3:28 pm, edited 1 time in total.

atari2600tim
Posts: 8
Joined: Sun Apr 05, 2020 4:39 am

Re: TTS text to speech demo by Tim

Post by atari2600tim »

Here is an update with some minor changes.

Empty or whitespace lines are now skipped. Issue 4688 on Github has discussion of it, but empty lines are a problem currently with Mudlet. There is already a fix written, but it is not in the release or Public Test Build versions of Mudlet yet.

Less than and greater than signs are now converted into the words, because Windows seems to treat them like HTML, and it ends up stopping speech completely. Issue 4689 on Github has discussion of it, so sometime in the future it will probably be handled better.

I made the adjustment steps go in intervals of 0.1 instead of 0.25. So if you increased the pitch twice to reach 1.5 for example, now you'll want to do it five times.
Last edited by atari2600tim on Sat Feb 27, 2021 3:29 pm, edited 1 time in total.

atari2600tim
Posts: 8
Joined: Sun Apr 05, 2020 4:39 am

Re: TTS text to speech demo by Tim

Post by atari2600tim »

This one adds 'tts skip' which will interrupt and go to the next line, useful if it is reading some text art.

Also if you use 'tts voice' to cycle through voices but your system is somehow set to use a voice that is not in the list of available voices, it will now select one from the list instead of failing to find what comes after the current one in the list.
Last edited by atari2600tim on Sat Feb 27, 2021 3:30 pm, edited 1 time in total.

atari2600tim
Posts: 8
Joined: Sun Apr 05, 2020 4:39 am

Re: TTS text to speech demo by Tim

Post by atari2600tim »

I switched the `tts stop` to use `ttsSpeak()` instead of ttsQueue(). There are some situations where ttsSpeak() will jumpstart a broken queue, so now `tts stop` can do that.

The `tts skip` has code to avoid an issue where you can interrupt in-between queued messages and break the queue. It is on github at 4737.

Post Reply