Is there a "command line" TTS?

Mycroft looks interesting. At the moment I’m running Home Assistant on an RPi3. HA has detected my Chromecast and is configured to use it as a media player. It also works well with Google TTS, along with other engines, and currently provides various notifications over my living room speakers. What I’d like to do is let HA own media playback and TTS for now, but since it has no capability to process audio input, Mycroft can handle that. So Mycroft takes input from a mic, generates its responses, then pipes them to HA for speech. HA, in turn, routes audio through Chromecast, or any other mechanism I choose to use in the future.

HA exposes an API. I’ve written a shell script that takes text as input, sends it to HA’s TTS, and outputs the result on my receiver. If I can tell Mycroft to run a shell script and pass text to speak as a parameter, then theoretically I can just plug in a USB mic and delegate input. So something like:

/usr/local/bin/say Hello, world.

currently speaks “Hello, world.”

Is there any way to do this? I see that Mimic outputs its TTS as wav files, and I’m also working another angle by setting the wavb/mp3 player commands to another shell script that streams them directly to the Chromecast via HA. Unfortunately I’m having issues with this approach, so instead thought I’d ask about piping text to speak through a shell command.

Alternatively, has anyone gotten Mycroft to stream its audio through Chromecasts directly? It’s discoverable on the network, and for all I know there’s a player that can push audio directly, but I haven’t studied how that works to know whether it is realistic.

Thanks.

I’m a home assistant user as well and would recommend you check out my repo here for mycroft: https://github.com/btotharye/mycroft-homeassistant. I also will be setting this up soon, if I don’t get to it this weekend I will get around to it when I get back from pycon. If you figure it out before me let me know, otherwise I’ll set this up probably after I get back.

Thanks, please do keep me posted! I am, unfortunately, failing to play any wavs through my Chromecast via HA. There are other Chromecast issues which I can’t reliably replicate, though I’ve filed an issue with a traceback so hopefully at the very least they can diagnose this initial traceback and help figure out what might be going on. I don’t know enough Python to dig into either project, so any help you can offer is very appreciated, and I’m of course happy to test from the perspective of a competent non-Python-coding user. :slight_smile:

Option a: Look at “mycroft-core/blob/dev/mycroft/tts”, in particular at “espeak_tts.py”. It seems if is at only a few words of change to your objective.

Option b, tricky, zero lines of change: Rename your speak script as “espeak” and configure mycroft to use “espeak” as its TTS.

Interested on this too, but running it on a mark 1.

Any idea how to push text to mycroft via CLi on mark 1?

Depending on what you want to achieve, there are several ways.

Quick demo or test of TTS
From the mycroft-cli-client you can type in:

say some phrase that I want to hear

Producing: “some phrase that I want to hear”

Outputting speech from a command line using Mycroft
We provide helper functions to post things on the messagebus, including a request for the system to speak using whatever voice is configured. For example:

mycroft-venv-activate
python -m mycroft.messagebus.send 'speak' '{"utterance": "this is a test"}'
mycroft-venv-deactivate

Outputting speech from a command line without Mycroft active
The Mimic executable can be used without any other pieces of Mycroft active. To test on a Mark 1 or Picroft you’d have to first shutdown the Mycroft audio, as it locks Pulse. So run:

sudo service mycroft-speech-client stop

Then you can tell mimic to convert text to speech for you:

mimic -t "This is what I want to hear"

or to save it to a file:

mimic -t "This is what I want to hear" -o output.wav

Finally, you can reactivate Mycroft via:

sudo service mycroft-speech-client stop
1 Like

Brilliant! thanks for that.

Just to confirm, I cannot have mark1 listening at the same time I can push text, correct?
ie: mimic -t “This is what I want to hear”

But I can use “say some phrase that I want to hear” if I activate the mycroft-cli-client. How do I activate it?
I looked at this: Push text to the Mark 1 to say? but it gives me an error

There’s also the new mycroft-say-to (send a sentence to mycroft for processing) and mycroft-speak (send a sentence for mycroft to speak)

2 Likes

You can just use speak command from the command line…:
speak "Hi"