Chuyển đến nội dung

Cài đặt OmniVoice bằng Conda

Giới thiệu

OmniVoice là một mô hình chuyển văn bản thành giọng nói (TTS) đa ngôn ngữ tiên tiến, hỗ trợ hơn 600 ngôn ngữ. Được xây dựng trên kiến ​​trúc kiểu mô hình ngôn ngữ khuếch tán mới lạ, nó tạo ra giọng nói chất lượng cao với tốc độ suy luận vượt trội, hỗ trợ sao chép giọng nói và thiết kế giọng nói.

GitHub: https://github.com/k2-fsa/OmniVoice
Hugging Face: https://hf.co/k2-fsa/OmniVoice
Paper: https://arxiv.org/abs/2604.00688
Demo: https://hf.co/spaces/k2-fsa/OmniVoice
Audio Samples: Đang cập nhật

Yêu cầu hệ thống

  • Hệ điều hành: Windows 10/11 (64-bit), macOS hoặc Linux (Debian/Ubuntu).
  • Python: Yêu cầu phiên bản >= 3.10
  • Dung lượng ổ cứng: Khuyến nghị 10GB trở lên (cho các thư viện phụ thuộc và bộ nhớ cache mô hình). Ít nhất 400 MB cho Miniconda; 3 GB trở lên cho Anaconda đầy đủ.
  • GPU: là tùy chọn nhưng RẤT KHUYÊN DÙNG để tăng hiệu suất
  • Internet: Để tải xuống các thư viện phụ thuộc và mô hình từ Hugging Face Hub.
Mức yêu cầu CPU RAM
Tối thiểu Intel Core i3 hoặc AMD Ryzen 3 8 GB
Khuyến nghị Intel Core i5 hoặc AMD Ryzen 5 16 GB
Hiệu năng cao Intel Core i7/i9 hoặc AMD Ryzen 7/9 32 GB
Môi trường Chạy lệnh để cài đặt Kiến trúc
CPU only pip3 install torch torchvision IA-32 and Intel 64
Apple Silicon pip3 install torch torchvision
AMD ROCm Install PyTorch for ROCm
CUDA 11.8 pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 Kepler/Maxwell → Ada Lovelace, Hopper
CUDA 12.1 pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 Kepler/Maxwell → Ada Lovelace, Hopper
CUDA 12.4 pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124 Kepler/Maxwell → Ada Lovelace, Hopper
CUDA 12.6 pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126 Maxwell → Hopper
CUDA 12.8 pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu128 Volta → Blackwell
CUDA 12.9 pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu129 Volta → Blackwell
CUDA 13.0 pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu130 Turing → Blackwell
CUDA 13.2 pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu132 Turing → Blackwell
CUDA 13.4 pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu134 Turing → Blackwell

Các phiên bản PyTorch khả dụng:

pip index versions torch
pip index versions torchaudio
pip index versions torchvision
pip index versions torch --index-url https://download.pytorch.org/whl/cu118
pip index versions torchaudio --index-url https://download.pytorch.org/whl/cu118
pip index versions torchvision --index-url https://download.pytorch.org/whl/cu118
Môi trường 2.15.0 2.14.1 2.14.0 2.13.0 2.12.1 2.12.0 2.11.0 2.10.0 2.9.1 2.9.0 2.8.0 2.7.1 2.7.0 2.6.0 2.5.1 2.5.0 2.4.1 2.4.0 2.3.1 2.3.0 2.2.2 2.2.1 2.2.0 2.1.2 2.1.1 2.1.0 2.0.1 2.0.0 1.13.1 1.13.0 1.12.1 1.12.0 1.11.0
cpu ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
cu118 ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
cu121 ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
cu124 ✅ ✅ ✅ ✅ ✅
cu126 ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
cu128 ✅ ✅ ✅ ✅ ✅ ✅ ✅
cu129 ✅ ✅
cu130 ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
cu132 ✅ ✅ ✅ ✅ ✅ ✅
cu134 ✅

Video hướng dẫn

Bước 1. Cài đặt Miniconda

Bước 2. Tạo môi trường Conda

Tạo tệp environment.yml:

name: omnivoice
channels:
- pytorch
- conda-forge
- defaults
dependencies:
# Python version >= 3.10 required
- python=3.10
# Install FFmpeg for pydub audio library
- ffmpeg
- pip
- pip:
    # PyTorch CPU only
    - torch
    - torchaudio

    # OmniVoice-TTS
    - omnivoice

Kích hoạt môi trường conda:

conda env create -f environment.yml
conda activate omnivoice

Có thể được bỏ qua nếu bạn chỉ làm việc với các tệp âm thanh định dạng WAV, vì Pydub hỗ trợ đọc và ghi tệp WAV mà không cần đến FFmpeg. Tuy nhiên, FFmpeg là bắt buộc nếu bạn muốn xử lý các định dạng âm thanh khác như MP3, OGG, FLAC, hoặc thực hiện chuyển đổi định dạng âm thanh.

Bước 3. Tạo một tệp Python

Tạo một tệp có tên omnivoice_tts_test.py:

from omnivoice import OmniVoice
import soundfile as sf
import torch

model = OmniVoice.from_pretrained(
    "k2-fsa/OmniVoice",
    device_map="cuda:0",
    dtype=torch.float16
)
# Apple Silicon users: use device_map="mps" instead
# Intel Arc GPU users: use device_map="xpu" instead

audio = model.generate(
    text="Hello, this is a test of zero-shot voice cloning.",
    # ref_audio="ref.wav",
    # ref_text="Transcription of the reference audio.",
    instruct="female, young adult, high pitch, british accent",
) # audio is a list of `np.ndarray` with shape (T,) at 24 kHz.

# If you don't want to input `ref_text` manually, you can directly omit the `ref_text`.
# The model will use Whisper ASR to auto-transcribe it.

sf.write("out.wav", audio[0], 24000)

Chạy thử:

python omnivoice_tts_test.py

Kết quả sẽ là tệp âm thanh out.wav

Khởi chạy Giao diện Web (Gradio Web UI)

Sau khi cài đặt xong, bạn không cần viết code mà có thể bật ngay một giao diện Web UI cục bộ bằng lệnh:

omnivoice-demo --ip 127.0.0.1 --port 8001

Mở trình duyệt và truy cập vào địa chỉ http://127.0.0.1:8001 để bắt đầu sử dụng. Hệ thống sẽ tự động tải các file Model (Trọng số cấu hình mã nguồn) từ HuggingFace trong lần đầu chạy.