Announcements for the Lyrion Media Server
LMS Announce is a plugin for playing announcements / notifications (audio / speech) using LMS.
Features
- Web API (using HTTP GET, i.e. calling an URL)
- Can play an audio file / URL, a playlist or generate speech (using a Text to Speech (TTS) engine installed on the LMS server)
- Pauses current playlist, plays announcement, resumes playlist
Scenarios
- Home automation
- Phone (e.g. using IFTTT or Automate)
- Anything that can call an URL with parameters (wget from a shell script etc.)
Status
- Beta quality
- untested with any sort of streaming
- little error handling
- Tested on Linux
- May work on MacOS (provided the TTS profiles are adapted, see below)
- Most likely won't fully work on Windows, except maybe the playlist and/or file mode
Installation
In the LMS standard web interface in Settings/Plugins
, add https://www.nexus0.net/pub/sw/lmsannounce/repo.xml
to the list of Additional Repositories and activate the plugin.
Usage Instructions
The plugin provides it's API at http://lmsserver:9000/plugins/LMSannounce/js.html
. All calls require the cmd
and playerid
parameter, plus, depending on the command, other parameters as well.
Note: As always, parameter values need to be URL encoded.
curl
can do this automatically:
curl -G 'http://lmsserver:9000/plugins/LMSannounce/js.html' --data-urlencode "cmd=announceTTS" --data-urlencode "ttsprofile=mimic-ap" --data-urlencode "playerid=00:00:00:00:00:00" --data-urlencode "text=new message"
Announce (playlist)
Parameter | Value |
---|---|
cmd | announcePlaylist |
playerid | ID of player (MAC address) |
playlist | Name of playlist |
forcewake | true / false (force player to wake up (default: true)) |
volume | 0-100 |
Example: http://lmsserver:9000/plugins/LMSannounce/js.html?cmd=announcePlaylist&playlist=somepls&playerid=00%3A00%3A00%3A00%3A00%3A00
Announce (file or URL)
Parameter | Value |
---|---|
cmd | announceFile |
playerid | ID of player (MAC address) |
file | Full (absolute) path of an audio file or an URL |
forcewake | true / false (force player to wake up (default: true)) |
volume | 0-100 |
Example: http://lmsserver:9000/plugins/LMSannounce/js.html?cmd=announceFile&file=%2Fdata%2Fmusic%2Fsoundeffects%2Fring.mp3&playerid=00%3A00%3A00%3A00%3A00%3A00
Announce (TTS)
Parameter | Value |
---|---|
cmd | announceTTS |
playerid | ID of player (MAC address) |
ttsprofile | select TTS profile (see below) |
text | Text to speak |
forcewake | true / false (force player to wake up (default: true)) |
volume | 0-100 |
Example: http://lmsserver:9000/plugins/LMSannounce/js.html?cmd=announceTTS&ttsprofile=espeak-en-m&text=new%20message&playerid=00%3A00%3A00%3A00%3A00%3A00
Text to Speech
The plugin needs a TTS engine installed on the server on which LMS is running (or you could use a cloud service, e.g. AWS Polly or Google TTS). This engine must be able to convert text to an audio file using a CLI command.
Some options are:
- espeak (supported, small and fast, robotic voice)
- mimic (supported, good quality and fairly natural voices)
- SVOX pico
- festival, flite, ... (not tested, would most likely work)
- Larynx (untested, but very interesting. Reported as working by 3rd party.)
- coqui-ai/TTS (untested, but very interesting)
- gTTS (Google TTS CLI tool. Reported as working by 3rd party.)
Some of them should be available as a package in most Linux distributions.
TTS profiles
A profile defines which TTS engine to use, and it's parameters. There are a number of defaults, and it's possible to define custom profiles as well.
Profile | Description |
---|---|
espeak-en-m | espeak TTS, english, male |
espeak-en-f | espeak TTS, english, female |
espeak-de-m | espeak TTS, german, male |
espeak-de-f | espeak TTS, german, female |
mimic-slt | mimic TTS, SLT voice |
mimic-ap | mimic TTS, AP voice |
Custom TTS profiles
To support other TTS engines / voices, create a file named la-ttsprofiles.json
in /etc
or /usr/local/etc
containing the definitions as a JSON object.
Example (download):
{
"espeak-fr-f": {
"cmd": "/usr/bin/espeak",
"output": "-w ",
"options": "-vfr+f3",
"text": ""
},
"mimic-rms": {
"cmd": "/usr/bin/mimic",
"output": "-o ",
"options": "-voice rms",
"text": "-t"
}
}
- cmd: the command to execute
- output: parameter to specify the output file (wav format)
- options: parameter to specify any other options to pass to the command
- text: parameter to specify the text to convert
The profiles can then be used as usual: http://lmsserver:9000/plugins/LMSannounce/js.html?cmd=announceTTS&ttsprofile=espeak-fr-f&text=ordinateur%20deux%20trois&playerid=00%3A00%3A00%3A00%3A00%3A00
Tips & Tricks
Pre-roll / post-roll sound
- for static announcements, use a playlist
- for speech, install sox and create a shell script:
#!/bin/bash
SOUND="/path/to/beep.flac"
while getopts "o:t:" opt; do
case $opt in
o)
DESTFILE="$OPTARG"
;;
t)
TEXT="$OPTARG"
;;
esac
done
mimic -o "${DESTFILE}.tmp" -voice slt -t "$TEXT"
sox "${DESTFILE}.tmp" -t sox - channels 2 rate 44100 | sox "$SOUND" -t sox - "$DESTFILE"
rm "${DESTFILE}.tmp"
and use it as a TTS engine:
"mimic-beep": {
"cmd": "/path/to/script.sh",
"output": "-o ",
"options": "",
"text": "-t"
}
Using a remote TTS
If you cannot install a TTS on the LMS server, you can run a non-local one using ssh
:
#!/bin/bash
while getopts "o:t:" opt; do
case $opt in
o)
DESTFILE="$OPTARG"
;;
t)
TEXT="$OPTARG"
;;
esac
done
ssh user@otherserver "/usr/bin/mimic -o /dev/stdout -voice slt -t \"$TEXT\"" > "${DESTFILE}"
Sending text interactively
- Android: HTTP Shortcuts
- bash / curl:
$ function LMS_announce { curl -G -s -o /dev/null 'http://lmsserver:9000/plugins/LMSannounce/js.html' --data-urlencode "cmd=announceTTS" --data-urlencode "ttsprofile=mimic-slt" --data-urlencode "playerid=00:00:00:00:00:00" --data-urlencode "text=$1"; }
$ LMS_announce "hello world"
FAQ
- Adding the plugin repository to LMS results in some errors / doesn't work. Why?
- Make sure your LMS installation is SSL-enabled (e.g. on *nix, the perl modules Net::SSLeay and IO:Socket:SSL need to be installed)
- What does 'Error Plugins::LMSannounce::Plugin::ANON (306) playlist creation error' mean?
- Check if playlists can actually be created on your LMS installation. Check if a playlist called announceTTS exists and delete it.
- When using TTS, there is only silence / the call returns "error n while executing TTS". What now?
- First, check from the shell if your TTS engine actually works (using the account LMS runs as, e.g.
squeezeboxserver
). After that, switch logging to debug for the plugin (LMS Web interface/Settings/Advanced/Logging/plugin.lmsannounce
). Search the server log for lines likeannounceTTS: command: /usr/bin/mimic -o /tmp/annTTS.wav -voice awb -t "message"
and check if the command is correct and works from a regular shell (delete/tmp/annTTS.wav
when done).
License
GNU GPLv3
Reporting Issues
Use the discussion thread in the LMS forum.