For AI novices, deploying an AI software from source code can be challenging. With a package, you can simply download, unzip, and double-click to use it, greatly reducing the barrier to entry. However, sometimes you may not find an existing package, or the package may not be updated in time. At this point, you can try creating your own package and sharing it with others.
Since AI project models are usually very large, coupled with GPU support, even compressed into 7z format, the file size may far exceed 5GB, which is difficult to upload to cloud storage and store. Therefore, I will no longer create packages. If you are interested, you can create your own package according to this tutorial and share it with others.
This tutorial takes F5-TTS as an example and uses Python 3.10 on Windows 10 to create a package. The main steps are as follows:
- Download Python 3.10 embed version (not the exe installer, but a zip archive).
- Install pip and set dependency lookup paths for the project.
- Download F5-TTS source code.
- Install F5-TTS dependency modules.
- Create a one-click startup script and set the model directory to the project directory.
- Configure a proxy and download the models.
- Execute a clone task once to complete the download of Whisper and other models.
- Compress into a package.
- Create packages for other AI projects
Preparation Before Starting:
First, create an empty folder. To avoid errors, it is recommended to create an English folder on a non-system drive, such as D:\f5win
. This article uses D:\f5win
as an example. Then, create an empty folder runtime
inside this folder to store the Python 3.10 embed version files downloaded later.
Before you start, be sure to click "View" in the folder navigation bar and then check "File name extensions", otherwise it will be easy to make mistakes in subsequent operations, especially for friends who are not familiar with extensions.
1. Download Python 3.10 embed version
Important Note: Here we are downloading the embed version, not the exe installer. This version does not depend on your local Python environment, so even if you already have Python installed locally, you still need to download this version.
Download address: https://www.python.org/downloads/release/python-31011/
After opening the webpage, scroll to the bottom and click
Windows embeddable package (64-bit)
to download. After downloading, you will get a zip archive.Be sure to download this version, don't get it wrong!
After the download is complete, unzip the zip archive and copy all the files inside to the
runtime
folder you just created. As shown below:
2. Install pip and modify package lookup path
The embed version of Python does not include the pip module, so you need to install it manually.
Install pip:
Open this address: https://bootstrap.pypa.io/get-pip.py
Right-click and save as, save the file to the
runtime
directory. After saving, theruntime
folder should have a file namedget-pip.py
.Enter
cmd
in the address bar of theruntime
folder and press Enter to open a terminal window (black window).In the terminal window, enter the command
.\python get-pip.py
and press Enter. Be sure to note whether the current folder address displayed in the command line is within theruntime
folder, otherwise it will cause an error.Wait for the installation to complete...
The pip module is installed successfully!
Modify the
python310._pth
file:Find the file named
python310._pth
in theruntime
folder, right-click and open it with Notepad.On the line below the dot symbol
.
in the second line, add the following three lines:./Lib/site-packages ../src ../src/f5_tts
Save the file. The modified file content should be as follows, please check carefully to ensure it is correct:
3. Download F5-TTS Source Code
Open the F5-TTS project's GitHub repository: https://github.com/SWivid/F5-TTS
Download the zip archive of the source code.
Unzip the downloaded zip package and copy all the files in the
F5-TTS-main
folder to theD:\f5win
folder. Note: Copy the files inside, not the entireF5-TTS-main
folder.After unzipping, the content of the
D:\f5win
folder should be as shown below:
Return to the previous CMD window
In the same terminal window, execute the
cd ../
command to ensure that the address before the command line has reduced theruntime
characters and becomes as follows. The following operations must be performed in theD:/f5win
directory
4. Install Dependency Modules
Return to the cmd terminal window and confirm again that the path displayed in the current command line is
D:\f5win
(withoutruntime
).Execute the following command to install dependencies (note spaces and dot symbols):
.\runtime\python -m pip install -e .
Wait for the installation to complete...
- If you want the package to support NVIDIA graphics cards (optional): Continue to execute the following command to install the CUDA version of PyTorch and torchaudio (note spaces and dot symbols, the command cannot be wrapped):
.\runtime\python -m pip install torch==2.4.0+cu124 torchaudio==2.4.0+cu124 --extra-index-url https://download.pytorch.org/whl/cu124
5. Create a One-Click Startup Script
By default, models will be saved to the user directory on the C drive. For easy integration, we need to download the models into the package.
- In the
D:\f5win
folder, right-click -- New -- Text Document, create arun.txt
file, open it with Notepad, and enter the following code:
```bat
@echo off
chcp 65001 > nul
set "HF_HOME=%~dp0models"
set "MODELSCOPE_CACHE=%~dp0models"
echo HF_HOME: %HF_HOME%
echo MODELSCOPE_CACHE: %MODELSCOPE_CACHE%
"%~dp0runtime\python" -m f5_tts.infer.infer_gradio --inbrowser
pause
```
The above script means: save the model to the
models
folder in the current directory, then start the web interface, and automatically open it in the browser
After saving the file, rename
run.txt
torun.bat
. A warning will pop up at this time, select "Yes". If the warning does not pop up, it means you modified it incorrectly, please check whether you have displayed the file extension as described at the beginning of this article.
6. Configure Science Online Environment
Due to the limitations of the domestic network environment, you cannot directly access Hugging Face (huggingface.co) where the F5-TTS model is located. Therefore, you need to configure a science online environment and set it as a system proxy.
For example, if the tool is v2ray, you can set it like this:
After the configuration is complete, double-click the run.bat
file you just created.
If the file is opened directly with Notepad after double-clicking, it means you failed to modify the extension, please return to the beginning of this article to prepare and select the file extension according to the instructions.
If a black window opens after double-clicking, it will start downloading the model to the
D:\f5win\models
folder.If an error similar to the following occurs, it means that you have not configured the science online environment correctly, or have not set it correctly as a system proxy, resulting in being unable to connect to Hugging Face to download the model.
Sometimes the download fails halfway, the biggest reason is that your proxy node is unstable, please change to a more stable proxy or node
After the model is downloaded, the browser window will open automatically.
7. Perform a Cloning Task to Download the Whisper Model
When performing voice cloning, if the text corresponding to the reference audio is not provided, F5-TTS will automatically download the Whisper model from Hugging Face. To package it completely, we need to download it in advance.
In the automatically opened Web window, select a 5-10 second clean reference audio, enter the text you want to synthesize (for example, "Hello friend"), and then click "Synthesize".
This will start downloading the Whisper model.
When the synthesis is successful and there are no errors, you can start packaging the project into a package.
8. Compress into a Package
- Before compressing, you can rename
run.bat
toClick to Start.bat
to make it easier for novice users to understand. - Compress the entire
D:\f5win
folder into a zip file, or compress it into a smaller 7z file. - Share the package with others, and they can use it by unzipping it and double-clicking
run.bat
(orClick to Start.bat
).
9. How to Create Packages for Other AI Projects
Most Python-based open source projects on GitHub can use similar methods to create packages. The main differences are in the following three points:
Python version: Python 3.10 is the most common version and is suitable for most projects. If the project has special requirements (such as 3.11 or 3.12), you can find the corresponding version of
Windows embeddable package (64-bit)
on this page https://www.python.org/downloads/windows/. Be sure to note that you cannot download the exe installer.Content of the
python310._pth
file:./Lib/site-packages
is still required.- Other paths are added according to the actual situation of the project.
- If there is a code directory named
cfg
in the project, add a line../cfg
. - If the project has a
src
directory and there are other folders undersrc
, continue to add../src/directory name
.
Startup command of the
run.bat
script:- You only need to modify this line of command:
"%~dp0runtime\python" -m f5_tts.infer.infer_gradio --inbrowser
- The
"%~dp0runtime\python"
part remains unchanged, and the part after it is changed to the command to start the corresponding project (excludingpython
). - If you have any questions, you can give the content of
run.bat
and the startup command of the corresponding project to AI, and let it give a new startup script based onrun.bat
. Remember to tell AI to use the Python interpreter inrun.bat
.
- You only need to modify this line of command: