該項目的靈感來自Silero-API-Server,並使用XTTSV2。
該服務器是為sillytavern創建的,但您可以將其用於您的需求
隨意製作PR或為您自己的需求使用代碼
如果您的計算機弱,則可以使用Google Collapon版本。
如果您正在尋找普通XTT的選項,請在這裡https://github.com/daswer123/xtts-webui
最近,我幾乎沒有時間進行這個項目,所以我建議您熟悉一個類似的項目
您可以跟踪發布頁面上的所有更改
簡單安裝:
pip install xtts-api-server這將安裝所有必要的依賴項,包括僅CPU支持版本的Pytorch版本
我建議您安裝GPU版本以提高處理速度(最多快3倍)
python -m venv venv
venv S cripts a ctivate
pip install xtts-api-server
pip install torch==2.1.1+cu118 torchaudio==2.1.1+cu118 --index-url https://download.pytorch.org/whl/cu118sudo apt install -y python3-dev python3-venv portaudio19-dev
python -m venv venv
source venv b in a ctivate
pip install xtts-api-server
pip install torch==2.1.1+cu118 torchaudio==2.1.1+cu118 --index-url https://download.pytorch.org/whl/cu118 # Clone REPO
git clone https://github.com/daswer123/xtts-api-server
cd xtts-api-server
# Create virtual env
python -m venv venv
venv/scripts/activate or source venv/bin/activate
# Install deps
pip install -r requirements.txt
pip install torch==2.1.1+cu118 torchaudio==2.1.1+cu118 --index-url https://download.pytorch.org/whl/cu118
# Launch server
python -m xtts_api_server
提供了一個Dockerfile來構建Docker映像,並提供了Docker-compose.yml文件以使用Docker組成的服務來運行服務器。
您可以使用以下命令構建圖像:
mkdir xtts-api-server
cd xtts-api-server
docker run -d daswer123/xtts-api-server
或者
cd docker
docker compose build然後,您可以使用以下命令運行服務器:
docker compose up # or with -d to run in background python -m xtts_api_server將在默認IP和端口上運行(Localhost:8020)
使用--deepspeed標誌快速處理結果(2-3X加速度)
usage: xtts_api_server [-h] [-hs HOST] [-p PORT] [-sf SPEAKER_FOLDER] [-o OUTPUT] [-t TUNNEL_URL] [-ms MODEL_SOURCE] [--listen] [--use-cache] [--lowvram] [--deepspeed] [--streaming-mode] [--stream-play-sync]
Run XTTSv2 within a FastAPI application
options:
-h, --help show this help message and exit
-hs HOST, --host HOST
-p PORT, --port PORT
-d DEVICE, --device DEVICE `cpu` or `cuda`, you can specify which video card to use, for example, `cuda:0`
-sf SPEAKER_FOLDER, --speaker-folder The folder where you get the samples for tts
-o OUTPUT, --output Output folder
-mf MODELS_FOLDERS, --model-folder Folder where models for XTTS will be stored, finetuned models should be stored in this folder
-t TUNNEL_URL, --tunnel URL of tunnel used (e.g: ngrok, localtunnel)
-ms MODEL_SOURCE, --model-source ["api","apiManual","local"]
-v MODEL_VERSION, --version You can download the official model or your own model, official version you can find [here](https://huggingface.co/coqui/XTTS-v2/tree/main) the model version name is the same as the branch name [v2.0.2,v2.0.3, main] etc. Or you can load your model, just put model in models folder
--listen Allows the server to be used outside the local computer, similar to -hs 0.0.0.0
--use-cache Enables caching of results, your results will be saved and if there will be a repeated request, you will get a file instead of generation
--lowvram The mode in which the model will be stored in RAM and when the processing will move to VRAM, the difference in speed is small
--deepspeed allows you to speed up processing by several times, automatically downloads the necessary libraries
--streaming-mode Enables streaming mode, currently has certain limitations, as described below.
--streaming-mode-improve Enables streaming mode, includes an improved streaming mode that consumes 2gb more VRAM and uses a better tokenizer and more context.
--stream-play-sync Additional flag for streaming mod that allows you to play all audio one at a time without interruption
您可以將文件的路徑指定為文本,然後是路徑計數和文件
您可以加載自己的模型,為此,您需要在模型中創建一個文件夾並使用配置加載模型,該文件夾中的注意應為3個文件config.json vocab.json model.pth
如果您希望主機聆聽,請使用-HS 0.0.0.0或使用 - listen
需要-t或-tunnel標誌,因此當您通過Get Geter Geters獲得揚聲器時,您可以獲得正確的鏈接來聆聽預覽。更多信息在這裡
模型源定義您要使用XTTS的格式:
local加載版本2.0.2默認情況下,但是您可以通過-v標誌指定版本,模型保存到模型文件夾中,並使用XttsConfig和inference 。apiManual默認情況下,加載2.0.2版本,但是您可以通過-V標誌指定版本,模型保存到模型文件夾中,並使用tts_to_file函數從tts api中使用api將加載最新版本的模型。 -v標誌行不通。可以在此處找到XTTSV2模型的所有版本,模型版本名稱與分支名稱[v2.0.2,v2.0.3,main]等相同。
您第一次運行或生成時,您可能需要確認您同意使用XTT。
流媒體模式使您可以獲取音頻並幾乎立即播放。但是,它有許多局限性。
您可以在這里和這裡看到此模式的工作方式
現在,關於限制
tts_to_file僅tts_to_audio ,它返回沉默的1秒。您可以使用-v標誌指定XTTS模型的版本。
改進的流媒體模式適用於中文,日語,印地語等複雜語言,或者如果您希望語言引擎在處理語音時考慮更多信息。
--stream-play-sync標誌 - 允許您按隊列順序播放所有消息,如果使用組聊天,則可以使用。在sillytavern中,您需要關閉流媒體以正確工作
可以從http:// localhost訪問API文檔:8020/DOCS
默認情況下, speakers文件夾應出現在文件夾中,您需要將WAV文件放在語音樣本中,您還可以創建一個文件夾並放置幾個語音示例,這將提供更準確的結果
您可以通過API更改揚聲器的文件夾和用於輸出的文件夾。
以下帖子是Reddit的用戶材料1276的報價
一些關於製作好樣本的建議
讓他們長約7-9秒。更長的時間不一定會更好。
確保將音頻向下採樣到單聲道22050Hz 16位WAV文件。您將減慢一定百分比的速度,否則似乎會導致質量差的結果(基於一些測試)。無論如何,24000Hz是它輸出的質量!
使用最新版本的Audacity,選擇您的剪輯和軌道>重新採樣至22050Hz,然後跟踪> Mix> MIX>立體聲>立體聲。然後文件>導出音頻,將其保存為22050Hz的WAV
如果您需要進行任何音頻清潔,請在將其壓縮到上述設置之前(Mono,22050Hz,16位)。
確保您使用的剪輯不會有背景噪音或音樂上的音樂,例如,許多演員都在講話時都有安靜的音樂。質量不佳的音頻將帶有需要清理的嘶嘶聲。即使我們不這樣做,AI也會撿起它,並且在某種程度上會在某種程度上使用模擬聲音,因此乾淨的音頻是關鍵!
嘗試使您的剪輯成為一個不錯的流動語音之一,就像隨附的示例文件一樣。沒有大的暫停,差距或其他聲音。最好是您要復制的人會顯示一些聲音範圍。示例文件在這裡
確保剪輯不會以呼吸的聲音開始或結束(呼吸進出)。
但是,使用AI生成的音頻剪輯可能會引入不需要的聲音,因為它已經對語音進行了複製/模擬,這將需要測試。