Skip to content

For AI beginners, deploying an AI software from source code can be a bit challenging. A self-contained package simplifies the process: download, extract, double-click, and you're ready to go, significantly lowering the barrier to entry. However, sometimes a ready-made package isn't available, or it hasn't been updated recently. In such cases, you can try creating your own package and sharing it with others.

AI project models are often large, and with GPU support, even when compressed to 7z format, the file size can easily exceed 5GB. This makes uploading and storing them difficult. Therefore, I won't be creating packages myself anymore. If you're interested, you can follow this tutorial to create your own package and share it.

This tutorial uses F5-TTS as an example to create a self-contained package on Windows 10 using Python 3.10. Key steps include:

  1. Download the Python 3.10 embed version (not the exe installer, but a zip archive).
  2. Install pip and set up the dependency lookup path for the project.
  3. Download the F5-TTS source code.
  4. Install F5-TTS's dependencies.
  5. Create a one-click startup script and set the model directory to the project directory.
  6. Configure a proxy to download the models.
  7. Run a cloning task once to complete the download of Whisper and other models.
  8. Compress into a package.
  9. Make Integration package for other AI projects

Preparations:

First, create an empty folder. To avoid errors, it's 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 another empty folder named runtime inside this folder, which will be used to store the Python 3.10 embed version files downloaded later.

Before starting, be sure to click "View" in the folder navigation bar and check "File name extensions". Otherwise, errors may occur in subsequent operations, especially for those unfamiliar with extensions.

Show file extensions


1. Download the Python 3.10 embed Version

Important: Make sure to download the embed version, not the exe installer. This version doesn't rely on your machine's Python environment. Even if you already have Python installed, you still need to download this version.

  • Download address: https://www.python.org/downloads/release/python-31011/

  • After opening the page, scroll to the bottom and click Windows embeddable package (64-bit) to download. You'll get a zip archive.

    Download Python embed version

    Make sure to download this version, don't get it wrong!

  • After downloading, extract the zip archive and copy all the files inside to the runtime folder you created earlier. As shown below:

    Python embed files copied to the runtime folder


2. Install pip and Modify Package Lookup Path

The embed version of Python doesn't 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, saving the file to the runtime directory. After saving, the runtime folder should have a file named get-pip.py.

      Download get-pip.pyget-pip.py fileget-pip.py in runtime directory

    • Enter cmd in the address bar of the runtime folder and press Enter to open a terminal window (black window).

      Open cmd and confirm the path is in runtime

    • 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 in the runtime folder, otherwise an error will occur.

      Wait for the installation to complete...

      pip installation in progress

      The pip module is successfully installed!

      pip module installed successfully

  • Modify the python310._pth file:

    • Find the file named python310._pth in the runtime folder, right-click and open it with Notepad.

      Default content of python310._pth file

    • On the line below the dot . on 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:

      Modified python310._pth file content should be as follows


3. Download the F5-TTS Source Code

  • Open the F5-TTS project's GitHub repository: https://github.com/SWivid/F5-TTS

  • Download the source code's zip archive.

    Download F5-TTS source code

  • Extract the downloaded zip package and copy all the files from the F5-TTS-main folder to the D:\f5win folder. Note: Copy the files inside, not the entire F5-TTS-main folder.

    Copy files from F5-TTS-main

    After extracting, the content of the D:\f5win folder should look like this:

    Correctly copied D:5win directory structure


Return to the previous CMD window

Still in the same terminal window, execute the cd ../ command to ensure that the address before the command line has been reduced by the runtime characters, becoming as follows. The following operations must be performed in the D:/f5win directory.

4. Install Dependencies

  • Return to the cmd terminal window and double-check that the path currently displayed in the command line is D:\f5win (without runtime).

  • Execute the following command to install dependencies (note the spaces and dot):

    .\runtime\python -m pip install -e .

    Installing dependencies

    Wait for the installation to complete...

All dependencies installed

  • 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 the spaces and dots, 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 are saved in the user directory on the C drive. For packaging convenience, we need to download the models into the package.

  • In the D:\f5win folder, right-click -- New -- Text Document, create a run.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 to run.bat. A warning will pop up at this time, select "Yes". If no warning pops up, it means you have modified it incorrectly, please check whether the file extension has been displayed as described in the preparation section at the top of this article.

    Warning popup when renaming to run.bat


6. Configure Scientific Internet Access

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 scientific internet access and set it as a system proxy.

For example, if the tool is v2ray, you can set it like this:

Set as system proxy in v2ray

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 that you failed to modify the extension. Please return to the preparation section at the top of this article 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.

    Downloading model

  • If an error similar to the following occurs, it means that you have not configured scientific internet access correctly, or have not set it as a system proxy correctly, resulting in a failure to connect to Hugging Face to download the model.

    Download model error: Failed to connect to huggingface.co

    Sometimes the download fails halfway, the biggest reason is that your proxy node is unstable, please replace it with a more stable proxy or node

  • After the model is downloaded, the browser window will automatically open. Model download completed, browser opened automatically


7. Perform a Cloning Task Once 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. In order to package completely, we need to download it in advance.

  • In the automatically opened Web window, select a clean reference audio of 5-10 seconds, enter the text you want to synthesize (for example, "Hello friend"), and click "Synthesize".

    Web interface

  • This will start downloading the Whisper model.

    Downloading Whisper model

  • When the synthesis is successful and there are no errors, you can start packaging the project into a package.


8. Compress into Package

  • Before compressing, you can rename run.bat to Click me 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 compressed package with others, they can extract it and double-click run.bat (or Click me to start.bat) to use it.


9. How to Create Integration package for Other AI Projects

Most Python-based open-source projects on GitHub can use a similar method to create packages. The main differences are the following three points:

  1. 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.

  2. Content of the python310._pth file:

    • ./Lib/site-packages is still required.
    • Add other paths 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 under src, continue to add ../src/directory name.
  3. 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
    • Keep the "%~dp0runtime\python" part unchanged, and change the part after it to the command to start the corresponding project (excluding python).
    • 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 on run.bat. Remember to tell AI to use the Python interpreter in run.bat.