Metadata-Version: 2.4
Name: fish_speech_lib
Version: 0.1.1.1
Summary: Python library interface for Fish Speech text-to-speech and voice-cloning inference.
Author-email: Atm4x <bloodyseiko@gmail.com>
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/Atm4x/Fish-speech-pipeline
Project-URL: Repository, https://github.com/Atm4x/Fish-speech-pipeline
Project-URL: Bug Tracker, https://github.com/Atm4x/Fish-speech-pipeline/issues
Project-URL: Original Project, https://github.com/fishaudio/fish-speech
Keywords: tts,text-to-speech,voice-cloning,speech-synthesis,fish-speech
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: numpy<=1.26.4
Requires-Dist: natsort>=8.4.0
Requires-Dist: transformers>=4.45.2
Requires-Dist: datasets==2.18.0
Requires-Dist: lightning>=2.1.0
Requires-Dist: hydra-core<1.4,>=1.3.2
Requires-Dist: omegaconf<2.4,>=2.2
Requires-Dist: tensorboard>=2.14.1
Requires-Dist: einops>=0.7.0
Requires-Dist: librosa>=0.9.1
Requires-Dist: rich>=13.5.3
Requires-Dist: wandb>=0.15.11
Requires-Dist: grpcio>=1.58.0
Requires-Dist: kui>=1.6.0
Requires-Dist: uvicorn>=0.30.0
Requires-Dist: loguru>=0.6.0
Requires-Dist: resampy>=0.4.3
Requires-Dist: zstandard>=0.22.0
Requires-Dist: pydub
Requires-Dist: pyaudio
Requires-Dist: faster-whisper
Requires-Dist: ormsgpack
Requires-Dist: tiktoken>=0.8.0
Requires-Dist: pydantic==2.9.2
Requires-Dist: cachetools
Requires-Dist: huggingface-hub
Requires-Dist: loralib
Requires-Dist: vector_quantize_pytorch==1.14.24
Dynamic: license-file

# Fish-Speech-Lib 0.1.1

Fish-Speech-Lib provides a Python interface to the Fish Speech inference pipeline for text-to-speech and voice cloning, without requiring the Fish Speech web UI.

Upstream project: [fishaudio/fish-speech](https://github.com/fishaudio/fish-speech)

## Release notes

**0.1.1** - September 30, 2026: Added MultiGPU support through separate instances on `cuda:0`, `cuda:1`, etc.; device-aware model caches and sampling; scoped `torch.compile`; explicit worker cleanup with `close()` / context managers; compact device setup JSON in the system temp folder.

## Requirements

- Python 3.10 or newer.
- PyTorch installed separately for the accelerator you intend to use.
- CUDA is recommended for NVIDIA GPUs; CPU and MPS are supported by the library's device routing, although performance and feature support vary by backend.

## Installation

Install PyTorch for your platform first, then install the library:

```bash
pip install fish_speech_lib
```

When running directly from the source tree, add the repository root to `PYTHONPATH` or `sys.path`. A `.project-root` marker is not required.

## Basic usage

```python
from fish_speech_lib import FishSpeech
import soundfile as sf

with FishSpeech(device="cuda", compile_model=False) as tts:
    sample_rate, audio = tts(
        text="Hello, world!",
        max_new_tokens=450,
    )

sf.write("output.wav", audio, sample_rate)
```

### Device selection

`device` accepts normal PyTorch device strings. In a multi-GPU process, pass an explicit CUDA index when placement matters:

```python
tts = FishSpeech(device="cuda:1")
```

A bare `"cuda"` selects the first visible CUDA device (`cuda:0`). Explicit indices such as `"cuda:1"` are preserved throughout the library's model, cache, sampling, and decoder paths.

## MultiGPU usage

Create a separate instance for each GPU and send requests to the instance you want to use. Each GPU holds its own model and caches.

```python
from concurrent.futures import ThreadPoolExecutor
import soundfile as sf
from fish_speech_lib import FishSpeech

with FishSpeech(device="cuda:0") as first, FishSpeech(device="cuda:1") as second:
    with ThreadPoolExecutor(max_workers=2) as pool:
        jobs = [
            pool.submit(first, text="First request."),
            pool.submit(second, text="Second request."),
        ]
        for index, job in enumerate(jobs):
            sample_rate, audio = job.result()
            sf.write(f"output-{index}.wav", audio, sample_rate)
```

You can enable `compile_model=True` on each instance. Use `close()` when you manage instances without a `with` block.

## Voice cloning

```python
from fish_speech_lib import FishSpeech

with FishSpeech(device="cuda:0") as tts:
    sample_rate, audio = tts(
        text="This is an example of voice cloning.",
        reference_audio="path/to/reference.wav",
        reference_audio_text="The text spoken in the reference audio.",
        max_new_tokens=1000,
    )
```

## `torch.compile`

Set `compile_model=True` to compile the token decode path with `torch.compile`. Compilation is lazy, so the first inference can take substantially longer than later calls. CUDA compilation is invoked inside the selected model device context; the library does not remap `CUDA_VISIBLE_DEVICES` or install process-wide Torch/Inductor monkey patches.

## Model downloads

If the default Fish Speech 1.5 checkpoints are missing, the library downloads them from `fishaudio/fish-speech-1.5` on Hugging Face.

## License

The source code in this repository is distributed under the Apache License 2.0. See [`LICENSE`](LICENSE). Files derived from Fish Speech retain Fish Audio attribution, and files modified by this project carry modification notices.

The Fish Speech 1.5 model weights downloaded from Hugging Face are separate assets and are licensed separately under CC BY-NC-SA 4.0. The repository's Apache-2.0 license does not relicense those model weights.

## Copyright

- Original Fish Speech code: Copyright 2024-2025 Fish Audio Authors.
- Fish-Speech-Lib modifications: Copyright 2025-2026 Atm4x.
