1

Ive been trying to get Mozillas deepspeech installed but i keep running in to the same problem. here is the terminal output

pi@raspberrypi:~/dev/deepspeech $ pip install deepspeech
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
ERROR: Could not find a version that satisfies the requirement deepspeech
ERROR: No matching distribution found for deepspeech

At first i was following this tutorial https://www.hackster.io/dmitrywat/offline-speech-recognition-on-raspberry-pi-4-with-respeaker-c537e7

then i tried the mozillas own resource https://deepspeech.readthedocs.io/en/r0.9/index.html

and lastly this tutorial https://dev.webonomic.nl/trying-out-deepspeech-on-a-raspberry-pi-4

in each case i am getting the same problem as shown above.

I am running a fresh install of raspbian bullseye on a pi 4 model b bullseye ships with python 3.9.2

Thanks in advance db

1
  • Hi @donny Bronson i've a solution, see below. It's time sensitive, as i don't know how useful the version of raspbian will be after a few months, so i recommend checking this out sooner rather than later, because the distro because too old to install anything on.
    – Owl
    Feb 14 at 12:58

3 Answers 3

0

The guides you're reading were written for the previous version of Raspberry Pi OS, which had Python 3.7. I'm guessing you're on RPi OS Bullseye, the latest version. The problem is that there are currently no ARM builds of deepspeech for Python 3.9 on PyPi.

I've been trying and failing to build deepspeech from source all today, so I'm afraid I don't have any more information than this for you. The simplest option would be to install Raspberry Pi OS Buster and start from there if you don't fancy spending quite a while getting it to compile.

2
  • Hi Alex, thanks for the response. Yeah i got a bit further with the install using Buster. Still some probs. but I'll update this thread once i make some progress. /donny Dec 14, 2021 at 13:01
  • Doesn't make more sense to downgrade python to 3.7 instead of reverting back to Buster?
    – naim5am
    Jan 29 at 13:44
0

As Alex commented, the issue is that there are no ARM builds for deepspeech but it isn't a hard issue to fix. You can install python 3.7.

sudo python3.7 -m pip install deepspeech

Unfortunately, for now, you'll likely be stuck using python 3.7

Alternatively, you can just use pyenv to set the working version of the project.

0

Solution:

deepspeech will run on an raspberry pi 4:

However it needs both:

  1. python 3.7 and
  2. Arm linux_armv7l (32bit)

At the time of writing this, Deepspeech will not install on later pythons, and it will not install on an 64 bit ARM OS (so it wont install on arm64 or aarch64, if you see that, then you're using an incompatible distro).

Download the version: 2022-01-28-raspios-buster-armhf.zip, extract it, and cat it to your sd card /dev/sdd (or whatever your sd card dev is).

Install it on the RPI 4.

It is important at this stage not to do apt-get update as this will update the system and cause the following compiler bug installing numpy in pip3 which will completely block your installation of deepspeech:

2022-02-13T06:56:51,225   numpy/core/src/umath/loops_trigonometric.dispatch.c.src: In function ‘FLOAT_sin_NEON_VFPV4’:
2022-02-13T06:56:51,226   numpy/core/src/umath/loops_trigonometric.dispatch.c.src:202:20: internal compiler error: in convert_move, at expr.c:218

Once you finish this, you are ready to install deepspeech, there are some differences between the recommended way on the website, and the way you need to install it on the pi.

sudo apt-get install virtualenv
virtualenv -p python $HOME/DeepSpeech/Working/deepspeech-venv/

source $HOME/DeepSpeech/Working/deepspeech-venv/bin/activate
pip3 install deepspeech

# I NEEDED TO ADD THIS - you should put it in bashrc or something:
export PATH="/home/pi/.local/bin:$PATH"

# DO NOT USE THE FOLLOWING ON RPI:
# curl -LO https://github.com/mozilla/DeepSpeech/releases/download/v0.9.3/deepspeech-0.9.3-models.pbmm

# INSTEAD USE:
curl -LO https://github.com/mozilla/DeepSpeech/releases/download/v0.9.3/deepspeech-0.9.3-models.tflite

curl -LO https://github.com/mozilla/DeepSpeech/releases/download/v0.9.3/deepspeech-0.9.3-models.scorer
curl -LO https://github.com/mozilla/DeepSpeech/releases/download/v0.9.3/audio-0.9.3.tar.gz

tar xvf audio-0.9.3.tar.gz

# DO NOT USE THE FOLLOWING ON RPI:
# deepspeech --model deepspeech-0.9.3-models.pbmm --scorer deepspeech-0.9.3-models.scorer --audio audio/2830-3980-0043.wav

# INSTEAD USE:
deepspeech --model deepspeech-0.9.3-models.tflite --scorer deepspeech-0.9.3-models.scorer --audio audio/2830-3980-0043.wav

This provides the following output:

pi@raspberrypi:~ $ virtualenv -p python $HOME/DeepSpeech/Working/deepspeech-venv/
Running virtualenv with interpreter /usr/bin/python
New python executable in /home/pi/DeepSpeech/Working/deepspeech-venv/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
pi@raspberrypi:~ $ source $HOME/DeepSpeech/Working/deepspeech-venv/bin/activate
(deepspeech-venv) pi@raspberrypi:~ $ pip3 install deepspeech
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting deepspeech
  Downloading https://files.pythonhosted.org/packages/a8/01/693eb642003e1a15e41d1224334d44934325e20f3d01a9a7831cc416eb70/deepspeech-0.9.3-cp37-cp37m-linux_armv7l.whl (1.4MB)
    100% |████████████████████████████████| 1.4MB 307kB/s 
Requirement already satisfied: numpy>=1.14.5 in /usr/lib/python3/dist-packages (from deepspeech) (1.16.2)
Installing collected packages: deepspeech
  The script deepspeech is installed in '/home/pi/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed deepspeech-0.9.3
(deepspeech-venv) pi@raspberrypi:~ $ curl -LO https://github.com/mozilla/DeepSpeech/releases/download/v0.9.3/deepspeech-0.9.3-models.tflite
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   667  100   667    0     0   2443      0 --:--:-- --:--:-- --:--:--  2443
100 45.1M  100 45.1M    0     0  7150k      0  0:00:06  0:00:06 --:--:-- 8365k
(deepspeech-venv) pi@raspberrypi:~ $ curl -LO https://github.com/mozilla/DeepSpeech/releases/download/v0.9.3/deepspeech-0.9.3-models.scorer
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   667  100   667    0     0   2407      0 --:--:-- --:--:-- --:--:--  2407
100  909M  100  909M    0     0  5517k      0  0:02:48  0:02:48 --:--:-- 8365k
(deepspeech-venv) pi@raspberrypi:~ $ export PATH="/home/pi/.local/bin:$PATH"
(deepspeech-venv) pi@raspberrypi:~ $ curl -LO https://github.com/mozilla/DeepSpeech/releases/download/v0.9.3/audio-0.9.3.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   655  100   655    0     0   2364      0 --:--:-- --:--:-- --:--:--  2373
100  194k  100  194k    0     0   364k      0 --:--:-- --:--:-- --:--:-- 4052k
(deepspeech-venv) pi@raspberrypi:~ $ tar xvf audio-0.9.3.tar.gz
._audio
audio/
audio/._2830-3980-0043.wav
audio/2830-3980-0043.wav
audio/._Attribution.txt
audio/Attribution.txt
audio/._4507-16021-0012.wav
audio/4507-16021-0012.wav
audio/._8455-210777-0068.wav
audio/8455-210777-0068.wav
audio/._License.txt
audio/License.txt

Finally we test the deepspeech works:

(deepspeech-venv) pi@raspberrypi:~ $ deepspeech --model deepspeech-0.9.3-models.tflite --scorer deepspeech-0.9.3-models.scorer --audio audio/2830-3980-0043.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.00352s.
Loading scorer from files deepspeech-0.9.3-models.scorer
Loaded scorer in 0.000633s.
Running inference.
experience proves this
Inference took 1.594s for 1.975s audio file.

"experience proves this" is the correct interpretation of the audio.

Now at this point, my advice is to install everything you need to install on this rpi image, and then snapshot the entire sd card by catting it off to ISO image and backing it up. In the future, this may well not be supported. Mozilla may or may not pull support in the future, or support future raspbian releases. Who knows. My advice is don't take the chance, back it up.

Additional Tips: You may also considering the following:

  1. Installing festival and / or flite voice synthesis, apt-get install flite festival
  2. you may wish to apt-get install normalize-audio as normalize-audio will adjust the dynamic range of any audio recordings
  3. If you want to record input, you may wish to add the following into /etc/modprobe.d/:

This will move the sound cards around:

pi@raspberrypi:~/Configs $ cat raspi-blacklist.conf 
blacklist snd_bcm2835
pi@raspberrypi:~/Configs $ cat aliases.conf
#These are the standard aliases and dependencies.
#This file does not need to be modified.
#prevent unusual drivers from appearing as the first sound device
options snd-pcsp index=-2
#options snd-usb-audio index=-2
options cx88_alsa index=-2
options snd-atiixp-modem index=-2
options snd-intel8x0m index=-2
options snd-via82xx-modem index=-2

#work around other kernel issues 
#The EHCI driver should be loaded before the ones for low speed controllers
#or some devices may be confused when they are disconnected and reconnected.
softdep uhci-hcd pre: ehci-hcd
softdep ohci-hcd pre: ehci-hcd

And this will allow your raspberry pi to see the USB soundcard as the first sound device. I'm using a startech.com ICUSBAUDIO7D and it's great for these types of application. For the microphone i'm using an Andrea Anti-Noise SG-100 shotgun mic, plugged into the mono socket of the sound card.

  1. To record audio, consider using arecord with options: arecord -r 16000 -f S16_LE test.wav and normalize it using normalize-audio test.wav normalizing the audio makes a significant difference to the performance of deepspeech. Also deepspeech needs 16Khz audio to work with else it gives an error.

Testing with the Flowers verses of the dhammapada:

pi@raspberrypi:~/DeepSpeech $ arecord -r 16000 -f S16_LE test2.wav
Recording WAVE 'test2.wav' : Signed 16 bit Little Endian, Rate 16000 Hz, Mono
^CAborted by signal Interrupt...
pi@raspberrypi:~/DeepSpeech $ normalize-audio test2.wav 
Computing levels...
 test2.wav         100% done, ETA 00:00:00 (batch 100% done, ETA 00:00:00) 
Applying adjustment of 40.43dB to test2.wav...
 test2.wav         100% done, ETA 00:00:00 (batch 100% done, ETA 00:00:00) 

Deepspeech:

(deepspeech-venv) pi@raspberrypi:~/DeepSpeech $ deepspeech --model deepspeech-0.9.3-models.tflite --scorer deepspeech-0.9.3-models.scorer --audio test2.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.0034s.
Loading scorer from files deepspeech-0.9.3-models.scorer
Loaded scorer in 0.000542s.
Running inference.
who will transcend this world who will transcend the realm of the dead and heaven too with all its gods who will find the true and shining way of the path
Inference took 13.021s for 15.125s audio file.

No mistakes in interpretation :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.