Setting up the speech server for the Audiobook
The Audiobook extension needs a Chatterbox-TTS-Server (devnen/Chatterbox-TTS-Server,
FastAPI, MIT licence) that it can reach over HTTP. This page is the server side. What is on it was tried on one machine (an AMD Radeon AI PRO R9700
with 32 GB, LiteLLM in front of everything, llama-server in router mode); your hardware and proxy may need other values.
Which setup is yours?
So: yes, pre and post requests are needed only when the two models take turns on one GPU. They are what makes the turns: the plugin makes them once around a batch (everything you started with one click), not around every part.
1. The speech server
Run Chatterbox-TTS-Server in a container (or from source) so that GET /api/model-info answers. Things that matter:
-
The model. Turbo (
chatterbox-turbo) is the default of the extension and the best sounding in the tests; the multilingual model is needed only for text in another language than the book's. The model is set in the server'sconfig.yaml(orPOST /save_settingsandPOST /restart_server). The Speech model of the backend must be the model the server has loaded after the acquire steps of its GPU lock. -
Japanese needs
pykakasiin the image. Without it the server logs pykakasi not available - Japanese text processing skipped and reads kanji wrongly. AddRUN python3 -m pip install --no-cache-dir pykakasito its Dockerfile (beforeCOPY . .). The same silent skip exists for Hebrew, Russian and Chinese packages. -
Voices are files in the server's
reference_audio/folder (mount it, so they survive). The extension uploads the clips of your actors itself (POST /upload_reference) before a batch, under a name made from the hash of the clip. The server has no delete call: clips pile up there. -
The server has no authentication. Do not publish its port; put a proxy in front of it if it is not on a private network.
-
restart: "no"for a container that something else starts on demand.restart: unless-stoppedstarts it at boot and takes the card for nothing.
In the backend (Settings → Extension Settings → Audiobook Settings) put its address, tick The server is on this machine or on my network if it is, press Test connection: the server answers, the model is loaded is what you want.
The extension speaks to /tts (the full set of parameters: voice, language, exaggeration, CFG weight, temperature, speed, seed) and GET /api/model-info, /get_predefined_voices, /get_reference_files, /upload_reference. If a proxy is between you and the server, it has to pass all of these.
Higgs Audio v3 in ComfyUI
A backend with the speech model Higgs Audio v3 in ComfyUI talks to a ComfyUI with the nodes of the
TTS Audio Suite, not to Chatterbox-TTS-Server. Its address is the one of ComfyUI (for example
http://gpu-server:8188). It was set up on the same AMD R9700 in the yanwk/comfyui-boot:rocm image.
- Install the suite into the
custom_nodesfolder of ComfyUI (git clone https://github.com/diodiogod/TTS-Audio-Suite). Its Python packages go into the container. To keep them when the container is recreated, give pip a folder on a volume: addPIP_USER=trueto the environment of the container and mount./storage/local:/root/.local. -
Never let pip replace the torch of the image (a CUDA build would replace the ROCm one). Write the installed versions into a file and install with it as a constraint:
PIP_USER=false python3 -m pip list --format=freeze | grep -iE '^(torch|torchaudio|torchvision|numpy|numba|transformers)==' > /root/.local/keep.txt PIP_CONSTRAINT=/root/.local/keep.txt python3 -m pip install -r requirements.txt PIP_CONSTRAINT=/root/.local/keep.txt python3 -m pip install librosaDo not run the suite's
install.pyas a whole: it may reinstall torch.librosais not in itsrequirements.txtand the suite does not load without it. - The model:
hf download bosonai/higgs-audio-v3-tts-4b --local-dir <ComfyUI>/models/TTS/higgs_audio_v3/higgs-audio-v3-tts-4b(about 8 GB), or let the suite download it the first time. It needs about 8 GB of the graphics card. - Test connection in the backend says the server answers with the model of the node when ComfyUI and the node are there.
What the extension does with it: it uploads the clips of the cast into the input folder of ComfyUI (POST /upload/image, under a name made from the clip), lists
the voices of the suite and the clips with GET /object_info, posts a workflow of its own to /prompt for every piece, waits on /history and fetches the audio
from /view (the workflow also hands the generation info of the TTS node to the core PreviewAny node: the suite answers an error with a second of silence and a run that succeeded, and only that info tells the piece failed, which then fails with the reason instead of being kept): with ffmpeg on the Marginalia side as flac, which it trims after the last word, fades out and stores as mp3 or wav; without ffmpeg as the mp3 of ComfyUI, untrimmed (wav storage then does not work). After every piece it calls POST /free with
{"free_memory": true}: on the R9700 the third piece in a row on the loaded model crashed the graphics card (HSA_STATUS_ERROR_EXCEPTION, ComfyUI exits);
emptying the memory between pieces keeps the model loaded and avoids it, for about 3 seconds a piece. ComfyUI is started and stopped around a batch with the
same kind of requests as the speech server (
Use fp32 on an AMD card. With the precision auto (bf16 on the R9700 with ROCm 7.2) many pieces came out as gibberish, as sound effects (a line about
banging became eleven knocks) or in a wrong voice, and changing the seed only moved the luck. The same pieces in fp32 were word-perfect. The backend's
Precision is fp32 by default; it needs about 16 GB of the card. The Granite speech recognition of the suite has the same problem in bf16 (gibberish from
the second recognition on), so the extension runs it in float32 as well.
The cleanup of clips (Cleanup of clips) uses two more nodes of the same suite, VocalRemovalNode (separation
models) and VoiceFixerNode, with LoadAudio and SaveAudio of ComfyUI; no other node pack is needed. The suite downloads a model the first time it is
used (the MelBand Roformer models are about 900 MB each). On the R9700 the MelBand models (vocals, denoise) and the voice fixer worked, about 25 seconds
for a 16-second clip. The UVR models first did not:
-
UVR-DeEcho-DeReverb(used by Remove echo and Film or game clip) failed withmodule 'samplerate' has no attribute 'resample'. The container hadsamplerate0.1.0, a wrapper that needs the system librarylibsamplerate, which the image lacks. The current package brings its own; install it with the torch pin and restart ComfyUI:PIP_CONSTRAINT=/root/.local/keep.txt python3 -m pip install --user 'samplerate>=0.2.1'After it, de-reverb took about 5 seconds for a 16-second clip.
UVR-DeNoisefailed to download (the address of the suite answered 404); put the file intomodels/TTS/UVR/by hand to use it. The MelBand denoise model needs no such step and is the one of the default cleanups.
The Fish Audio S2 Pro engine of the suite did not work on that card: its audio came out as invalid numbers (NaN). The Higgs Audio v3 weights are under a research and non-commercial licence.
One GPU for the model and the speech
A card that holds the language model has no room for the speech model. The administrator sets up the swap once under Admin → GPUs, with a GPU and a lock for each thing that can be loaded on it, and picks the lock in the AI of the language model and in the speech backend. The plan is the same for any proxy:
lock "Speech (Chatterbox)" acquire: 1. unload the language model
2. start the speech server (and wait until it is ready; load its model if it starts empty)
release: 3. stop the speech server
lock "Language model" acquire: nothing (the router loads the model by itself with the next request)
release: nothing (the speech lock unloads it first)
A batch (or a sample) of the speech backend runs the acquire steps of the speech lock when the GPU holds the language model, then all the pieces; the GPU stays loaded with the speech server after it. The next request to the language model waits for the batch, runs the release step of the speech lock (stop the server) and goes on. Several batches and samples in a row pay for the swap once.
The order is not negotiable. Starting the speech container while the language model holds the card filled the host's memory in the test (30 GB of RAM, the swap, then the OOM killer took other services): the unload must come first. The first failing acquire step ends the list, so nothing starts on a full card; and when a release step fails, the next lock is not loaded at all (the GPU may still be full) and the job fails with the error. The release steps all run, whatever happens to one of them.
Higgs, the speech recognition and the cleanup of clips on one ComfyUI each get a lock of their own, all three with the same steps (unload the language model, start ComfyUI; release: stop ComfyUI). ComfyUI keeps a model it unloaded in the server's memory (fp32 Higgs is about 16 GB), and loading the speech recognition next to it ran the server out of memory in the test; with three locks every switch restarts ComfyUI, so only one of them is ever loaded.
Why stop the container instead of unloading the model inside the server: an unload inside the server left about 1 GB of the card taken after many model swaps; stopping the container frees everything.
The steps
Each step is a method, an address, headers, a body, a timeout and a wait afterwards (seconds); the headers are stored encrypted, so the key of the
proxy can be written into them (Authorization: Bearer ...). With a LiteLLM in front of everything, the steps of the speech lock are (Before 1
to 3 are its acquire steps, After 1 its release step):
For a Higgs backend Before 2 is POST http://litellm:4000/gpu/comfy/start (it answers when ComfyUI is up, about 15 s; the model is loaded with the first
piece), there is no Before 3, and After 1 is POST http://litellm:4000/gpu/comfy/stop. The two pass-throughs are in the README of tools/gpu-control.
The language model comes back by itself: the next ordinary request makes the router load it (about a minute for a big model; with the prompt cache hook the cache of your session is restored), so no request after the batch is needed for it.
Without LiteLLM the same requests go to whatever starts and stops your containers; the only rule is the order above.
What answers those addresses
X-Llama-Unloadis answered by the hookgpu_unload.pyof LiteLLM, described with its code in Freeing the GPU for another model (it works without the cache hook). With a routeopenai/*the model name in the body must start withopenai/: another name is answered 400 after the models were unloaded.-
/gpu/tts/start,/stop,/loadare LiteLLM pass-through endpoints to the small controllertools/gpu-controlof the repository, which starts and stops containers by name. Its README has the compose file with the Docker socket proxy (so the controller can start and stop containers and do nothing else; the socket itself is root on the host) and the settings that are easy to get wrong:POST=1,ALLOW_START=1,ALLOW_STOP=1,CONTAINERS=0. In LiteLLM:general_settings: pass_through_endpoints: - path: "/gpu/tts/start" target: "http://gpu-control:8000/chatterbox/start" headers: {X-Control-Token: os.environ/GPU_CONTROL_TOKEN} - path: "/gpu/tts/stop" target: "http://gpu-control:8000/chatterbox/stop" headers: {X-Control-Token: os.environ/GPU_CONTROL_TOKEN} - path: "/gpu/tts/load" target: "http://chatterbox:8004/restart_server"(the container is named
chatterboxandGPU_CONTROL_CONTAINERS=chatterbox=http://chatterbox:8004/api/model-infotells the controller what to wait for; the controller's token stays in its.envand in LiteLLM's environment, Marginalia only ever has the key of LiteLLM). - All the containers and LiteLLM share a Docker network (
docker network create ai, once). Putnetworks: [default, ai]and the external networkaiinto each compose file: adocker network connectdone by hand is lost when a container is recreated.
Checking it
curl http://<speech server>/api/model-infoanswers (loadedtrue after a start).- Test connection in the backend says the model is loaded. If the GPU lock is the only thing that starts the server, test it with the lock picked: the server answers, no model is loaded is the answer of a stopped-and-started one that still has to load.
- Convert one short part in Convert to audio. The window shows the pieces being made; afterwards the speech container should be stopped and
nvidia-smi/nvtop/rocm-smishow the card free again. - If the first call after a model load takes long, that is the engine warming up (once, 28 s in the first run, not seen again).