-
-
Notifications
You must be signed in to change notification settings - Fork 55
Development
This app is developed using python version 3.11.6
but it should work with python 3.8+
For development, you might need to have Build tools for Visual Studio installed
- Clone the repo with its submodules by running
git clone --recurse-submodules https://github.com/Dadangdut33/Speech-Translate.git
- Cd into the project directory
- Create a virtual environment by running
python -m venv venv
- Activate your virtual environment
- Install all the dependencies needed by running
pip install -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu118
if you are using GPU orpip install -r requirements.txt
if you are using CPU. - You should be ready now π
Notes:
- If you forgot the
--recure-submodules
flag when cloning the repository, you can dogit submodule update --init --recursive
in the project directory to pull the needed submodules. - The
--extra-index-url
is needed to install CUDA version of pytorch and for this one we are using CUDA 11.8. If your device is not compatible or you need to use other version of CUDA you can check the previous pytorch version in this link or this.
You can run the app by running the Run.py
located in root directory with the command python Run.py
. Alternatively you can also run it using python -m speech_translate
in the root directory.
Before compiling the project, make sure you have installed all the dependencies and setup your pytorch correctly. Your pytorch version will control wether the app will use GPU or CPU (that's why it's recommended to make virtual environment for the project).
The pre compiled version in this project is built using cx_freeze, we have provided the script in build.py. This build script is only configured for windows build at the moment, but feel free to contribute if you know how to build properly for other OS.
To compile it into an exe run python build.py build_exe
in the root directory. This will produce a folder containing the compiled project alongside an executable in the build
directory. After that, use innosetup script to create an installer. You can use the provided installer.iss to create the installer.
I use vscode with the pylance
and isort
for the formatter of this project. The linter is provided using pylint
. There is a config for it in the .vscode folder
The architecture of the code is fairly simple with the code located inside the speech_translate
folder. The files and folder inside can be explained like this:
Run.py
β
βββ π assets/ -> folder to store assets of the app
β βββ ...
βββ π theme/ -> folder to store theme of the app
β βββ ...
βββ π ui/ -> location of code for the UI of the app
β βββ ...
βββ π utils/ -> location of code for the utility function of the app
β βββ ...
βββ __main__.py -> script to run the app in here along with some patches
βββ _constants.py -> constants variable
βββ _logging.py -> logger setup
βββ _path.py -> path/location needed for the app
βββ _version.py -> app and setting version
βββ linker.py -> containing bridge class to get around circular import, also have the setting json class instantiated here
The GUI of the app is made using tkinter, a very simple gui library. For the theme, we took advantage of sunvalley ttk theme made by rdbende. You can probably use other works made by rdbende if you want to add other themes.
To communicate with the other units of the code, we use linker.py
, in there we instantiate BridgeClass
as bc
and then use it to store reference to other class needed in the app. I know that there are other ways to do it but i think this one works just fine.
The main code to start the app is located at speech_translate/__main__.py
. In here we do some monkey patching and set environment for some of the library used in the app. After that we call the main function in speech_translate/ui/window/main.py
to start the app.
This project should be compatible with Windows and other platforms. But I only tested it extensively on Windows. If you find any bugs or issues, feel free to create an issue.
Go to: Download Page - Wiki Home - Code