Pre-install Dependencies
Use brew to install python3 and ffmpeg on MacOS. If your Mac doesn't support the brew command, you need to install Homebrew first.
Use this command to install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
The above command requires a stable internet connection. If it fails, use the command below:
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
Open a terminal and execute the following three commands separately:
brew install [email protected] ln -s /opt/homebrew/opt/[email protected]/bin/python3 /opt/homebrew/bin/python3 ln -s /opt/homebrew/opt/[email protected]/bin/pip3 /opt/homebrew/bin/pip3
brew install ffmpeg
brew install libsndfile
Make sure all commands execute correctly without errors before proceeding.
Download and Extract the Source Code
Open the website https://github.com/jianchang512/pyvideotrans
to download the source code zip package.
Extract the source code package to get a folder named pyvideotrans-main
. Enter this folder pyvideotrans-main
and view and remember the absolute path of the folder, for example, /Users/c1/desk/pyvideotrans-main
.
Open a terminal inside this folder, make sure the end of the terminal line is pyvideotrans-main
, and enter ls sp.py
to ensure that the output is the content of sp.py. If it prompts that the file does not exist or no such file, it means that it is not in this folder. You must cd
into this folder.
Create a Virtual Environment using the venv Module and Install Dependencies
In the terminal opened in the previous step, execute the command:
python3.10 -m venv venv
. After execution, confirm that avenv
folder is generated in the same directory as sp.py.Then continue to execute the command
source ./venv/bin/activate
.Then execute the following 2 commands separately, using the Alibaba Cloud mirror to speed up the installation:
python3.10 -m pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
python3.10 -m pip config set install.trusted-host mirrors.aliyun.com
After the above commands are executed, then execute
python3.10 -m pip install -r requirements.txt
.At this point, the installation is complete, but there are no models yet. You need to go to
https://github.com/jianchang512/stt/releases/tag/0.0
to download the model and place it correctly according to the instructions before you can use it happily.
How to Open the Software
Each time you open the software, you need to open a terminal in the software directory and make sure that the end of the terminal is pyvideotrans-main
.
Then first execute the command source ./venv/bin/activate
, and then confirm that the head of the terminal is the word (venv)
.
Then execute python3.10 sp.py
to open the software.
If executing source ./venv/bin/activate
prompts that the file does not exist, it means that your terminal is not in this folder and you need to cd into the folder.
Pay attention, when there is a (venv)
character at the beginning of the terminal prompt line, executing python3.10 sp.py
will not report an error and the software can be opened correctly.
Encountered Errors
- First check whether the terminal is in the software code folder. The judgment criterion is whether
pyvideotrans-main
is after the terminal command prompt. If not, you must ensure that you are in this folder. - Check whether the terminal prompt prefix is
(venv)
. If not, it means that the virtual environment is not activated. You need to executesource ./venv/bin/activate
to activate it before executingpython3.10 sp.py
. - Each time after closing the terminal or software, if you want to open the software again, you must execute
source ./venv/bin/activate
to activate the virtual environment.