Error when using command STT via rhasspy but not locally

Hi all, so I am using an external program to actually perform the STT because I found that selecting “open transcription mode” for deepspeech does not work via Rhasspy interface. I am running into an error where running a python script from Rhasspy does not recognize the import modules.

So, my python script consists of this:

import deepspeech
import wave
import numpy as np
import sys

model = deepspeech.Model('deepspeech-0.9.3-models.tflite')

w ='temp_file.wav', 'r')
#wav =
data16 = np.frombuffer(w.readframes(w.getnframes()), dtype=np.int16)

text = model.stt(data16)

I haven’t wrangled with the wav file yet, so I am just leaving in a temporary wav file that I pass in. Ignore any errors from that (errors should produce running from Rhasspy but not manually, you’ll see why below).

My profile contains this:

"speech_to_text": {
        "command": {
            "program": "/profiles/en/"
        "system": "command"

When I run this via Rhasspy (taken from docker logs rhasspy):

[DEBUG:2022-01-06 11:09:04,374] rhasspyremote_http_hermes: Traceback (most recent call last):
  File "/profiles/en/", line 8, in <module>
    model = deepspeech.Model('deepspeech-0.9.3-models.tflite')
AttributeError: module 'deepspeech' has no attribute 'Model'

Because I am passing in a file, I expect an error, but not this one.

When I run this locally:

pi@raspberrypi:~/.config/rhasspy/profiles/en $ ./ < temp_file.wav 
TensorFlow: v2.3.0-6-g23ad988
DeepSpeech: v0.9.3-0-gf2e9c85
why should one halt on the way
pi@raspberrypi:~/.config/rhasspy/profiles/en $ python3
Python 3.7.3 (default, Jan 22 2021, 20:04:44) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import deepspeech
>>> model = deepspeech.Model('deepspeech-0.9.3-models.tflite')
TensorFlow: v2.3.0-6-g23ad988
DeepSpeech: v0.9.3-0-gf2e9c85

I found a similar error for my intent recognition program that previously worked – I import a module called text2digits and was successful, but it is now giving me a module not found error. Which is super weird.

Anyone have any thoughts as to why running something from Rhasspy won’t recognize a python module?

I think this may be a problem with how Rhasspy calls on these files? I also tried with a shell script and also got errors:

pi@raspberrypi:~/.config/rhasspy/profiles/en $ cat

# WAV data is avaiable via STDIN
trap "rm -f $wav_file" EXIT
cat | sox -t wav - -r 16000 -e signed-integer -b 16 -c 1 -t wav - > "$wav_file"

deepspeech --model "deepspeech-0.9.3-models.tflite" --scorer "deepspeech-0.9.3-models.scorer" --audio "$wav_file"

pi@raspberrypi:~/.config/rhasspy/profiles/en $ docker logs rhasspy
DEBUG:2022-01-06 11:39:28,516] rhasspyremote_http_hermes: ['/profiles/en/']
[DEBUG:2022-01-06 11:39:28,678] rhasspyremote_http_hermes: /profiles/en/ line 8: deepspeech: command not found

pi@raspberrypi:~/.config/rhasspy/profiles/en $ deepspeech --model deepspeech-0.9.3-models.tflite --scorer deepspeech-0.9.3-models.scorer --audio temp_file.wav 
Loading model from file deepspeech-0.9.3-models.tflite
TensorFlow: v2.3.0-6-g23ad988
DeepSpeech: v0.9.3-0-gf2e9c85
Loaded model in 0.0717s.
Loading scorer from files deepspeech-0.9.3-models.scorer
Loaded scorer in 0.0163s.
Running inference.
why should one halt on the way
Inference took 9.948s for 2.735s audio file.

All in all, I’m confused as to why this isn’t working.

I’m not sure why… but I think something is screwed up between Rhasspy’s python env and mine? I wanted to see what modules were found when running pip list from a python script called by rhasspy, and here’s what I found (and what I did):

#!/usr/bin/env python3

import re
import sys
import json
import subprocess
bc = "pip3 list"
proc = subprocess.Popen(bc.split(), stdout=subprocess.PIPE)
output, error = proc.communicate()
with open ('output.txt', 'wb') as f:

from text2digits import text2digits

# other code down here to recognize the intent
$ docker logs rhasspy
[DEBUG:2022-01-06 17:22:49,508] rhasspyremote_http_hermes: ['/profiles/en/']
WARNING: You are using pip version 20.2.4; however, version 21.3.1 is available.
You should consider upgrading via the '/usr/lib/rhasspy/.venv/bin/python -m pip install --upgrade pip' command.
Traceback (most recent call last):
  File "/profiles/en/", line 14, in <module>
    from text2digits import text2digits
ModuleNotFoundError: No module named 'text2digits'

My pip version is 21.3.1 locally, so why is it showing a different pip version and a venv?

$ cat output.txt

Output.txt is empty (and when tested just by running python3, I see all of my packages), which is evidently should not be. I think this may be the root cause of my general issue for above. Would @synesthesiam or @romkabouter (sorry, calling you both out since I know both of you are great maintainers of this project :slight_smile:) have any idea why?