2.3.0 • Published 2 years ago
@charactr/api-sdk v2.3.0
charactr-api-sdk-ts
JavaScript/TypeScript SDK to interact with the charactr API.
Terminology
VC - Voice conversion - converting one voice from audio input to another voice.
TTS - Text to speech - converting text to voice audio.
Requirements
Node.js
>= v18.0.0Features
- making TTS requests
- making VC requests
- getting lists of available voices
Installation
$ yarn add @charactr/api-sdkUsage
For the detailed SDK usage, please refer to the SDK reference or the ./examples directory.
Security of using the SDK in browser
The ClientKey and ApiKey required to authenticate the SDK are meant to be private.
Packaging them with the frontend application effectively leaks them publicly and allows anyone to use your Charactr Account directly.
We strongly advise to proxy those requests via your own backend or use the browser SDK only for internal usage.
How to run examples
Node.JS
- Clone & install SDK locally
$ git clone https://github.com/charactr-platform/charactr-api-sdk-ts
$ yarn install
$ yarn build
$ npm install -g ts-node- Open
./examples/credentials.tsand paste your ClientKey and APIKey inside.
Use TTS
ts-node ./examples/nodejs/tts.tsUse TTS simplex streaming
ts-node ./examples/nodejs/tts_stream_simplex.tsUse TTS duplex streaming
ts-node ./examples/nodejs/tts_stream_duplex.tsUse VC
ts-node ./examples/nodejs/vc.tsUse Voice Clones
ts-node ./examples/nodejs/clones.tsRun ttfb / latency test
ts-node ./examples/nodejs/latency.tsExample output:
$ ts-node ./examples/nodejs/latency.ts
Running latency test. Today is Mon, 18 Sep 2023 11:53:29 GMT
serverLatency is 273 ms
voice "20" latency test: ttfb: 635 (server ttfb: 362) | total: 1560
voice "40" latency test: ttfb: 359 (server ttfb: 86) | total: 1281
voice "151" latency test: ttfb: 486 (server ttfb: 213) | total: 1395
voice "222" latency test: ttfb: 881 (server ttfb: 608) | total: 1992Browser
Navigate go ./examples/browser/ and open index.html example in your browser of choice. Provided sample uses ESModules.