Skip to content

For AI novices, deploying an AI software from source code can be challenging. With a portable package, it becomes as simple as downloading, extracting, and double-clicking, significantly lowering the barrier to entry. However, sometimes a ready-made package might not be available or up-to-date. In such cases, you can try creating your own package and sharing it with others.

Due to the typically large size of AI project models, combined with GPU support, even when compressed into 7z format, the file size can far exceed 5GB, making uploading to cloud storage and general storage difficult. Therefore, I will no longer be creating portable packages. If you're interested, you can create your own package following this tutorial and share it with others.

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

  1. Download the Python 3.10 embed version (not the exe installer, but a zip archive).
  2. Install pip and set dependency lookup paths 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 and download the models.
  7. Execute a cloning task once to complete the download of Whisper and other models.
  8. Compress into a portable package.
  9. Creating Portable Packages for Other AI Projects

Preparations Before Starting:

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 to store the Python 3.10 embed version files downloaded later.

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

显示文件扩展名


1. Download the Python 3.10 embed version

Important Note: Here, we are downloading the embed version, not the exe installer. This version doesn't depend on your machine's Python environment, so even if you have Python installed, you still need to download this version.

  • Download Link: 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.

    下载Python embed版本

    Be sure to download this version; don't make a mistake!

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

    Python embed文件复制到runtime文件夹内


2. Install pip and Modify Package Lookup 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, saving the file to the runtime directory. After saving, the runtime folder should contain a file named get-pip.py.

      下载get-pip.pyget-pip.py文件runtime目录下的get-pip.py

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

      打开cmd,并确认路径是否在runtime内

    • Enter the command .\python get-pip.py in the terminal window and press Enter. Be sure to note whether the current folder address displayed by the command line is within the runtime folder; otherwise, it will cause an error.

      Wait for the installation to complete...

      pip安装中

      The pip module is installed successfully!

      pip 模块安装成功

  • Modify the python310._pth file:

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

      python310._pth文件内默认内容

    • On the line below the dot symbol . 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 check carefully to ensure it's correct:

      修改后的python310._pth文件内容应如下


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.

    下载F5-TTS源码

  • Extract the downloaded zip archive 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.

    复制F5-TTS-main内文件

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

    正确复制后的D:5win目录结构


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 confirm again that the path displayed by the current command line is D:\f5win (without runtime).

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

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

    安装依赖中

    Wait for the installation to complete...

所有依赖安装完成

  • If you want the portable 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 dot symbol; the command cannot be split into multiple lines):
    .\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. 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 script above means: Save the models in 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 no warning pops up, it means you made a mistake in modifying the extension. Please go back to the "Preparations Before Starting" section at the top of this article and select "File name extensions" as instructed.

    重命名为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 models are 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 up like this:

v2ray中设置为系统代理

After configuring it, double-click the run.bat file you just created.

  • If double-clicking directly opens the file with Notepad, it means you failed to modify the extension. Please return to the "Preparations Before Starting" section at the top of this article and select "File name extensions" as instructed.

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

    下载模型中

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

    下载模型错误:无法连接到huggingface.co

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

  • After the models are downloaded, the browser window will open automatically. 模型下载完毕,自动打开浏览器


7. Execute a Cloning Task Once to Download the Whisper Model

When performing voice cloning, if the corresponding text for the reference audio is not provided, F5-TTS will automatically download the Whisper model from Hugging Face. To pack everything completely, we need to download it in advance.

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

    Web界面

  • This will start downloading the Whisper model.

    下载Whisper模型中

  • 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. After they extract it, they can double-click run.bat (or Click Me to Start.bat) to use it.


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 not to 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 the project has a code directory named cfg, 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. Startup command of the run.bat script:

    • You only need to modify this line of code:
      "%~dp0runtime\python" -m f5_tts.infer.infer_gradio  --inbrowser
    • Keep the "%~dp0runtime\python" part unchanged, and change the part after it to the command that starts 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 imitate run.bat to give a new startup script. Remember to tell AI to use the Python interpreter in run.bat.