[PYTHON] Implementieren Sie ESPnet auf einem Macbook

Hintergrund

Ich wollte eine Open-Source-Spracherkennungsbibliothek auf meinem Mac verwenden, aber nach vielen Recherchen konnte ich nicht einmal schließen, ob ich könnte. Requirement environments according to ESPnet official documents

Supported Linux distributions and other requirements
We support the following Linux distributions with CI. If you want to build your own Linux by yourself, please also check our CI configurations. to prepare the appropriate environments
ubuntu18
ubuntu16
centos7
debian9

(In der Dokumentation scheint nur Linux zu funktionieren, aber ich konnte es unter macOS implementieren.) Hier ist eine Zusammenfassung meiner eigenen Methoden und Probleme, die aufgetreten sind.

Verfahren

Betriebsumgebung

** macOS Calatina 10.15.4 ** (derzeit die neueste Version von 2020.4) Anaconda3(Python3.7.3)

Homebrew-Installation

https://brew.sh/index_ja

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Umwelt vorbereiten

Laut Dokumentation ist gcc 4.9+ für PyTorch 1.0.0+ erforderlich

warp-transducer.done: espnet.done
    rm -rf warp-transducer
    git clone https://github.com/HawkAaron/warp-transducer.git
    # Note: Requires gcc>=5.0 to build extensions with pytorch>=1.0

Wenn Sie sich auf das Makefile von ESPnet beziehen, ist ** gcc> = 5.0 ** erforderlich.

Installieren Sie gcc

$ brew install gcc
$ ln -s /usr/local/bin/gcc-9 /usr/local/bin/gcc
$ ln -s /usr/local/bin/g++-9 /usr/local/bin/g++
$ gcc --version
gcc-9 (Homebrew GCC 9.3.0_1) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.

Installieren Sie cmake

Laden Sie die macOS-Version von [https://cmake.org/download/] herunter und installieren Sie sie (https://cmake.org/download/).

Installiere sox, ffmepg, flac

$ conda install -c conda-forge sox
$ conda install -c conda-forge ffmpeg
$ brew install flac
$ brew install automake

Installieren Sie autoconf

Download von http://ftp.gnu.org/gnu/autoconf/.

$ wget http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.xz
$ tar xvfz autoconf-latest.tar.xz
$ cd autoconf-latest
$ ./configure --prefix=/usr  #Wenn Sie hier keine Berechtigung erhalten können, stellen Sie das Präfix ein~Bitte im Folgenden.
$ make
$ make install
$ git clone https://github.com/kaldi-asr/kaldi
$ cd kaldi/tools
$ ./extras/install_openblas.sh #openBLAS installation
$ ./extras/check_dependencies.sh 

Nach der Implementierung aller Abhängigkeiten

$ make -j <Anzahl der Themen>  #Hier ist es ungewöhnlich langsam, also beeilen Sie sich und nutzen Sie alle Kerne.

kompilieren ohne cuda

$ cd ../src
$ ./configure --mkl-root=/opt/intel/compilers_and_libraries_2020/mac/mkl --use-cuda=no
$ make -j clean depend; make -j <NUM-CPU>

ESPnet-Installation

$ git clone https://github.com/espnet/espnet
$ cd espnet/tools

Wenn der mit Xcode gelieferte Clang bereits installiert ist, wird Clang auch dann aufgerufen, wenn Sie den Befehl gcc drücken. Das Kompilieren mit clang verursacht das Problem `clang: error: nicht unterstützte Option'-fopenmp' `, daher müssen Sie die Compilervariablen für gcc definieren, bevor Sie make ausführen.

$ export CC=gcc
$ export CXX=g++

$ make KALDI=<PATH_TO_KALDI>  #OPTIONS

OPTIONS:

CUPY_VERSION='' #CPU-Leere Cupy-Version nur zur Installation.
PYTHON=/opt/anaconda3/bin/python3.7 #Bitte geben Sie PYTHON an, wenn in Miniconda ein Fehler vorliegt.
TH_VERSION=1.2.0 #Warp für MacOS-Version 1 mit integriertem CTC-Verlust aufgrund fehlenden CTC-Pakets.2.Benötigt 0 oder mehr Pytroch.
INFO: library availableness check start.
INFO: # libraries to be checked = 7
INFO: --> espnet is installed.
INFO: --> kaldiio is installed.
INFO: --> matplotlib is installed.
INFO: --> torch is installed.
INFO: --> chainer is installed.
INFO: --> chainer_ctc is installed.
WARNING: --> warprnnt_pytorch is not installed.
INFO: library availableness check done.
INFO: 6 / 7 libraries are correctly installed.
INFO: please try to setup again and then re-run this script.
make: *** [check_install] Error 1

Es scheint, dass warprnnt_pytorch keine reine CPU-Plattform sein muss, daher ist dies abgeschlossen.

Überprüfung

$cd espnet/egs/csj/asr1;bash ../../../utils/recog_wav.sh --models csj.transformer.v1 <WAV-Datei>

Unten sehen Sie das Modell csj.transformer mit japanischen ASR-Ergebnissen

stage 0: Data preparation
stage 1: Feature Generation
steps/make_fbank_pitch.sh --cmd run.pl --nj 1 --write_utt2num_frames true decode/osa/data decode/osa/log decode/osa/fbank
steps/make_fbank_pitch.sh: moving decode/osa/data/feats.scp to decode/osa/data/.backup
utils/validate_data_dir.sh: Successfully validated data-directory decode/osa/data
steps/make_fbank_pitch.sh: [info]: no segments file exists: assuming wav.scp indexed by utterance.
steps/make_fbank_pitch.sh: Succeeded creating filterbank and pitch features for data
/Users/soshiyuu/signal/espnet/egs/csj/asr1/../../../utils/dump.sh --cmd run.pl --nj 1 --do_delta false decode/osa/data/feats.scp decode/download/csj.transformer.v1/data/train_nodup_sp/cmvn.ark decode/osa/log decode/osa/dump
stage 2: Json Data Preparation
/Users/soshiyuu/signal/espnet/egs/csj/asr1/../../../utils/data2json.sh --feat decode/osa/dump/feats.scp decode/osa/data decode/osa/dict
/Users/soshiyuu/signal/espnet/egs/csj/asr1/../../../utils/feat_to_shape.sh --cmd run.pl --nj 1 --filetype  --preprocess-conf  --verbose 0 decode/osa/dump/feats.scp decode/osa/data/tmp-EPng1/input_1/shape.scp
sym2int.pl: replacing X with 1
** Replaced 1 instances of OOVs with 1
stage 3: Decoding

Recognized text:Wie wäre es am Montagmorgen, ist es nicht kostenlos?



Recommended Posts

Implementieren Sie ESPnet auf einem Macbook
OpenPose auf dem MacBook Pro
OpenPose auf MacBook Pro Teil 2
Retina-Netz unter CentOS implementiert
Lernen Sie Paints Chainer mit Macbook Pro ~ Operation