npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

fish-audio

v0.0.3

Published

To provide convenient Node.js program integration for https://docs.fish.audio

Readme

Fish Audio Typescript SDK

To provide convenient Typescript program integration for https://docs.fish.audio

Install

npm install fish-audio

Usage

Initialize a FishAudioClient to use APIs. Authenticate by setting FISH_API_KEY="your_api_key" in your environment or pass it in.

import { FishAudioClient } from fish-audio;

const fishAudio = new FishAudioClient();

Sometimes, you may need to change our endpoint to another address. You can use

import { FishAudioClient } from fish-audio;

const fishAudio = new FishAudioClient({apiKey: "your_api_key", baseUrl: "https://your-proxy-domain"});

Text to Speech

import { FishAudioClient, play } from fish-audio;

const fishAudio = new FishAudioClient({ apiKey: "your_api_key" });

const request = { text: "Hello, world!" };
const audio = await fishAudio.textToSpeech.convert(request); //defaults to backend: "s1"

await play(audio);

Reference Audio

import type { TTSRequest } from fish-audio;

const request: TTSRequest = {
    text: "Hello, world!",
    reference_id: "your_model_id",
};

Or just use ReferenceAudio in TTSRequest:

const audioBuffer = await readFile(new URL("/path/to/your/audio/file",));
const referenceFile = new File([audioBuffer], "audio_file_name");

const referenceAudio: ReferenceAudio = {
    audio: referenceFile,
    text: "reference audio text"
};

const request: TTSRequest = {
    text: "Hello, world!",
    references: [referenceAudio]
};

WebSocket

The TTS websocket provides real-time streaming.

import { FishAudioClient, RealtimeEvents } from "fish-audio";
import { writeFile } from "fs/promises";
import path from "path";

// Simple async generator that yields text chunks to speak
async function* makeTextStream() {
    const chunks = [
        "Hello from Fish Audio! ",
        "This is a realtime text-to-speech test. ",
        "We are streaming multiple chunks over WebSocket.",
    ];
    for (const chunk of chunks) {
        yield chunk;
        await new Promise((r) => setTimeout(r, 200));
    }
}

const client = new FishAudioClient();

// For realtime, set text to "" and stream the content via textStream instead
const request = {
    text: "",
    reference_id: "your_model_id"
};

// Defaults to backend: "s1"
const connection = await client.textToSpeech.convertRealtime(request, makeTextStream());

// Collect audio and write to a file when the stream ends
const chunks: Buffer[] = [];
connection.on(RealtimeEvents.OPEN, () => console.log("WebSocket opened"));
connection.on(RealtimeEvents.AUDIO_CHUNK, (audio: unknown): void => {
    if (audio instanceof Uint8Array || Buffer.isBuffer(audio)) {
        chunks.push(Buffer.from(audio));
    }
});
connection.on(RealtimeEvents.ERROR, (err) => console.error("WebSocket error:", err));
connection.on(RealtimeEvents.CLOSE, async () => {
    const outPath = path.resolve(process.cwd(), "out.mp3");
    await writeFile(outPath, Buffer.concat(chunks));
    console.log("Saved to", outPath);
});

Speech to Text (ASR)

import { FishAudioClient } from "fish-audio";
import { createReadStream } from "fs";

const fishAudio = new FishAudioClient();

const audioFile = createReadStream(new URL("/path/to/your/audio/file"));

try {
    const result = await fishAudio.speechToText.convert({
        audio: audioFile,
    });

    console.log("Transcription:", result.text);
    console.log("Duration (s):", result.duration);
    console.log("Segments:", result.segments);
} catch (err) {
    console.error("STT request failed:", err);
}

Voices

Clone a Voice

import { FishAudioClient } from "fish-audio";
import { createReadStream } from "fs";

const fishAudio = new FishAudioClient();

const title = "cloned-voice-name";
const audioFile = createReadStream(new URL("/path/to/your/audio/file"));
const coverImageFile = createReadStream(new URL("/path/to/your/cover/image/file"));

try {
    const response = await fishAudio.voices.ivc.create({
        title: title,
        voices: [audioFile],
        cover_image: coverImageFile,
    });

    console.log("Voice created:", {
        id: response._id,
        title: response.title,
        state: response.state,
    });
} catch (err) {
    console.error("Create voice request failed:", err);
}

List models

fishAudio.voices.search()

Get a model info by id

fishAudio.voices.get("your_model_id")

Update a model

fishAudio.voices.update("your_model_id", { title: "new_title" })

Delete a model

fishAudio.voices.delete("your_model_id")

User

Get User API Credits

fishAudio.user.get_api_credit()

Get User Package

fishAudio.voices.get_package()