alphacep / vosk-server

WebSocket, gRPC and WebRTC speech recognition server based on Vosk and Kaldi libraries
Apache License 2.0
896 stars 243 forks source link

ModuleNotFoundError: No module named '_cffi_backend' #107

Closed lalimili6 closed 3 years ago

lalimili6 commented 3 years ago

Hi Dear When I run English model docker, I get this error how can fix it?

 sudo docker build --build-arg KALDI_MKL=0 --file Dockerfile.kaldi-vosk-server --tag alphacep/kaldi-vosk-server:latest .
Sending build context to Docker daemon  4.608kB
Step 1/4 : FROM debian:10.4
 ---> ae8514941ea4
Step 2/4 : ARG KALDI_MKL
 ---> Using cache
 ---> e0af55450f0f
Step 3/4 : RUN apt-get update &&     apt-get install -y --no-install-recommends         g++         bzip2         unzip
 make         wget         git         python3         python3-dev         python3-websockets         python3-setuptools
  python3-pip         python3-wheel         zlib1g-dev         patch         ca-certificates         swig         cmake
 xz-utils         automake         autoconf         libtool         pkg-config     && rm -rf /var/lib/apt/lists/*
 ---> Using cache
 ---> aff934f247d7
Step 4/4 : RUN     git clone -b lookahead-1.8.0 --single-branch https://github.com/alphacep/kaldi /opt/kaldi     && cd /opt/kal
di/tools     && sed -i 's:status=0:exit 0:g' extras/check_dependencies.sh     && sed -i 's:--enable-ngram-fsts:--enable-ngram-f
sts --disable-bin:g' Makefile     && make -j $(nproc) openfst cub     && if [ "x$KALDI_MKL" != "x1" ] ; then           extras/i
nstall_openblas_clapack.sh;        else           extras/install_mkl.sh;        fi         && cd /opt/kaldi/src     && if [ "x$
KALDI_MKL" != "x1" ] ; then           ./configure --mathlib=OPENBLAS_CLAPACK --shared;        else           ./configure --math
lib=MKL --shared;        fi     && sed -i 's:-msse -msse2:-msse -msse2:g' kaldi.mk     && sed -i 's: -O1 : -O3 :g' kaldi.mk
 && make -j $(nproc) online2 lm rnnlm         && git clone https://github.com/alphacep/vosk-api /opt/vosk-api     && cd /opt/vo
sk-api/python     && KALDI_MKL=$KALDI_MKL KALDI_ROOT=/opt/kaldi python3 ./setup.py install --single-version-externally-managed
--root=/         && git clone https://github.com/alphacep/vosk-server /opt/vosk-server     && pip3 install grpcio-tools     &&
cd /opt/vosk-server/grpc     && python3 -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. stt_service.proto         &
& rm -rf /opt/vosk-api     && rm -rf /opt/kaldi     && rm -rf /root/.cache     && rm -rf /var/lib/apt/lists/*
 ---> Using cache
 ---> 7c54b6cf8656
Successfully built 7c54b6cf8656
Successfully tagged alphacep/kaldi-vosk-server:latest
sudo docker build --file Dockerfile.kaldi-en --tag alphacep/kaldi-en:latest .
Sending build context to Docker daemon  4.608kB
Step 1/6 : FROM alphacep/kaldi-vosk-server:latest
 ---> 7c54b6cf8656
Step 2/6 : ENV MODEL_VERSION 0.2
 ---> Running in a4579c645daa
Removing intermediate container a4579c645daa
 ---> 02d1fc7186b6
Step 3/6 : RUN mkdir /opt/vosk-model-en    && cd /opt/vosk-model-en    && wget -q http://alphacephei.com/kaldi/models/vosk-mode
l-en-us-aspire-${MODEL_VERSION}.zip    && unzip vosk-model-en-us-aspire-${MODEL_VERSION}.zip    && mv vosk-model-en-us-aspire-$
{MODEL_VERSION} model    && rm -rf vosk-model-en-us-aspire-${MODEL_VERSION}.zip
 ---> Running in cfc1fac8d23f

                                                                                                                     [20/1803]
Archive:  vosk-model-en-us-aspire-0.2.zip
   creating: vosk-model-en-us-aspire-0.2/
   creating: vosk-model-en-us-aspire-0.2/am/
 extracting: vosk-model-en-us-aspire-0.2/am/frame_subsampling_factor
  inflating: vosk-model-en-us-aspire-0.2/am/final.mdl
  inflating: vosk-model-en-us-aspire-0.2/am/tree
   creating: vosk-model-en-us-aspire-0.2/ivector/
  inflating: vosk-model-en-us-aspire-0.2/ivector/ivector.conf
  inflating: vosk-model-en-us-aspire-0.2/ivector/mfcc.conf
  inflating: vosk-model-en-us-aspire-0.2/ivector/final.dubm
  inflating: vosk-model-en-us-aspire-0.2/ivector/final.ie
  inflating: vosk-model-en-us-aspire-0.2/ivector/final.mat
  inflating: vosk-model-en-us-aspire-0.2/ivector/splice.conf
  inflating: vosk-model-en-us-aspire-0.2/ivector/global_cmvn.stats
  inflating: vosk-model-en-us-aspire-0.2/ivector/online_cmvn.conf
  inflating: vosk-model-en-us-aspire-0.2/README
   creating: vosk-model-en-us-aspire-0.2/conf/
  inflating: vosk-model-en-us-aspire-0.2/conf/mfcc.conf
  inflating: vosk-model-en-us-aspire-0.2/conf/model.conf
   creating: vosk-model-en-us-aspire-0.2/graph/
   creating: vosk-model-en-us-aspire-0.2/graph/phones/
  inflating: vosk-model-en-us-aspire-0.2/graph/phones/word_boundary.int
  inflating: vosk-model-en-us-aspire-0.2/graph/HCLG.fst
  inflating: vosk-model-en-us-aspire-0.2/graph/phones.txt
  inflating: vosk-model-en-us-aspire-0.2/graph/words.txt
   creating: vosk-model-en-us-aspire-0.2/rescore/
  inflating: vosk-model-en-us-aspire-0.2/rescore/G.carpa
  inflating: vosk-model-en-us-aspire-0.2/rescore/G.fst
Removing intermediate container cfc1fac8d23f
 ---> 04de9b250881
Step 4/6 : EXPOSE 2700
 ---> Running in fe0c5448b14a
Removing intermediate container fe0c5448b14a
 ---> fcf87c2bca47
Step 5/6 : WORKDIR /opt/vosk-server/websocket
 ---> Running in ac0f9cd6c228
Removing intermediate container ac0f9cd6c228
 ---> da261b5a31db
Step 6/6 : CMD [ "python3", "./asr_server.py", "/opt/vosk-model-en/model" ]

 ---> Running in 9ce16c343d0e
Removing intermediate container 9ce16c343d0e
 ---> 980bd4cfe0a8
Successfully built 980bd4cfe0a8
Successfully tagged alphacep/kaldi-en:latest
 sudo docker run -p 2700:2700 alphacep/kaldi-en:latest
Traceback (most recent call last):
  File "./asr_server.py", line 11, in <module>
    from vosk import Model, KaldiRecognizer
  File "/usr/local/lib/python3.7/dist-packages/vosk/__init__.py", line 4, in <module>
    from .vosk_cffi import ffi as _ffi
  File "/usr/local/lib/python3.7/dist-packages/vosk/vosk_cffi.py", line 2, in <module>
    import _cffi_backend
ModuleNotFoundError: No module named '_cffi_backend'

best regards

nshmyrev commented 3 years ago

This issue should be fixed now with updated docker files. Please try again.

lalimili6 commented 3 years ago

@nshmyrev I think this is because of default python on Debian 10 is 3.7 and we must install python3.8 in Docker or change the Debian version. https://github.com/alphacep/vosk-api/issues/294#issuecomment-726352352 https://github.com/alphacep/vosk-server/blob/c5148900586c9a325592ff5b7f8c57bf2b6e46eb/docker/Dockerfile.kaldi-vosk-server#L1

nshmyrev commented 3 years ago

I think this is because of default python on Debian 10 is 3.7 and we must install python3.8 in Docker or change the Debian version.

@lalimili6 You do not need 3.8 anymore, now Vosk works with any python version. The information in the link is outdated.