How to make deepspeech-server run as a, well, server?

I have an Ubuntu 18.04 server running in a Hyper-V VM that I want to use as a central STT translator resource for multiple mycrofts in the home.

I have installed deepspeech v0.6.1:

As well as deepspeech-server:

Deepspeech-server runs fine when executed from an SSH session, I can perform STT remotely, sending the deepspeech audio sample files.

The problem is it runs in the foreground, tying up the console, and as soon as you send ctrl-c, the process ends and the service stops operating.

I need this to run in the background, obviously, and remain running at all times. As well as start automatically at boot. Can’t really call it a “server” until it does…

Does anyone have any guidance on setting a python/pip package to run as a service?

Thanks.

Look out for “debian systemd service” - there should be a bunch of recipes how to create your own service.

Or have a look at my example how to “Automatically start Mycroft while booting” here: Mycroft on Respeaker Core V2 and adapt it to deepspeech-server.

1 Like

The sample config needs a bit of tweaking, and I should probably update the script to what I use now, but this will run it in a screen session for you.

2 Likes

i am running it in cron
it looks to see if there is a running service with deep whatever and if not, it starts it up.

if [[ ! $(pgrep -f deepspeech) ]]; then
/home/pi/mycroft-core/.venv/bin/deepspeech-server --config /home/pi/config.json 1>> /home/pi/log/deepserver.log 2>>/home/pi/log/deepservererror.log
fi