
純粋な錆で書かれた、魚の音声1.5以下のシンプルで高速なテキストからスピーチの推論サーバー。
特徴:
torch.compileキャッシュ障害注記
はい、ソースからコンパイルすることは面白くありません。公式のDocker画像、HomeBrew、Linux Packaging、およびPython Interopレイヤーがロードマップにあります。
プラットフォームをサポートしたい場合は、お気軽に問題を提起してください。
まず、このレポを必要なフォルダーにクローンします。
git clone https://github.com/EndlessReform/fish-speech.rs.git
cd fish-speech.rs魚の音声チェックポイントを./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 metalnvidiaの場合:
cargo build --release --bin server --features cudaNvidiaでの追加のパフォーマンスのために、Flashの注意を引き付けることができます。ただし、初めてまたは主要な更新の後にコンパイルした場合、これにはかなり時間がかかる場合があります。まともなCPUで最大15分16GBのRAMです。あなたは警告されています!
mkdir ~ /.candle
CANDLE_FLASH_ATTN_BUILD_DIR= $HOME /.candle cargo build --release --features flash-attn --bin serverこれにより、バイナリを./target/release/serverにコンパイルします。
バイナリを開始するだけです!初めて始めた場合は、実行してください。
# 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.2 1.4デフォルトは1.5です--temp :言語モデルバックボーンの温度。デフォルト:0.7--top_p :言語モデルバックボーンのトップPサンプリング。デフォルト0.8、オフにするには、1に設定します。このサーバーは、OGGオーディオ(ストリーミング)と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ファイルと転写が必要です。ファイルfake.wavに「hello world」と言うスピーカーaliceを追加したいとします。
/v1/audio/encoding endpointに投稿リクエストを行います。
idおよびprompt AS URLエンコードクエリパラメーターカールの例:
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. "
}
}Voicesディレクトリには以下が含まれています。
default.npy )ですランタイムエンコードから得た.npyファイルを使用して、スピーカーIDに変更します:Ex。 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. "
}
}サーバーを再起動すると、新しい音声が良いはずです。
今のところ、公式の魚の音声推論CLIスクリプトとの互換性を維持しています。 (推論サーバーと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 Supportを使用してコンパイルします。
警告
キャンドルフラッシュアテンションの依存関係は、良いCPUでもコンパイルするのに10分以上かかる場合があり、16 GB以上のメモリを必要とする可能性があります。あなたは警告されています。
また、2024年10月のボトルネックは実際には他の場所(非効率的なメモリコピーとカーネルディスパッチ)であるため、すでに高速ハードウェア(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警告
このコードベースは、元のApache 2.0ライセンスの下でライセンスされています。あなたが望むように自由に使用してください。ただし、魚のスピーチの重量はCC-BY-NC-SA-4.0であり、非営利目的のみです!
生産に公式APIを使用して、元の著者をサポートしてください。
このモデルは、BY-CC-NC-SA-4.0ライセンスに基づいて許可されています。ソースコードは、Apache 2.0ライセンスでリリースされます。
大いに感謝します:
candle_examplesメンテナーは、コードベース全体の非常に便利なコードスニペットのためのメンテナーFish Speech v1.5は、複数の言語で100万時間以上のオーディオデータでトレーニングされた主要なテキスト対スピーチ(TTS)モデルです。
サポート言語:
詳細については、Fish Speech Githubを参照してください。フィッシュオーディオで利用可能なデモ。
このリポジトリが便利だと思った場合は、この作業を引用することを検討してください。
@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ライセンスに基づいて許可されています。