An open API service indexing awesome lists of open source software.

https://github.com/transitive-bullshit/unrealspeech-api

TypeScript client for the Unreal Speech TTS API.
https://github.com/transitive-bullshit/unrealspeech-api

text-to-speech tts tts-api

Last synced: 4 months ago
JSON representation

TypeScript client for the Unreal Speech TTS API.

Awesome Lists containing this project

README

          

# unrealspeech-api

> TypeScript client for the [Unreal Speech](https://unrealspeech.com/) [TTS API](https://docs.unrealspeech.com/reference/getting-started-with-our-api).


Build Status
NPM
MIT License
Prettier Code Formatting

- [Intro](#intro)
- [Why?](#why)
- [Install](#install)
- [Usage](#usage)
- [License](#license)

## Intro

This package is a rewrite of https://github.com/unrealspeech/unrealspeech-js to expose a more standards-based TS package for the [Unreal Speech](https://unrealspeech.com/) [TTS API](https://docs.unrealspeech.com/reference/getting-started-with-our-api).

## Why?

Their first-party JS package has several issues:

- it has a bogus dependency on `fs` which doesn't inspire confidence
- it uses `node-fetch` instead of universal `fetch`
- it includes additional Node.js-specific functionality related to playing media via ffmpeg, which doesn't belong in this type of NPM package
- some of the types are also incorrect
- [ky](https://github.com/sindresorhus/ky) handles automatic retries, is very customizable, and is built on top of `fetch`

## Install

```sh
npm install unrealspeech-api
```

This package is [ESM-only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). If your project uses CommonJS, consider switching to ESM or use [dynamic `import()`](https://v8.dev/features/dynamic-import).

## Usage

```ts
import { UnrealSpeechClient } from 'unrealspeech-api'

const unrealSpeech = new UnrealSpeechClient({
apiKey: process.env.UNREAL_SPEECH_API_KEY
})

const shortResult = await unrealSpeech.stream({
text: 'Hello, World!',
voiceId: 'Scarlett'
})
console.log(shortResult)

const mediumResult = await unrealSpeech.speech({
text: 'Hello, World! ...',
voiceId: 'Scarlett'
})
console.log(mediumResult)

const synthesisTask = await unrealSpeech.createSynthesisTask({
text: 'Hello, World! ...',
voiceId: 'Scarlett'
})
console.log(synthesisTask)

const updatedSynthesisTask = await unrealSpeech.getSynthesisTask(
synthesisTask.TaskId
)
consolelog(updatedSynthesisTask)
```

## License

MIT © [Travis Fischer](https://x.com/transitive_bs)

If you found this project interesting, [consider following me on Twitter](https://x.com/transitive_bs).