PySimpleGUI based DESKTOP APP that can RECOGNIZE any live streaming in 21 languages that supported by VOSK then TRANSLATE (using unofficial online Google Translate API) and display it as LIVE CAPTION / LIVE SUBTITLE
pyvosklivesubtitle.480p.mp4
The speech recognition part is using vosk python module https://pypi.org/project/vosk/
pip install --upgrade vosk
On the older versions (bellow 0.0.11) the translation part is using googletrans=4.0.04c1 and pygoogletranslation module https://github.com/Saravananslb/py-googletranslation, but since version 0.0.11 I decide to use my own simple translate function.
The GUI part is using pysimplegui https://github.com/PySimpleGUI/PySimpleGUI
pip install --upgrade pysimplegui
pip install --upgrade pyvosklivesubtitle
then you can run it by just type :
pyvosklivesubtitle
If you don't have python on your OS you can get compiled version from this release page assets.
When you run this app for the very first time it may takes some times to download vosk language model, you can check those downloaded models in "/home/username/.cache/vosk" (if you're on Linux) and "C:\Users\Username\.cache\vosk\" (if you're on Windows).
You can always download those small models manually from https://alphacephei.com/vosk/models then extract them to that used folder.
You can try to compile that script in win folder (if your OS is Windows) or linux folder (if your OS is Linux) into a single executable file with pyinstaller :
pip install pyinstaller
pyinstaller --onefile pyvls.py
The executable compiled file will be placed by pyinstaller into dist subfolder of your current working folder, then you can just put that compiled exe file into a folder that has been added to your PATH ENVIRONTMENT so you can execute it from anywhere.
DONT FORGET TO PLACE THOSE LIBS FILES FROM VOSK (libgcc_s_seh-1.dll, libstdc++-6.dll, libvosk.dll, & libwinpthread-1.dll if your OS is Windows, libvosk.so if your OS is Linux) INTO SAME FOLDER WITH COMPILED EXE FILE!
I was succesfuly compiled it in Windows 10 with pyinstaller-5.1 and Pyhton-3.10.4, and python-3.8.12 in Debian 9
Another alternative way you can install this script with python by cloning this git (or downloading this git as zip then extract it into a folder), and then just type :
python setup.py build
python setup.py install
If you fail when installing any python modules using pip, you can always use this way, get that module from github then build them manually
For best recognizing performance, on windows you will need STEREO MIX or VIRTUAL AUDIO CABLE as RECORDING/INPUT DEVICE
and on linux you willl need PAVUCONTROL (by choosing MONITOR of your audio device as INPUT DEVICE)
To DRAG/MOVE that TRANSLATION TEXT anywhere on the screen, just USE CONTROL KEY + LEFT MOUSE combination.
pyvosklivesubtitle [-S SRC_LANGUAGE] [-D DST_LANGUAGE]
for example : pyvosklivesubtitle -S ja -D en
options:
-h, --help show this help message and exit
-S SRC_LANGUAGE, --src-language SRC_LANGUAGE
Spoken language
-D DST_LANGUAGE, --dst-language DST_LANGUAGE
Desired language for translation
-ll, --list-languages
List all available source/destination languages
-ld, --list-devices show list of audio devices and exit
-f FILENAME, --filename FILENAME
audio file to store recording to
-d DEVICE, --device DEVICE
input device (numeric ID or substring)
-r SAMPLERATE, --samplerate SAMPLERATE
sampling rate in Hertz for example 8000, 16000, 44100, or 48000
-v, --version show program's version number and exit
Those command line switches are just to make this application directly select the language in combo box, so it's okay if you don't use them
MIT
Check my other SPEECH RECOGNITIION + TRANSLATE PROJECTS in https://botbahlul.github.io