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 🙏

© 2024 – Pkg Stats / Ryan Hefner

fakeyou.ts

v3.6.1

Published

FakeYou API made easy, with ESM and TypeScript support!

Downloads

124

Readme

FakeYou.ts

FakeYou.ts logo

A modern, light, 100% type-safe, and easy-to-use unofficial API wrapper for FakeYou with Node.js. Get your app up and running with FakeYou in minutes!

Installation

Make sure you install the necessary build tools for Node. Otherwise you will get an error when you try to npm install this package!

npm install fakeyou.ts
npm pkg set type=module

If you use TypeScript it is recommended to include this in your tsconfig.json:

{
	"extends": "fakeyou.ts/tsconfig.recommended.json"
}

Text-to-speech usage

import Client from 'fakeyou.ts';

const client = new Client();

const model = await client.fetchTtsModelByToken('TM:4e2xqpwqaggr');
const inference = await model?.infer('hello!');

await inference?.toDisk('./local/name.wav'); // or toBuffer, toBase64 or just the raw URL!

Or voice-to-voice!

Fakeyou.ts is the only Node package to support voice-to-voice!

import Client from 'fakeyou.ts';
import { readFileSync } from 'node:fs';

const client = new Client();

const model = await client.fetchV2vModelByToken('vcm_tes015h65n6h');
const audioFile = readFileSync('./localAudioFile.wav'); // Wav is only supported for simplicity, as validating the type is not reliable
const inference = await model?.infer(audioFile);

await inference?.toDisk('./local/name.wav'); // Same API as TTS!

Login to FakeYou

You may optionally log in to take advantage of reduced rate limits, premium benefits, faster processing times and more.

import Client from 'fakeyou.ts';

const client = new Client();

await client.login({
	username: 'your username',
	password: 'your password',
});

Or set FAKEYOU_COOKIE as an environment variable containing your cookie and it will automatically log in. You may override the environment cookie with the above login() method.

Features

| Name | Description | Status | | ---------------------------------- | ------------------------------------------------------------------------------------------------ | ------ | | FakeYou login support (session) | Ability to take advantage of any potential premium benefits | ✅ | | Fetch models | Fetch models, and view their info, and do your own TTS | ✅ | | Text-to-speech download | Download text-to-speech as buffer, base64, or directly to disk | ✅ | | Voice-to-voice download | Upload a voice then download the voice-to-voice inference as buffer, base64, or directly to disk | ✅ | | Fetch model categories | Fetch categories, child categories and parent categories and their models | ✅ | | View and edit user profiles | View user profiles, and edit profiles you are privileged to edit (like your own) | ✅ | | Leaderboards | Fetch users from the leaderboard | ✅ | | Global FakeYou queue stats | Simple fetch of queue statistics | ✅ | | Subscription details | View your subscription details and loyalty status | ✅ | | View TTS audio history on profiles | View profile TTS audio history, and get associated model details, re-download audio and more | ✅ | | View user models on profiles | Get a list of the user's models from their profile | ✅ |

... and I will keep this list up to date with more features to come.

Contributing

If you would like to contribute, then please read the contributing guidelines. Thank you!

Q&A

My project uses CommonJS (require instead of import), will this package work?

No. This package is meant to be used with bleeding-edge JS, to keep things standardized and simple!

My project uses ESModule syntax, but compiles to CommonJS in post, will this package work?

If the resulting code is CommonJS this package will not be compatible.

Do you plan to support CommonJS?

No, sorry. 😔 Projects nowadays should be looking to move away from the legacy CommonJS module system. If you use TypeScript or another transpilation tool, you may be able to convert your project to ESModules and interoperate with CommonJS packages (in TypeScript there is the esModuleInterop flag you can set to true). Or you can dynamically import this package with await import().

Will this work with my JS-only project?

Yes! You still get all of the types out of the box even with JS, but you won't be able to take full advantage of the amazing benefits of types.

Do I need to log in to my FakeYou account to use this package?

Nope! As an anonymous user, you can still request TTS, but you will be missing out on any premium benefits and linking your TTS history to your account and some methods like client.fetchLoggedInUser() will return undefined.

What versions of Node.js do you support?

Node.JS LTS and up. You will know if you have an invalid version, because npm will say EBADENGINE upon install.

This package aims for LTS support, and will deprecate any versions under LTS.

Does it work in the browser?

No, unfortunately. 😔 It is best you create your own web server that uses this package to build your app.

Interestingly, the packages this project depends on are cross-platform, and it uses JS-native APIs when available like crypto and fetch so if CORS did not exist, I could tweak this project in only a few hours for first-class browser support. This package is 99% ready! CORS is just the blocker.

Does it work with Deno?

In theory, it should! But I haven't tried. Deno has first-class support for npm modules, so it should be possible.

If you have tried it, let me know, and I will update this README!

Why this over fakeyou.js?

Fakeyou.js is a great project (if you haven't seen it, you can check it out here!) but I wrote this package to address its shortcomings. For example and in comparison, fakeyou.ts is...

  • [x] Safe; All API responses are validated at runtime with type-smart schemas, which provides type-safety guarantees as well as the package just being fully type-safe. When using this package you will get autocomplete for every function, types for every return and compile-time errors for improper usage. No fragile conditional checks spread throughout the code.
  • [x] End-to-end and unit tested; Before this package is deployed or pull-requests merged, a branch must pass through user-simulated automated tests to reduce the likelihood of deploying bugs.
  • [x] Optimised and memory safe; Memory safe?!?! For JS?? A garbage collected language?! Yes! (well sort of, you don't have the same amount of control as other languages out there but this package does what it can.) Thanks to smart use of caching, searching for a model by name OR by token will return the exact same instance of the object in memory, so you are never creating unwanted garbage in the background and doing more work than is what is required. This does not just apply to models, but all other types of data too. The cache has a maximum capacity of ~500MB, with an object TTL of 10 minutes and stores no more than 5000 objects at a time.
  • [x] Scalable; All classes and components are all independent from one-another, making refactors and feature additions easy. Composition is favoured over inheritance with isolated implementation functions.
  • [x] Feature-rich; Fakeyou.ts is the most powerful NPM package available for Node.js (as of writing 🤣).
  • [x] Modern; Fakeyou.ts works with ESModules, supporting next-generation JavaScript projects and supports top-level await.
  • [x] Easy to work with; Not only does fakeyou.ts give you type-safety guarantees, it has a logging flag you can enable to inspect all of its network traffic, and if you're unfortunate enough, see nicely-formatted errors. I know that unhelpful errors are an absolute pain, so this package takes is seriously so any bugs or problems can be addressed as quickly as possible.
  • [x] Active on Discord; The maintainer (me!) of this project is active on FakeYou's official Discord! If there are any problems you are having, you can either contact me there (#api channel) or submit an issue on this GitHub page. Make sure to tag me so I don't miss you! For safety reasons I will not display my discord tag here.
  • [x] Highly documented; The code takes big advantage of JSDoc, to not only provide inline documentation while you code, but public documentation which is generated and published by an automated CI pipeline. https://fakeyouts.js.org/.