Utilisation de l'auto-transcription dans Pod
Pour découper le fichier audio de pod et faire sa transcription, nous avons besoin de Sox, il faut donc installer les deux librairies suivantes :
(django_pod) pod@:/path/to/project/django_projects/pod$ sudo apt-get install sox
(django_pod) pod@:/path/to/project/django_projects/pod$ sudo apt-get install libsox-fmt-mp3
Il faut également installer le module python ffmpeg-normalize
(django_pod) pod@:/path/to/project/django_projects/pod$ pip install ffmpeg-normalize
L'ensemble du modèle peuvent être stockés dans /path/to/project/django_projects/transcription. Il convient de faire un sous-dossier par langue (I.E: fr, en etc.), et un sous-dossier par type de modèle (I.E: stt, vosk, etc.)
Par exemple, pour un modèle vosk français:
/path/to/project/django_projects/transcription/fr/vosk/vosk-model-fr-0.6-linto-2.2.0/
Les fichiers pour les modèles peuvent être téléchargés sur cette page https://alphacephei.com/vosk/models.
Par exemple pour le modèle français:
(django_pod) pod@:/path/to/project/django_projects/transcription/fr/vosk/$ wget https://alphacephei.com/vosk/models/vosk-model-fr-0.6-linto-2.2.0.zip
Il faut après avoir téléchargé le modèle, il faut le décompresser. Pour cela vous pouvez utiliser la librairie unzip:
(django_pod) pod@:/path/to/project/django_projects/pod$ sudo apt-get install unzip
(django_pod) pod@:/path/to/project/django_projects/pod$ unzip vosk-model-fr-0.6-linto-2.2.0.zip
Dans le fichier custom/settings-local.py, il suffit d’ajouter les paramètres suivant:
Pour Pod avec stt et vosk avec fr et en :
USE_TRANSCRIPTION = True
TRANSCRIPTION_TYPE = "STT"
MODEL_PARAM = {
# le modèle stt
'STT': {
'fr': {
'model': "/path/to/project/Esup-django_projects/transcription/model_fr/stt/output_graph.tflite",
'scorer': "/path/to/project/django_projects/transcription/model_fr/stt/kenlm.scorer",
}
},
# le modèle vosk
'VOSK':{
'fr': {
'model': "/path/of/project/django_projects/transcription/model_fr/vosk/vosk-model-fr-0.6-linto-2.2.0",
},
‘en’: {
'model': "/path/of/project/django_projects/transcription/model_en/vosk/vosk-model-en-us-0.22",
}
}
}
Maintenant lors de l’upload d’une vidéo avec l’auto-transcription activée le modèle Vosk sera utilisé pour effectuer la transcription.
Activer L’enrichissement du modèle vosk dans Pod:
Les modèles utilisés pour l’enrichissement du modèle peuvent être stockés dans /path/to/project/django_projects/compile-model
Il faut télécharger le modèle de compilation correspondant sur ce lien https://alphacephei.com/vosk/lm#update-process.
Par exemple pour le modèle français:
(django_pod) pod@:/path/to/project/django_projects/compile-model/fr$ wget https://alphacephei.com/vosk/models/vosk-model-fr-0.6-linto-2.2.0-compile.zip
Il faut après avoir téléchargé le modèle de compilation, le décompresser. Pour cela vous pouvez utiliser la librairie unzip:
(django_pod) pod@:/path/to/project/django_projects/compile-model/fr$ sudo apt-get install unzip
(django_pod) pod@:/path/to/project/django_projects/compile-model/fr$ unzip vosk-model-fr-0.6-linto-2.2.0-compile.zip
Il faut seulement que la structure du dossier compile-model ressemble à cela:
(django_pod) pod@:/path/to/project/django_projects/compile-model
compile-model
|--fr | |--conf | | |... | | | |--data | | |... | | | |--db | | |... | | | |--exp | | |... | | | |--local | | |... | | | |--mfcc | | |... | | | |--steps | | |... | | | |--utils | | |... | | | |--cmd.sh | |--compile-grapg.sh | |--decode.sh | |--dict.py | |--path.sh | |--en
Maintenant il faut installer docker sur votre machine. (voir https://docs.docker.com/engine/install/debian/ ci besoin)
Après que docker soit installer créer un fichier entrypoint.sh et DockerFile dans un même dossier.
Copier le script suivant dans le fichier entrypoint.sh;
#!/bin/bash modelPath="$KALDI_ROOT/compile-model/$1" cat "$KALDI_ROOT/tools/env.sh" > "$modelPath/path.sh" cd $modelPath /bin/bash -c "./compile-graph.sh" /bin/bash -c "utils/build_const_arpa_lm.sh lm.gz data/lang_test data/lang_test_rescore"
Puis copier le code ci-dessous fait sur mesure afin d’enrichire un modèle dans le Fichier DockerFile, cela créera un container avec tout ce qu’il faut d’installer :
## Build the DockerFile
# docker build --tag kaldi -f DockerFile .
##
## Example of manual execution of the Docker file
# sudo docker run -v ${PWD}/compile-model:/kaldi/compile-model -it kaldi
##
FROM debian:10
RUN apt-get update && apt-get install -y ca-certificates \
&& apt-get install -y \
python3-pip \
git \
&& apt-get install -y zlib1g-dev automake autoconf unzip wget sox gfortran libtool subversion python2.7 nano libfst-tools \
&& apt-get clean
RUN python3 --version
ENV KALDI_ROOT="/kaldi"
RUN git clone https://github.com/kaldi-asr/kaldi.git $KALDI_ROOT
WORKDIR $KALDI_ROOT"/tools"
RUN bash $KALDI_ROOT"/tools/extras/check_dependencies.sh"
RUN touch $KALDI_ROOT"/tools/python/.use_default_python"
RUN bash $KALDI_ROOT"/tools/extras/install_mkl.sh"
RUN apt-get install gfortran sox
RUN make -j $(nproc)
RUN pip3 install phonetisaurus
RUN bash $KALDI_ROOT"/tools/extras/install_opengrm.sh"
RUN make
RUN bash $KALDI_ROOT"/tools/extras/install_irstlm.sh"
RUN apt-get install gawk
RUN bash $KALDI_ROOT"/tools/extras/install_srilm.sh" "unkown" "unkown" "unkown"
RUN cd $KALDI_ROOT"/src" && ./configure --shared
RUN cd $KALDI_ROOT"/src" && make depend -j $(nproc)
RUN cd $KALDI_ROOT"/src" && make -j $(nproc)
RUN cd $KALDI_ROOT"/src/fstbin" && make
RUN echo "export PATH="$KALDI_ROOT"/src/fstbin:\$PATH" >> $KALDI_ROOT"/tools/env.sh"
RUN cd $KALDI_ROOT"/src/lmbin" && make
RUN echo "export PATH="$KALDI_ROOT"/src/lmbin:\$PATH" >> $KALDI_ROOT"/tools/env.sh"
RUN cd $KALDI_ROOT"/src/tree" && make
RUN echo "export PATH="$KALDI_ROOT"/src/tree:\$PATH" >> $KALDI_ROOT"/tools/env.sh"
RUN cd $KALDI_ROOT"/src/bin" && make
RUN echo "export PATH="$KALDI_ROOT"/src/bin:\$PATH" >> $KALDI_ROOT"/tools/env.sh"
COPY entrypoint.sh /entrypoint.sh
WORKDIR $KALDI_ROOT
ENTRYPOINT ["/entrypoint.sh"]
Après avoir copié et créer les deux fichier Dockerfile et entrypoint.sh il suffit de lancer la commande ci-dessous en étant dans la même dossier que les fichiers précédemment mentionnés.
docker build --tag kaldi -f DockerFile .
Pour finir il faut activer l’enrichissement du modèle vosk dans une application pod, pour cela il suffit d’ajouter dans le fichier custom/settings-local.py les paramètres suivant:
ACTIVE_ENRICH = True MODEL_COMPILE_DIR = "/path/to/project/django_projects/compile-model"