Skip to content

PySimpleGUI based DESKTOP APP that can RECOGNIZE any live streaming in 23 languages that supported by VOSK then TRANSLATE (using unofficial online Google Translate API) and display it as LIVE CAPTION / LIVE SUBTITLE

License

botbahlul/pyvosklivesubtitle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyvosklivesubtitle

PySimpleGUI based DESKTOP APP that can RECOGNIZE any LIVE STREAMING in 23 languages that supported by VOSK then TRANSLATE (using unofficial online Google Translate API) and display it as LIVE CAPTION / LIVE SUBTITLE

pyvosklivesubtitle-0.1.13.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

Installation

pip install --upgrade pyvosklivesubtitle

then you can run it by just type :

pyvosklivesubtitle

If you don't have python on your OS you can try compiled version from this release page assets.

If it doesn't run well then you need to install python on your Windows system.

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.

NOTES :

START FROM VERSION 0.1.2 THIS APP USE streamlink MODULE WHICH SUPPORTS urllib3 >= 1.26, < 3.x BRANCH, SO IF YOU'RE STILL WANT TO INSTALL THIS APP TRY TO REINSTALL streamlink WITH --force-reinstall ARGUMENT.

pip install streamlink --force-reinstall

START FROM VERSION 0.1.2 YOU SHOULD USE THAT "mypyinstaller.bat" (or "mypyinstaller.sh" IF YOU'RE ON LINUX) TO COMPILE WITH pyinstaller.

THAT "streamlink" MODULE FOLDER MUST BE ON SAME FOLDER WITH "pyvls.pyw" and "mypyinstaller.bat", OR YOU CAN CHANGE THE LOCATION FOLDER BY EDITING "mypyinstaller.bat".

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!

ALSO NOTE THAT SINCE VERSION 0.1.2 THIS APP NEED ffmpeg AND ffprobe, you can get it from https://www.ffmpeg.org/

IN DEBIAN BASED LINUX OS YOU CAN INSTALL IT WITH :

sudo apt update
sudo apt install -y ffmpeg

I was succesfuly compiled this script 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 image image image

LAUNCH Audio Repeater MME, NOT Audio Repeater KS! AND THEN CLICK THAT START BUTTON AND MINIMIZE IT, DON'T CLOSE IT!

image

and on linux you willl need PAVUCONTROL (by choosing MONITOR of your audio device as INPUT DEVICE) image image

To DRAG/MOVE that TRANSLATION TEXT anywhere on the screen, just USE CONTROL KEY + LEFT MOUSE combination.

ANOTHER NOTES, DON'T FORGET TO CHANGE YOUR CONSOLE (COMMAND PROMPT WINDOW) CODE PAGE TO 65001 (UTF-8)!

To change the codepage for the console, do the following:

Start -> Run -> regedit
Go to [HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\Autorun]
Change the value to @chcp 65001>nul
If Autorun is not present, you can add a New String

image

Usage

usage: pyvosklivesubtitle [-h] [-S SRC_LANGUAGE] [-D DST_LANGUAGE] [-lls] [-lld] [-sf SUBTITLE_FILENAME] [-F SUBTITLE_FORMAT] [-lsf]
                          [-ld] [-af AUDIO_FILENAME] [-d DEVICE] [-r SAMPLERATE] [-u URL] [-vf VIDEO_FILENAME] [-v]

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
  -lls, --list-src-languages
                        List all available source languages
  -lld, --list-dst-languages
                        List all available destination languages
  -sf SUBTITLE_FILENAME, --subtitle-filename SUBTITLE_FILENAME
                        Subtitle file name for saved transcriptions
  -F SUBTITLE_FORMAT, --subtitle-format SUBTITLE_FORMAT
                        Desired subtitle format for saved transcriptions (default is "srt")
  -lsf, --list-subtitle-formats
                        List all available subtitle formats
  -ld, --list-devices   show list of audio devices and exit
  -af AUDIO_FILENAME, --audio-filename AUDIO_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
  -u URL, --url URL     URL of live streaming if you want to record the streaming
  -vf VIDEO_FILENAME, --video-filename VIDEO_FILENAME
                        video file to store recording to
  -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

License

MIT

Check my other SPEECH RECOGNITIION + TRANSLATE PROJECTS https://github.com/botbahlul?tab=repositories

Buy me coffee : https://sociabuzz.com/botbahlul/tribe

About

PySimpleGUI based DESKTOP APP that can RECOGNIZE any live streaming in 23 languages that supported by VOSK then TRANSLATE (using unofficial online Google Translate API) and display it as LIVE CAPTION / LIVE SUBTITLE

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages