Pre-install Related Dependencies
On macOS, use brew to install python3 and ffmpeg. If your Mac does not 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 VPN to be executed successfully. If it fails, please 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 3 commands respectively:
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
Confirm that all executions are correct and there are no errors, then continue to read downward.
Download and Unzip the Source Code
Open the website https://github.com/jianchang512/pyvideotrans, download the source code zip package as shown in the figure
Unzip the source code package to get a folder pyvideotrans-main
. Enter this folder pyvideotrans-main
, view and remember the absolute path of the folder, such as /Users/c1/desk/pyvideotrans-main
. The file list in the folder should be similar to the figure below.
Open a terminal in this folder, make sure the end of the terminal line is pytvideotrans-main
, enter ls sp.py
, and make sure 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 the venv folder is generated in the same directory as sp.pyThen continue to execute the command
source ./venv/bin/activate
Then execute the following 2 commands respectively, using the Aliyun 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, then 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, making sure the end of the terminal is pyvideotrans-main
Then first execute the source ./venv/bin/activate
command, and confirm that the head of the terminal is (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 this folder.
Pay attention, when the prompt line of the terminal has the (venv)
character at the beginning, then executing python3.10 sp.py
will not report an error and can correctly open the software.
Encountered Errors
- First check whether the terminal is in the software code folder. The judgment standard 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
and then executepython3.10 sp.py
after activation. - Each time you close the terminal or software, and then want to open the software again, you must execute
source ./venv/bin/activate
to activate the virtual environment.