### Install System Dependencies Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/install.md Installs essential system dependencies for audio processing using apt. ```bash apt install portaudio19-dev libsox-dev ffmpeg ``` -------------------------------- ### Start Server with Docker Compose Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/server.md This command starts the API server profile using Docker Compose. Ensure Docker and Docker Compose are installed and configured. ```bash docker compose --profile server up ``` -------------------------------- ### Start WebUI with Docker Compose (CUDA) Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/install.md Use this command to start the WebUI with CUDA support. Ensure you have cloned the repository and are in the project directory. ```bash git clone https://github.com/fishaudio/fish-speech.git cd fish-speech docker compose --profile webui up ``` -------------------------------- ### Start API Server with Docker Compose (CUDA) Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/install.md Use this command to start the API server with CUDA support. Ensure you have cloned the repository and are in the project directory. ```bash docker compose --profile server up ``` -------------------------------- ### Example .env file for Docker Compose Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/install.md This example shows how to configure environment variables for Docker Compose deployments, including backend selection, compile optimization, and port settings. ```bash # .env file example BACKEND=cuda # or cpu COMPILE=1 # Enable compile optimization GRADIO_PORT=7860 # WebUI port API_PORT=8080 # API server port UV_VERSION=0.8.15 # UV package manager version CUDA_VER=12.9.0 # CUDA base image version (e.g. 12.6.0 for older drivers) UV_EXTRA=cu129 # PyTorch CUDA variant (cu126, cu128, cu129) — must match CUDA_VER ``` -------------------------------- ### Install PyTorch with Intel XPU Support Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/install.md Installs a nightly build of PyTorch with Intel XPU support for GPU acceleration. ```bash pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/xpu ``` -------------------------------- ### Install and Configure Fish-Audio S2 Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/index.md Instructions for setting up the Fish-Audio S2 system for use with LLM agents. Refer to the provided URL for detailed installation steps. ```text Install and configure Fish-Audio S2 by following the instructions here: https://speech.fish.audio/install/ ``` -------------------------------- ### Start Awesome WebUI Backend Server Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/inference.md Starts the API server for the Awesome WebUI. The `--compile` flag enables CUDA kernel fusion for faster inference. The server listens on `0.0.0.0:8888`. ```bash python tools/api_server.py --listen 0.0.0.0:8888 --compile ``` -------------------------------- ### Build Awesome WebUI Dependencies Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/inference.md Installs the necessary Node.js dependencies for the Awesome WebUI. Ensure Node.js and npm are installed. ```bash cd awesome_webui npm install ``` -------------------------------- ### Dataset Structure Example Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/finetune.md Organize your dataset with audio files and corresponding .lab annotation files under speaker-specific directories. ```bash . ├── SPK1 │ ├── 21.15-26.44.lab │ ├── 21.15-26.44.mp3 │ ├── 27.51-29.98.lab │ ├── 27.51-29.98.mp3 │ ├── 30.1-32.71.lab │ └── 30.1-32.71.mp3 └── SPK2 ├── 38.79-40.85.lab └── 38.79-40.85.mp3 ``` -------------------------------- ### Start API Server with Docker Compose (CUDA + Compile Optimization) Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/install.md Starts the API server with CUDA and enables compile optimization. Ensure the repository is cloned and you are in the project directory. ```bash COMPILE=1 docker compose --profile server up ``` -------------------------------- ### Start WebUI with Docker Compose (CPU-only) Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/install.md Starts the WebUI using only the CPU. This is suitable for deployments without a compatible GPU. Ensure the repository is cloned and you are in the project directory. ```bash BACKEND=cpu docker compose --profile webui up ``` -------------------------------- ### Troubleshoot PyAudio Installation with Conda Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/install.md Installs PyAudio using Conda if pip installation fails, then retries the Fish Speech installation. ```bash # conda install pyaudio # Then run pip install -e . again ``` -------------------------------- ### Start WebUI with Docker Compose (CUDA + Compile Optimization) Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/install.md Starts the WebUI with CUDA and enables compile optimization for potentially faster performance. Ensure the repository is cloned and you are in the project directory. ```bash COMPILE=1 docker compose --profile webui up ``` -------------------------------- ### Install Fish Speech with Conda (CPU) Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/install.md Installs Fish Speech with CPU-only support using pip. ```bash pip install -e .[cpu] ``` -------------------------------- ### Install Fish Speech with Conda (Default) Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/install.md Installs Fish Speech using the default PyTorch index. ```bash pip install -e . ``` -------------------------------- ### Start Local API Server Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/server.md Use this command to start the Fish Speech API server locally. Specify paths to your Llama and decoder checkpoints and the desired listen address. ```bash python tools/api_server.py \ --llama-checkpoint-path checkpoints/s2-pro \ --decoder-checkpoint-path checkpoints/s2-pro/codec.pth \ --listen 0.0.0.0:8080 ``` -------------------------------- ### Start WebUI with Docker Compose (ROCm) Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/install.md Starts the WebUI using Docker Compose with ROCm support for AMD GPUs. This requires ROCm drivers and Docker with GPU passthrough configured. ```bash docker compose -f compose.rocm.yml --profile webui up --build ``` -------------------------------- ### Install C++ Standard Library for Intel Arc XPU Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/install.md Installs the required C++ standard library from conda-forge for Intel Arc XPU support. ```bash conda install libstdcxx -c conda-forge ``` -------------------------------- ### Install Fish Speech with UV (CPU) Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/install.md Synchronizes dependencies using UV for Fish Speech with CPU-only support. ```bash uv sync --python 3.12 --extra cpu ``` -------------------------------- ### Start API Server with Docker Compose (ROCm) Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/install.md Starts the API server using Docker Compose with ROCm support for AMD GPUs. This requires ROCm drivers and Docker with GPU passthrough configured. ```bash docker compose -f compose.rocm.yml --profile server up --build ``` -------------------------------- ### Conda Environment Setup Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/install.md Creates and activates a Conda environment for Fish Speech with Python 3.12. ```bash conda create -n fish-speech python=3.12 conda activate fish-speech ``` -------------------------------- ### Install Fish Speech with Conda (GPU) Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/install.md Installs Fish Speech with GPU support using pip, specifying a CUDA version (e.g., cu129). ```bash pip install -e .[cu129] ``` -------------------------------- ### Install Fish Speech with UV (GPU) Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/install.md Synchronizes dependencies using UV for Fish Speech with GPU support, specifying a CUDA version (e.g., cu129). ```bash uv sync --python 3.12 --extra cu129 ``` -------------------------------- ### Download Model Weights Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/inference.md Use this command to download the required model weights for the Fish Audio S2 model. Ensure you have `hf` installed. ```bash hf download fishaudio/s2-pro --local-dir checkpoints/s2-pro ``` -------------------------------- ### Python Client for Text-to-Speech Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/server.md Example of using the Python client to perform text-to-speech generation via the API server. This command uses the default model loaded on the server. ```bash python tools/api_client.py \ --url http://127.0.0.1:8080/v1/tts \ --text "Hello from Fish Speech" \ --output s2-pro-demo ``` -------------------------------- ### Get VQ Tokens from Reference Audio Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/inference.md This script extracts VQ tokens from a reference audio file, which are necessary for subsequent text-to-semantic token generation. It outputs `fake.npy` and `fake.wav`. ```python python fish_speech/models/dac/inference.py \ -i "test.wav" \ --checkpoint-path "checkpoints/s2-pro/codec.pth" ``` -------------------------------- ### Pack Dataset into Protobuf Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/finetune.md Pack your prepared dataset into protobuf format using the build_dataset.py script. This is a necessary step before fine-tuning. ```bash python tools/llama/build_dataset.py \ --input "data" \ --output "data/protos" \ --text-extension .lab \ --num-workers 16 ``` -------------------------------- ### Build Awesome WebUI Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/inference.md Compiles the frontend assets for the Awesome WebUI. ```bash npm run build ``` -------------------------------- ### Run Gradio WebUI Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/inference.md Launches the Gradio-based Web User Interface for inference. The `--compile` flag can be added for acceleration. ```bash python tools/run_webui.py # --compile if you need acceleration ``` -------------------------------- ### Download VQGAN Weights Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/finetune.md Download the necessary VQGAN weights before extracting semantic tokens. Ensure the path is correctly specified. ```bash huggingface-cli download fishaudio/openaudio-s1-mini --local-dir checkpoints/openaudio-s1-mini ``` -------------------------------- ### Fine-tuning LLAMA with LoRA Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/finetune.md Initiate the fine-tuning process for the LLAMA model using LoRA. Ensure LLAMA weights are downloaded and specify the LoRA configuration. ```bash python fish_speech/train.py --config-name text2semantic_finetune \ project=$project \ +lora@model.model.lora_config=r_8_alpha_16 ``` -------------------------------- ### Run WebUI Inference Source: https://github.com/fishaudio/fish-speech/blob/main/inference.ipynb Launch the WebUI for inference. Use the '--compile' flag to fuse CUDA kernels for significantly faster inference. ```python !python tools/run_webui.py \ --llama-checkpoint-path checkpoints/openaudio-s1-mini \ --decoder-checkpoint-path checkpoints/openaudio-s1-mini/codec.pth \ # --compile ``` -------------------------------- ### Build CPU-only Docker Images (Multi-platform) Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/install.md Builds CPU-only Docker images for both WebUI and API server, supporting multiple platforms like amd64 and arm64. This is for deployments without GPU acceleration. ```bash docker build \ --platform linux/amd64,linux/arm64 \ -f docker/Dockerfile \ --build-arg BACKEND=cpu \ --target webui \ -t fish-speech-webui:cpu . ``` -------------------------------- ### Run WebUI Container (ROCm) Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/install.md Runs a manually built WebUI container with ROCm support. This command includes necessary device mappings and environment variables for AMD GPU acceleration. ```bash docker run \ --device=/dev/kfd --device=/dev/dri \ --group-add video --group-add render \ -e ROCBLAS_USE_HIPBLASLT=0 \ -v ./checkpoints:/app/checkpoints \ -p 7860:7860 \ fish-speech-webui:rocm ``` -------------------------------- ### Build WebUI Docker Image (CUDA) Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/install.md Manually builds the Docker image for the WebUI with CUDA support. This command is for advanced users who need to customize the build process. ```bash docker build \ --platform linux/amd64 \ -f docker/Dockerfile \ --build-arg BACKEND=cuda \ --build-arg CUDA_VER=12.9.0 \ --build-arg UV_EXTRA=cu129 \ --target webui \ -t fish-speech-webui:cuda . ``` -------------------------------- ### Build API Server Docker Image (CUDA) Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/install.md Manually builds the Docker image for the API server with CUDA support. This command is for advanced users who need to customize the build process. ```bash docker build \ --platform linux/amd64 \ -f docker/Dockerfile \ --build-arg BACKEND=cuda \ --build-arg CUDA_VER=12.9.0 \ --build-arg UV_EXTRA=cu129 \ --target server \ -t fish-speech-server:cuda . ``` -------------------------------- ### Python Client with Reference Voice Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/server.md Use this command to perform text-to-speech generation with a specific reference voice ID. This selects the voice, not the base TTS model. ```bash python tools/api_client.py \ --url http://127.0.0.1:8080/v1/tts \ --text "Hello from Fish Speech" \ --reference_id my-speaker \ --output s2-pro-demo ``` -------------------------------- ### Download Fish-Speech Model Source: https://github.com/fishaudio/fish-speech/blob/main/inference.ipynb Download the specified Fish-Speech model using the 'hf download' command. Consider using a mirror for faster downloads if needed. ```python # For Chinese users, you probably want to use mirror to accelerate downloading # !set HF_ENDPOINT=https://hf-mirror.com # !export HF_ENDPOINT=https://hf-mirror.com !hf download fishaudio/openaudio-s1-mini --local-dir checkpoints/openaudio-s1-mini/ ``` -------------------------------- ### Encode Reference Audio to Prompt Source: https://github.com/fishaudio/fish-speech/blob/main/inference.ipynb Encode a reference audio file into a prompt file (fake.npy). This step is necessary for generating speech from text later. The output audio is saved as fake.wav. ```python ## Enter the path to the audio file here src_audio = r"D:\PythonProject\vo_hutao_draw_appear.wav" !python fish_speech/models/dac/inference.py \ -i {src_audio} \ --checkpoint-path "checkpoints/openaudio-s1-mini/codec.pth" ``` ```python from IPython.display import Audio, display audio = Audio(filename="fake.wav") display(audio) ``` -------------------------------- ### Build Development Docker Image (CUDA) Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/install.md Builds a development-focused Docker image with CUDA support. This image is suitable for local development and debugging purposes. ```bash docker build \ --platform linux/amd64 \ -f docker/Dockerfile \ --build-arg BACKEND=cuda \ --target dev \ -t fish-speech-dev:cuda . ``` -------------------------------- ### Loudness Normalization Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/finetune.md Apply loudness normalization to your dataset using the fish-audio-preprocess tool. This step is recommended for better audio quality. ```bash fap loudness-norm data-raw data --clean ``` -------------------------------- ### Build WebUI Docker Image (ROCm) Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/install.md Manually builds the Docker image for the WebUI with ROCm support for AMD GPUs. This command is used for advanced customization of the ROCm environment. ```bash docker build -f docker/Dockerfile.rocm --target webui -t fish-speech-webui:rocm . ``` -------------------------------- ### Generate Semantic Tokens from Text Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/inference.md Converts input text into semantic tokens using a reference text and its corresponding VQ tokens. The `--compile` flag can be used for faster inference, and `--half` is for GPUs that do not support bf16. ```python python fish_speech/models/text2semantic/inference.py \ --text "The text you want to convert" \ --prompt-text "Your reference text" \ --prompt-tokens "fake.npy" \ # --compile ``` -------------------------------- ### Generate Vocals from Semantic Tokens Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/inference.md This script generates the final vocal audio file (`fake.wav`) from the previously generated semantic tokens. ```python python fish_speech/models/dac/inference.py \ -i "codes_0.npy" \ ``` -------------------------------- ### Enable React-Specific ESLint Rules Source: https://github.com/fishaudio/fish-speech/blob/main/awesome_webui/README.md Integrate 'eslint-plugin-react-x' and 'eslint-plugin-react-dom' for React and React DOM specific linting. Project configuration is similar to type-aware rules. ```javascript // eslint.config.js import reactX from 'eslint-plugin-react-x' import reactDom from 'eslint-plugin-react-dom' export default defineConfig([ globalIgnores(['dist']), { files: ['**/*.{ts,tsx}'], extends: [ // Other configs... // Enable lint rules for React reactX.configs['recommended-typescript'], // Enable lint rules for React DOM reactDom.configs.recommended, ], languageOptions: { parserOptions: { project: ['./tsconfig.node.json', './tsconfig.app.json'], tsconfigRootDir: import.meta.dirname, }, // other options... }, }, ]) ``` -------------------------------- ### Generate Semantic Tokens from Text Source: https://github.com/fishaudio/fish-speech/blob/main/inference.ipynb Generate semantic tokens from input text, using a reference audio prompt. This command creates a 'codes_N.npy' file. Using '--compile' can increase inference speed. ```python !python fish_speech/models/text2semantic/inference.py \ --text "hello world" \ --prompt-text "The text corresponding to reference audio" \ --prompt-tokens "fake.npy" \ --checkpoint-path "checkpoints/openaudio-s1-mini" \ --num-samples 2 # --compile ``` -------------------------------- ### Batch Extraction of Semantic Tokens Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/finetune.md Extract semantic tokens from your dataset using the provided Python script. Adjust `--num-workers` and `--batch-size` based on your GPU memory. ```bash python tools/vqgan/extract_vq.py data \ --num-workers 1 --batch-size 16 \ --config-name "modded_dac_vq" \ --checkpoint-path "checkpoints/openaudio-s1-mini/codec.pth" ``` -------------------------------- ### Dataset Structure After Token Extraction Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/finetune.md After token extraction, .npy files containing semantic tokens will be added to your data directory. ```bash . ├── SPK1 │ ├── 21.15-26.44.lab │ ├── 21.15-26.44.mp3 │ ├── 21.15-26.44.npy │ ├── 27.51-29.98.lab │ ├── 27.51-29.98.mp3 │ ├── 27.51-29.98.npy │ ├── 30.1-32.71.lab │ ├── 30.1-32.71.mp3 │ └── 30.1-32.71.npy └── SPK2 ├── 38.79-40.85.lab ├── 38.79-40.85.mp3 └── 38.79-40.85.npy ``` -------------------------------- ### Enable Type-Aware ESLint Rules Source: https://github.com/fishaudio/fish-speech/blob/main/awesome_webui/README.md Configure ESLint to use type-aware lint rules for TypeScript files. Ensure 'tsconfig.node.json' and 'tsconfig.app.json' are correctly specified. ```javascript export default defineConfig([ globalIgnores(['dist']), { files: ['**/*.{ts,tsx}'], extends: [ // Other configs... // Remove tseslint.configs.recommended and replace with this tseslint.configs.recommendedTypeChecked, // Alternatively, use this for stricter rules tseslint.configs.strictTypeChecked, // Optionally, add this for stylistic rules tseslint.configs.stylisticTypeChecked, // Other configs... ], languageOptions: { parserOptions: { project: ['./tsconfig.node.json', './tsconfig.app.json'], tsconfigRootDir: import.meta.dirname, }, // other options... }, }, ]) ``` -------------------------------- ### Generate Speech from Semantic Tokens Source: https://github.com/fishaudio/fish-speech/blob/main/inference.ipynb Synthesize speech from the generated semantic tokens (codes_N.npy). The output speech is saved as fake.wav. ```python !python fish_speech/models/dac/inference.py \ -i "codes_0.npy" \ --checkpoint-path "checkpoints/openaudio-s1-mini/codec.pth" ``` ```python from IPython.display import Audio, display audio = Audio(filename="fake.wav") display(audio) ``` -------------------------------- ### Set Linux Locale for UTF-8 Source: https://github.com/fishaudio/fish-speech/blob/main/inference.ipynb For Linux users, set the locale to 'en_US.UTF-8' to handle character encoding correctly. ```python import locale locale.setlocale(locale.LC_ALL, 'en_US.UTF-8') ``` -------------------------------- ### API Server Health Check Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/server.md Perform a health check on the running API server to ensure it is operational. The expected response indicates the server is ready. ```bash curl -X GET http://127.0.0.1:8080/v1/health ``` -------------------------------- ### Set Windows Console Code Page Source: https://github.com/fishaudio/fish-speech/blob/main/inference.ipynb For Windows users, set the console code page to UTF-8 to ensure proper character display. ```python !chcp 65001 ``` -------------------------------- ### Merge LoRA Weights Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/finetune.md After fine-tuning, merge the LoRA weights with the base model weights to create a consolidated model for inference. Specify the correct paths for base and LoRA weights. ```bash python tools/llama/merge_lora.py \ --lora-config r_8_alpha_16 \ --base-weight checkpoints/openaudio-s1-mini \ --lora-weight results/$project/checkpoints/step_000000010.ckpt \ --output checkpoints/openaudio-s1-mini-yth-lora/ ``` -------------------------------- ### VQ Encode Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/server.md Encodes input data into a VQ representation. ```APIDOC ## VQ Encode ### Description Encodes input data into a VQ representation. ### Method POST ### Endpoint /v1/vqgan/encode ``` -------------------------------- ### Text-to-Speech Generation Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/server.md Generates speech from input text using the configured TTS model. ```APIDOC ## Text-to-Speech Generation ### Description Generates speech from input text using the configured TTS model. ### Method POST ### Endpoint /v1/tts ### Request Body - **text** (string) - Required - The text to convert to speech. - **reference_id** (string) - Optional - The ID of a saved voice reference to use for style transfer. ``` -------------------------------- ### VQ Decode Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/server.md Decodes a VQ representation back into its original data format. ```APIDOC ## VQ Decode ### Description Decodes a VQ representation back into its original data format. ### Method POST ### Endpoint /v1/vqgan/decode ``` -------------------------------- ### Health Check Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/server.md Checks the status of the running API server. ```APIDOC ## Health Check ### Description Checks the status of the running API server. ### Method GET ### Endpoint /v1/health ### Response #### Success Response (200) - **status** (string) - Indicates the server status, typically "ok". ``` -------------------------------- ### API Server Health Check Response Source: https://github.com/fishaudio/fish-speech/blob/main/docs/en/server.md The expected JSON response for a successful health check of the API server. ```json {"status":"ok"} ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.