文章目录
- 一、关于 Fish Speech
- 架构
- Fish Speech V1.1 技术介绍[视频]
 
- 二、配置
- 1、Linux 配置
- 2、Docker 配置
 
- 三、快速开始
- 1、设置
- For Windows User / win用户
- For Linux User / Linux 用户
 
- 2、准备模型
- 3、WebUI Inference
 
- 四、Break-down CLI Inference
- 1、从语音生成 prompt:
- 2、从文本生成语义 token:
- 3、从语义 token 生成人声:
 
 
一、关于 Fish Speech
Fish Speech : Brand new TTS solution
- github : https://github.com/fishaudio/fish-speech (240916 10.7k)
- Fish Audio demo : https://fish.audio/
- 快速开始 : https://github.com/fishaudio/fish-speech/blob/main/inference.ipynb
- 官方文档:https://speech.fish.audio/zh/
- 示例:https://speech.fish.audio/zh/samples/
- 视频介绍(bilibili):
 https://www.bilibili.com/video/BV1pu46eVEk7
 https://www.bilibili.com/video/BV1wz421B71D
 https://www.bilibili.com/video/BV1zJ4m1K7cj
架构

Fish Speech V1.1 技术介绍[视频]
Fish Speech V1.1 技术介绍
二、配置
1、Linux 配置
# 创建一个 python 3.10 虚拟环境, 你也可以用 virtualenv
conda create -n fish-speech python=3.10
conda activate fish-speech
# 安装 pytorch
pip3 install torch torchvision torchaudio
# 安装 fish-speech
pip3 install -e .[stable]
# (Ubuntu / Debian 用户) 安装 sox + ffmpeg
apt install libsox-dev ffmpeg
2、Docker 配置
1)安装 NVIDIA Container Toolkit:
Docker 如果想使用 GPU 进行模型训练和推理,需要安装 NVIDIA Container Toolkit :
对于 Ubuntu 用户:
# 添加远程仓库
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
    && curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
        sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
        sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
# 安装 nvidia-container-toolkit
sudo apt-get update
sudo apt-get install -y nvidia-container-toolkit
# 重启 Docker 服务
sudo systemctl restart docker
对于使用其他 Linux 发行版的用户,安装指南请参考:NVIDIA Container Toolkit Install-guide。
注:对于中国大陆的用户,您可能需要使用代理来完成相关工具的安装。
2)拉取并运行 fish-speech 镜像
# 拉取镜像
docker pull fishaudio/fish-speech:latest-dev
# 运行镜像
docker run -it \
    --name fish-speech \
    --gpus all \
    -p 7860:7860 \
    fishaudio/fish-speech:latest-dev \
    zsh
# 如果需要使用其他端口,请修改 -p 参数为 YourPort:7860
3)下载模型依赖
确保您在 docker 容器内的终端,然后再从我们的 huggingface 仓库下载所需的 vqgan 和 llama 模型。
huggingface-cli download fishaudio/fish-speech-1.4 --local-dir checkpoints/fish-speech-1.4
对于中国大陆用户,可以通过镜像站下载。
HF_ENDPOINT=https://hf-mirror.com huggingface-cli download fishaudio/fish-speech-1.4 --local-dir checkpoints/fish-speech-1.4
4)配置环境变量,访问 WebUI
在 docker 容器内的终端,输入 export GRADIO_SERVER_NAME="0.0.0.0" ,从而让外部可以访问 docker 内的 gradio 服务。 接着在 docker 容器内的终端,输入 python tools/webui.py 即可开启 WebUI 服务。
如果是 WSL 或者是 MacOS ,访问 http://localhost:7860 即可打开 WebUI 界面。
如果是部署在服务器上,更换 localhost 为您的服务器 ip 即可。
三、快速开始
1、设置
For Windows User / win用户
!chcp 65001
For Linux User / Linux 用户
import locale
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
2、准备模型
# 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 
!huggingface-cli download fishaudio/fish-speech-1.4 --local-dir checkpoints/fish-speech-1.4/
3、WebUI Inference
You can use --compile to fuse CUDA kernels for faster inference (10x).
!python tools/webui.py \
    --llama-checkpoint-path checkpoints/fish-speech-1.4 \
    --decoder-checkpoint-path checkpoints/fish-speech-1.4/firefly-gan-vq-fsq-8x1024-21hz-generator.pth \
    # --compile
四、Break-down CLI Inference
1、从语音生成 prompt:
你应该能得到一个 fake.npy 文件.
## Enter the path to the audio file here
src_audio = r"D:\PythonProject\vo_hutao_draw_appear.wav"
!python tools/vqgan/inference.py \
    -i {src_audio} \
    --checkpoint-path "checkpoints/fish-speech-1.4/firefly-gan-vq-fsq-8x1024-21hz-generator.pth"
from IPython.display import Audio, display
audio = Audio(filename="fake.wav")
display(audio)
2、从文本生成语义 token:
该命令会在工作目录下创建 codes_N 文件, 其中 N 是从 0 开始的整数.
您可以使用 --compile 来融合 cuda 内核以实现更快的推理 (~30 tokens/秒 -> ~300 tokens/秒)
!python tools/llama/generate.py \
    --text "hello world" \
    --prompt-text "The text corresponding to reference audio" \
    --prompt-tokens "fake.npy" \
    --checkpoint-path "checkpoints/fish-speech-1.4" \
    --num-samples 2
    # --compile
3、从语义 token 生成人声:
!python tools/vqgan/inference.py \
    -i "codes_0.npy" \
    --checkpoint-path "checkpoints/fish-speech-1.4/firefly-gan-vq-fsq-8x1024-21hz-generator.pth"
from IPython.display import Audio, display
audio = Audio(filename="fake.wav")
display(audio)
2024-09-16(一)




![[OpenCV] 数字图像处理 C++ 学习——15像素重映射(cv::remap) 附完整代码](https://i-blog.csdnimg.cn/direct/aa2b3cc23b664f7895e885093ca63491.png)














