unrealspeech-api
v1.0.2
Published
TypeScript client for the Unreal Speech TTS API.
Downloads
29
Readme
unrealspeech-api
TypeScript client for the Unreal Speech TTS API.
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 TTS 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 universalfetch
- 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 handles automatic retries, is very customizable, and is built on top of
fetch
Install
npm install unrealspeech-api
This package is ESM-only. If your project uses CommonJS, consider switching to ESM or use dynamic import()
.
Usage
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
If you found this project interesting, consider following me on Twitter.