Skip to content
Receive text from MQTT and TTS via Google TTS
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.editorconfig
.gitignore
README.md
config.example.js
index.js
node start.lnk
package-lock.json
package.json

README.md

Receive text from MQTT and TTS via Google TTS on Windows.

Tested only on Windows. Will work on Linux too.

Requirements

Install

Download and install Node.js.

Install gTTS:

pip install gTTS

Download cmd2mp3, place to PATH, or replace playCommand to your in command.

Clone this repository.

Config

  • Copy config.example.js to config.js
  • Edit config.js
  • For Ubuntu replace cmdmp3 to playogg in config.js

Usage

npm start or just open node start.lnk.

Default host: localhost:1883.

Default MQTT topic: tts.

Tool will save mp3 to ./data directory for cache.

Linux bash verion

Requirements: gtts, playogg (ogg123 package).

Create tts-say script:

#!/bin/bash
set -eu

in="${1:-/dev/stdin}"

if [ "$in" = "/dev/stdin" ]; then
	while read line
	do
		line="$(echo "$line" | sed 's/^log //g')"
		echo "tts-say: $line"
		gtts-cli --nocheck --lang ru "$line" --output /tmp/tts.mp3
		playogg /tmp/tts.mp3
	done < "$in"
else
	gtts-cli --nocheck --lang ru "$in" --output /tmp/tts.mp3
	playogg /tmp/tts.mp3
fi

Usage:

echo "проверка" | tts-say
You can’t perform that action at this time.