Skip to content

For AI beginners, deploying AI software from source code can be challenging. Portable packages significantly lower the barrier to entry by allowing users to simply download, extract, and double-click to use the software. However, ready-made packages might not always be available or up-to-date. In such cases, you can create your own package and share it with others.

AI project models are often large, and with GPU support, even compressed into 7z format, the file size can easily exceed 5GB, making it difficult to upload and store. Therefore, I will no longer be creating portable packages. If you are interested, you can follow this tutorial to create your own and share it.

This tutorial uses F5-TTS as an example to create a portable package on Windows 10 with Python 3.10. The main steps are as follows:

  1. Download the Python 3.10 embed version (a zip archive, not an exe installer).
  2. Install pip and set up dependency search paths for the project.
  3. Download the F5-TTS source code.
  4. Install the F5-TTS dependencies.
  5. Create a one-click launch script and set the model directory to the project directory.
  6. Configure a proxy and download the models.
  7. Perform a cloning task to complete the download of Whisper and other models.
  8. Compress into a portable package.
  9. Creating Portable Packages 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 it to store the downloaded Python 3.10 embed version files.

Before starting, be sure to click "View" in the folder navigation bar and check "File name extensions," otherwise, you may encounter errors, especially if you're not familiar with extensions.

Show file extensions


1. Download the Python 3.10 Embed Version

Important: Download the embed version, not the exe installer. This version doesn't rely on your system's Python environment. Even if you 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. This will give you a zip archive.

    Download Python embed version

    Make sure you download this version! Do not make mistakes!

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

    Copy Python embed files to runtime folder


2. Install pip and Modify Package Search Paths

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" to save the file to the runtime directory. After saving, the runtime folder should contain a file named get-pip.py.

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

    • Type 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 within runtime

    • In the terminal window, type the command .\python get-pip.py and press Enter. Important: Make sure the current folder address displayed in the command line is within the runtime folder, otherwise, it will cause errors.

      Wait for the installation to complete...

      pip installation in progress

      The pip module is installed successfully!

      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 contents 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 look like this, please double-check to ensure correctness:

      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 zip archive of the source code.

    Download F5-TTS source code

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

    Copy files inside F5-TTS-main

    After extraction, the contents of the D:\f5win folder should look like this:

    Correct D:5win directory structure after copying


Return to the previous CMD window

Back to the terminal window just now, execute the cd ../ command to make sure that the address before the command line has reduced 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 current command line path is D:\f5win (without runtime).

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

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

    Installing dependencies

    Wait for the installation to complete...

All dependencies installed successfully

  • If you want the portable package to support NVIDIA graphics cards (optional): Continue executing the following command to install the CUDA version of PyTorch and torchaudio (note the spaces and the dot, the command cannot be wrapped to the next line):
    .\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 Launch Script

By default, models are saved to the user directory on the C drive. To facilitate integration, we need to download the models into the portable package.

  • In the D:\f5win folder, right-click -- New -- Text document to 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, select "Yes". If the warning does not pop up, it means you have made a mistake in the modification. Please check whether the file extension is displayed as described in the preparation section at the top of this article.

    Rename to run.bat warning popup


6. Configure a Scientific Internet Access Environment

Due to the limitations of the domestic network environment, it is not possible to directly access Hugging Face (huggingface.co) where the F5-TTS models are located. Therefore, you need to configure a scientific internet access environment 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 as instructed.

  • If a black window opens after double-clicking, it will start downloading the models to the D:\f5win\models folder.

    Downloading models

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

    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

  • Once the models are downloaded, a browser window will open automatically. Models downloaded, browser opened 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 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 portable package.


8. Compress into a Portable 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, and they can use it by extracting it and double-clicking run.bat (or Click me to start.bat).


9. How to Create Portable Packages for Other AI Projects

Most Python-based open-source projects on GitHub can be packaged using a similar method. The main differences are in 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 installation package.

  2. Contents of the python310._pth file:

    • ./Lib/site-packages still needs to be added.
    • 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/folder name.
  3. Launch command for the run.bat script:

    • You only need to modify this line of code:
      "%~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 (not including 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.