
เซิร์ฟเวอร์การอนุมานแบบข้อความที่รวดเร็วและรวดเร็วสำหรับการพูดปลา 1.5 และต่ำกว่าเขียนด้วยสนิมบริสุทธิ์
คุณสมบัติ:
torch.compile ได้: รวบรวมเป็น binary ~ 15MB แบบคง บันทึก
ใช่การรวบรวมจากแหล่งที่มาไม่ใช่เรื่องสนุก ภาพนักเทียบท่าอย่างเป็นทางการ, Homebrew, Linux Packaging และ Python Interop Layer อยู่บนแผนงาน
หากคุณต้องการรองรับแพลตฟอร์มของคุณโปรดอย่าลังเลที่จะยกปัญหาและฉันจะได้รับมัน!
ก่อนอื่นให้โคลน repo นี้ไปยังโฟลเดอร์ที่คุณต้องการ:
git clone https://github.com/EndlessReform/fish-speech.rs.git
cd fish-speech.rs บันทึกจุดตรวจพูดของปลาไปที่ ./checkpoints CheckPoints ฉันแนะนำให้ใช้ huggingface-cli :
# If it's not already on system
brew install huggingface-cli
# For Windows or Linux (assumes working Python):
# pip install -U "huggingface_hub[cli]"
# or just skip this and download the folder manually
mkdir -p checkpoints/fish-speech-1.5
# NOTE: the official weights are not compatible
huggingface-cli download jkeisling/fish-speech-1.5 --local-dir checkpoints/fish-speech-1.5หากคุณใช้รุ่นปลารุ่นเก่า:
jkeisling/fish-speech-1.4 : น้ำหนักอย่างเป็นทางการไม่เข้ากันได้ตอนนี้รวบรวมจากแหล่งที่มา สำหรับการสนับสนุน Apple Silicon GPU:
cargo build --release --bin server --features metalสำหรับ Nvidia:
cargo build --release --bin server --features cudaสำหรับประสิทธิภาพพิเศษบน Nvidia คุณสามารถเปิดใช้งานความสนใจของแฟลช หากคุณกำลังรวบรวมเป็นครั้งแรกหรือหลังการอัปเดตที่สำคัญอาจใช้เวลาสักครู่: มากถึง 15 นาทีและ 16GB ของ RAM ใน CPU ที่ดี คุณได้รับคำเตือนแล้ว!
mkdir ~ /.candle
CANDLE_FLASH_ATTN_BUILD_DIR= $HOME /.candle cargo build --release --features flash-attn --bin server สิ่งนี้จะรวบรวมไบนารีของคุณถึง ./target/release/server /Server
เพียงแค่เริ่มต้นไบนารี! หากคุณเริ่มต้นใช้งานเป็นครั้งแรก RUN:
# Default voice to get you started
./target/release/server --voice-dir voices-templateตัวเลือก:
--port : ค่าเริ่มต้นเป็น 3000--checkpoint : ไดเรกทอรีสำหรับโฟลเดอร์จุดตรวจสอบ ค่าเริ่มต้นไปยัง checkpoints/fish-speech-1.5--voice-dir : ไดเรกทอรีสำหรับการแจ้งเตือนลำโพง (เพิ่มเติมเกี่ยวกับด้านล่างนี้)--fish-version : 1.5 , 1.4 หรือ 1.2 ค่าเริ่มต้นเป็น 1.5--temp : อุณหภูมิสำหรับกระดูกสันหลังแบบจำลองภาษา ค่าเริ่มต้น: 0.7--top_p : การสุ่มตัวอย่างด้านบน P สำหรับแบ็คโบนโมเดลภาษา ค่าเริ่มต้น 0.8 เพื่อปิดการตั้งค่าเป็น 1เซิร์ฟเวอร์นี้รองรับ OGG Audio (สตรีมมิ่ง) และเอาต์พุตเสียง WAV
คุณสามารถใช้ไคลเอนต์ที่เข้ากันได้กับ OpenAI นี่คือตัวอย่างคำขอ Python:
from openai import OpenAI
client = OpenAI (
base_url = "http://localhost:3000/v1"
)
audio = client . audio . speech . create (
input = "Hello world!" ,
voice = "default" ,
response_format = "wav" ,
model = "tts-1" ,
)
temp_file = "temp.wav"
audio . stream_to_file ( temp_file ) ในการโคลนเสียงคุณจะต้องมีไฟล์ WAV และการถอดความ สมมติว่าคุณต้องการเพิ่มลำโพง alice ที่พูดว่า "สวัสดีโลก" ในไฟล์ fake.wav
ส่งคำขอโพสต์ไปยังจุดสิ้นสุด /v1/audio/encoding ด้วย:
id และ prompt เป็นพารามิเตอร์การสืบค้น URL ที่เข้ารหัสตัวอย่างด้วย Curl:
curl -X POST " http://localhost:3000/v1/audio/encoding?id=alice&prompt=Hello%20world "
-F " [email protected] "
--output alice.npy คุณสามารถตรวจสอบได้ว่าเสียงของคุณถูกเพิ่มโดยการกดจุดดีบัก /v1/voices ดีบั๊ก:
curl http://localhost:3000/v1/voices
# Returns ['default', 'alice'] สิ่งนี้จะส่งคืนไฟล์. NPY ด้วยเสียงอินพุตของคุณเป็นโทเค็นที่เข้ารหัส หลังจากนี้เสียง alice จะใช้งานได้ ตราบใดที่เซิร์ฟเวอร์กำลังทำงานอยู่ และจะถูกลบเมื่อปิดเครื่อง
หากคุณต้องการบันทึกเสียงนี้คุณสามารถใช้ไฟล์ .npy ที่ส่งคืนเพื่อเพิ่มลงในเสียงเมื่อเริ่มต้น: ดูด้านล่าง
บันทึก
ใช่สิ่งนี้แย่มาก เสียงที่เข้ารหัสยังคงอยู่ในดิสก์เป็นสิ่งสำคัญที่สุด
เปิดไฟล์ voices-template/index.json ควรมีลักษณะเหมือน:
{
"speakers" : {
"default" : " When I heard the release demo, I was shocked, angered, and in disbelief that Mr. Altman would pursue a voice that sounded so eerily similar to mine that my closest friends and news outlets could not tell the difference. "
}
}ไดเรกทอรีเสียงประกอบด้วย:
default.npy ) ใช้ไฟล์ .npy ที่คุณได้รับจากการเข้ารหัสรันไทม์และเปลี่ยนชื่อเป็นรหัสลำโพงของคุณ: อดีต หาก ID คือ "Alice" ให้เปลี่ยนชื่อเป็น alice.npy จากนั้นย้าย alice.npy ไปยังโฟลเดอร์ Voices ของคุณ ใน index.json เพิ่มคีย์:
{
"speakers" : {
"default" : " When I heard the release demo, I was shocked, angered, and in disbelief that Mr. Altman would pursue a voice that sounded so eerily similar to mine that my closest friends and news outlets could not tell the difference. "
"alice" : " I–I hardly know, sir, just at present–at least I know who I WAS when I got up this morning, but I think I must have been changed several times since then. "
}
}รีสตาร์ทเซิร์ฟเวอร์และเสียงใหม่ของคุณควรจะไปได้ดี
สำหรับตอนนี้เรายังคงความเข้ากันได้กับการอนุมานการพูดของปลาอย่างเป็นทางการ (การอนุมานเซิร์ฟเวอร์และการผูก Python เร็ว ๆ นี้!)
# saves to fake.npy by default
cargo run --release --features metal --bin encoder -- -i ./tests/resources/sky.wavสำหรับเวอร์ชันก่อนหน้าคุณจะต้องระบุเวอร์ชันและจุดตรวจด้วยตนเอง:
cargo run --release --bin encoder -- --input ./tests/resources/sky.wav --output-path fake.npy --fish-version 1.2 --checkpoint ./checkpoints/fish-speech-1.2-sftสำหรับปลา 1.5 (ค่าเริ่มต้น):
# Switch to --features cuda for Nvidia GPUs
cargo run --release --features metal --bin llama_generate --
--text " That is not dead which can eternal lie, and with strange aeons even death may die. "
--prompt-text " When I heard the release demo, I was shocked, angered, and in disbelief that Mr. Altman would pursue a voice that sounded so eerily similar to mine that my closest friends and news outlets could not tell the difference. "
--prompt-tokens fake.npyสำหรับเวอร์ชันก่อนหน้าคุณจะต้องระบุเวอร์ชันและจุดตรวจสอบอย่างชัดเจน ตัวอย่างเช่นปลา 1.2:
cargo run --release --features metal --bin llama_generate -- --text " That is not dead which can eternal lie, and with strange aeons even death may die. " --fish-version 1.2 --checkpoint ./checkpoints/fish-speech-1.2-sftสำหรับความเร็วเพิ่มเติมให้รวบรวมด้วยการสนับสนุน Flash Attention
คำเตือน
การพึ่งพาการพึ่งพาเทียน-แฟลชอาจใช้เวลามากกว่า 10 นาทีในการรวบรวมแม้ในซีพียูที่ดีและอาจต้องใช้หน่วยความจำมากกว่า 16 GB! คุณได้รับคำเตือนแล้ว
นอกจากนี้ในเดือนตุลาคม 2567 คอขวดเป็นที่อื่น (ในสำเนาหน่วยความจำที่ไม่มีประสิทธิภาพและการส่งเคอร์เนล) ดังนั้นในฮาร์ดแวร์ที่รวดเร็วแล้ว (เช่น RTX 4090) ปัจจุบันมีผลกระทบน้อยกว่า
# Cache the Flash Attention build
# Leave your computer, have a cup of tea, go touch grass, etc.
mkdir ~ /.candle
CANDLE_FLASH_ATTN_BUILD_DIR= $HOME /.candle cargo build --release --features flash-attn --bin llama_generate
# Then run with flash-attn flag
cargo run --release --features flash-attn --bin llama_generate --
--text " That is not dead which can eternal lie, and with strange aeons even death may die. "
--prompt-text " When I heard the release demo, I was shocked, angered, and in disbelief that Mr. Altman would pursue a voice that sounded so eerily similar to mine that my closest friends and news outlets could not tell the difference. "
--prompt-tokens fake.npyสำหรับปลา 1.5 (ค่าเริ่มต้น):
# Switch to --features cuda for Nvidia GPUs
cargo run --release --features metal --bin vocoder -- -i out.npy -o fake.wavสำหรับรุ่นก่อนหน้าโปรดระบุเวอร์ชัน 1.2 ตัวอย่าง:
cargo run --release --bin vocoder -- --fish-version 1.2 --checkpoint ./checkpoints/fish-speech-1.2-sftคำเตือน
codebase นี้ได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 ดั้งเดิม อย่าลังเลที่จะใช้ตามที่คุณต้องการ อย่างไรก็ตามน้ำหนักการพูดปลาคือ CC-by-NC-SA-4.0 และสำหรับการใช้งานที่ไม่ใช่เชิงพาณิชย์เท่านั้น!
โปรดสนับสนุนผู้เขียนดั้งเดิมโดยใช้ API อย่างเป็นทางการสำหรับการผลิต
โมเดลนี้ได้รับอนุญาตอย่างอนุญาตภายใต้ใบอนุญาต BY-CC-NC-SA-4.0 ซอร์สโค้ดถูกเผยแพร่ภายใต้ใบอนุญาต Apache 2.0
ขอบคุณมากไปที่:
candle_examples ผู้ดูแลระบบสำหรับตัวอย่างรหัสที่มีประโยชน์สูงทั่ว codebaseFish Speech v1.5 เป็นรุ่นข้อความนำไปใช้เป็นคำพูด (TTS) ที่ผ่านการฝึกอบรมเกี่ยวกับข้อมูลเสียงมากกว่า 1 ล้านชั่วโมงในหลายภาษา
ภาษาที่รองรับ:
โปรดดูคำพูดของปลา GitHub สำหรับข้อมูลเพิ่มเติม มีการสาธิตที่ Fish Audio
หากคุณพบว่าที่เก็บนี้มีประโยชน์โปรดพิจารณาอ้างถึงงานนี้:
@misc{fish-speech-v1.4,
title={Fish-Speech: Leveraging Large Language Models for Advanced Multilingual Text-to-Speech Synthesis},
author={Shijia Liao and Yuxuan Wang and Tianyu Li and Yifan Cheng and Ruoyi Zhang and Rongzhi Zhou and Yijin Xing},
year={2024},
eprint={2411.01156},
archivePrefix={arXiv},
primaryClass={cs.SD},
url={https://arxiv.org/abs/2411.01156},
}
โมเดลนี้ได้รับอนุญาตอย่างอนุญาตภายใต้ใบอนุญาต BY-CC-NC-SA-4.0