wrap-fish-audio
v0.1.0
Published
Simple wrapper around Fish Audio TTS API
Maintainers
Readme
wrap-fish-audio
Fish Audio TTS API wrapper for TypeScript/Node.js.
Install
npm install wrap-fish-audioSetup
import { LibAudio } from "wrap-fish-audio";
const audio = new LibAudio({
apiKey: "your-api-key", // or set FISH_API_KEY env var
});Usage
Text to Speech (Buffer)
const buffer = await audio.speak("Hello world", {
voiceId: "voice-model-id",
format: "mp3", // mp3 | wav | pcm | opus
});Save to File
await audio.speakToFile("Hello world", "./output.mp3", {
voiceId: "voice-model-id",
format: "mp3",
speed: 1.2,
});Streaming
const stream = await audio.speakStream("Hello world", {
format: "wav",
});List Voices
const { items, total } = await audio.listVoices({ pageSize: 10 });
for (const voice of items) {
console.log(`${voice.title} (${voice.id})`);
}Get Voice
const voice = await audio.getVoice("voice-model-id");SpeakOptions
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| voiceId | string | - | Voice model ID |
| format | "mp3" \| "wav" \| "pcm" \| "opus" | "mp3" | Output audio format |
| speed | number | - | Speech speed (0.5-2.0) |
| volume | number | - | Volume adjustment (dB) |
| temperature | number | - | Expressiveness (0-1) |
| topP | number | - | Nucleus sampling (0-1) |
| sampleRate | number | - | Sample rate in Hz |
| mp3Bitrate | 64 \| 128 \| 192 | - | MP3 bitrate (kbps) |
| opusBitrate | -1000 \| 24 \| 32 \| 48 \| 64 | - | Opus bitrate (kbps) |
| latency | "normal" \| "balanced" | - | Latency mode |
Config
const audio = new LibAudio({
apiKey: "your-api-key",
baseUrl: "https://custom-proxy.com", // optional
defaultVoiceId: "voice-model-id", // optional
defaultFormat: "wav", // optional, default: "mp3"
defaultBackend: "speech-1.6", // optional
});Raw SDK Access
const client = audio.raw; // FishAudioClient instanceLicense
MIT
