Skip to content

Latest commit

 

History

21 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mochaspeech

Note

Mochaspeech is not production-ready and is not meant to be used that way. This is just a fun alternative server. You can use it on your own laptop absolutely don't put it on someone else's laptop.

What?

Mochaspeech is a speech server compatible with most speech-dispatcher clients. Basically clients tell it to speak and it speaks.

Why?

I made it purely for fun and enjoyment.

Isn't this an SSIP implementation?

No. An SSIP implementation would implement the SSIP fully according to the spec. This is a custom server attempting to merely work with most SSIP clients, and it cuts corners in a ton of ways (no history, no proper pausing/resuming, no module/voice systems, tons of lying to clients, and so on) in ordere to achieve that goal.

Is this supposed to replace speechd?

No. Speechd's still better at being reliable. Read the note at the top.

You say "most clients", what isn't it compatible with?

I don't know. It seems to work with Firefox, spd-say, and Orca. But because I don't implement the SSIP fully (read Isn't this an SSIP implementation?), there's bound to be some client that breaks under mochaspeech.

What's the good stuff about this?

if I had to advertise it

  • size: Mochaspeech is 792 lines of Python as of writing this. Now compare that to the ever so humble speechd, with 30k-40k lines of code as of writing
  • lightness: It just executes a command at the end of the day
  • configurablility: You can customize the exact commands it runs and the pitch/volume/rate ranges through good old Python and a crappy list template system that i made in 5 minutes

And what's the bad stuff

  • matureness: Mochaspeech is young. Speechd is over 20 years old.
  • reliability: Speechd may be large, but at least it's almost guaranteed to work. Mochaspeech hasn't been tested as much.
  • jank: Mochaspeech is pretty janky.

Should I use this

For most people no. This is just a nichhe fun project.

How do I install this

windows/macos

Unsupported. This is for Linux and the BSDs. Go away

linux

Git clone this repo to /opt/mochaspeech. You're done for the installation.

If you wanna quickly just start the server run python -m mochaspeech while you're in /opt/mochaspeech.

Now to set it up to automatically run in the background, which is init-specific:

systemd

DO NOT INSTALL IT AS A SYSTEM SERVICE DO NOT PLEASE DONT NO

Create this file at ~/.config/systemd/user/mochaspeech.service for each user that needs it:

[Unit]
Description=mochaspeech speech server
PartOf=graphical-session.target
After=graphical-session.target

[Service]
Type=simple
WorkingDirectory=/opt/mochaspeech
ExecStart=python3 -m mochaspeech
Restart=on-failure

[Install]
WantedBy=graphical-session.target

Then systemctl --user daemon-reload and systemctl --user enable --now mochaspeech!

To verify it's running run in your terminal:

python3 -c '
import socket
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
s.connect("/run/user/'"$(id -u)"'/speech-dispatcher/speechd.sock")
s.sendall(b"MOCHASPEECH\r\n")
print(s.recv(4096).decode())
s.close()
'

If it says 266- followed by a version number, mochaspeech is running correctly.

If it instead says 500 ERR INVALID COMMAND or ConnectionRefusedError: [Errno 111] Connection refused, it isn't running and either you did something wrong or I did something wrong.

other

I only have instructions for systemd, sorry! it's the only thing I used, you're probably smart enough if you use something else anyway.

bsd

You can definitely figure it out ❤️

How do I update it?

Go to /opt/mochaspeech or wherever you cloned mochaspeech and git pull.

Why won't it say anything?

Try installing espeak-ng first. It uses that by default and is stupid and won't fallback if it isn't there. Also make sure it's in your PATH.

Otherwise check the logs. Idk. If it looks like something I broke open a GitHub issue.

How do I configure it?

DO NOT MODIFY config_example.py ABSOLUTELY DO NOT DON'T DON'T PLEASE DONT NO DONT MODIFY IT DONT PLEAES DONT PLEASE

Go to /opt/mochaspeech or wherever you cloned mochaspeech and create a file in the mochaspeech directory called config.py. Copy the contents of config_example.py into it.

Note you'll need to know Python to configure this. If you don't know Python just use the default config don't trouble yourself with this.

Variables (all of these are required):

synth_name

Literal string. Should ideally identify your config but can be whatever.

speak_template

List of either strings or integers. These are command arguments for SPEAK mode (plain text multiple lines).

The command this runs should be blocking, should run the audio on its own, and should quit as soon as speech ends. If it plays in the background mochaspeech will break. If it outputs audio data instead of playing on its own mochaspeech will break. If it waits for more data after speaking mochaspeech will break.

The strings get passed down literally and the integers get replaced dynamically.

Meaning of the integers:

  • 1: The text data (omit this if your command supports stdin text input, mochaspeech knows what to do)
  • 2: Pitch
  • 3: Rate/speed
  • 4: Volume/amplitude

speak_encoding

Literal string. The encoding that should be used for stdin communication with the SPEAK mode process. Should be an encoding name Python can recognize. Just leave this as utf-8 unless you know what you're doing.

speak_rate

Function. Takes an integer from -100 to 100 and outputs an integer or float. Should transform the input value to a value the SPEAK mode command can understand.

speak_pitch

Function. Same thing as speak_rate but for pitch.

speak_volume

Function. Same thing as speak_rate but for volume.

punct_template

List of either strings or integers. These are commands arguments for CHAR mode (char-by-char, pronouncing punctuation).

See speak_template.

punct_encoding

Literal string. Same thing as speak_encoding but for CHAR mode.

punct_rate/punct_pitch/punct_volume

Functions. Same as speak_rate, speak_pitch, and speak_volume (respectively) but for CHAR mode.

ssml_template

List of either strings or integers. These are commands arguments for SSML mode (speak SSML)

See speak_template.

ssml_encoding

Literal string. Same thing as speak_encoding but for SSML mode.

ssml_rate/ssml_pitch/ssml_volume

Functions. Same as speak_rate, speak_pitch, and speak_volume (respectively) but for SSML mode.

How long did v1.0.0 take

4 days

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. See the LICENSE file for more info.

About

speech server compatible with most speech-dispatcher clients

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Contributors

Languages