@ondewo/ondewo-t2s-client-js
v6.6.0
Published
ONDEWO Text to Speech (T2S) Client library for Js
Readme
Overview
@ondewo/t2s-client-js is a compiled version of the ONDEWO T2S API using the ONDEWO PROTO COMPILER. Here you can find the T2S API documentation.
ONDEWO APIs use Protocol Buffers version 3 (proto3) as their Interface Definition Language (IDL) to define the API interface and the structure of the payload messages. The same interface definition is used for gRPC versions of the API in all languages.
Setup
Using NPM:
npm i --save @ondewo/ondewo-t2s-client-jsUsing GitHub:
git clone https://github.com/ondewo/ondewo-t2s-client-js.git ## Clone repository
cd ondewo-t2s-client-js ## Change into repo-directoy
make setup_developer_environment_locally ## Install dependenciesPackage structure
npm
├── api
│ ├── ondewo_t2s_api.js
│ ├── ondewo_t2s_api.min.js
│ └── ondewo_t2s_api.min.js.map
├── auth
│ ├── offlineTokenProvider.js
│ └── offlineTokenProvider.spec.js
├── LICENSE
├── package.json
└── README.mdAuthentication
Calls to the ONDEWO API are authenticated with a Keycloak bearer token. Bundle auth/offlineTokenProvider.js into your app, call login() to obtain a live token provider, then pass its Authorization header as gRPC-web metadata on every request:
const { login } = require('@ondewo/ondewo-t2s-client-js/auth/offlineTokenProvider');
const tokenProvider = await login({
keycloakUrl: 'https://auth.example.com/auth',
realm: 'ondewo-ccai-platform',
clientId: 'ondewo-nlu-cai-sdk-public',
username: '[email protected]',
password: 'super-secret'
});
// Pass this metadata to any T2S RPC, e.g. client.synthesize(request, metadata):
const metadata = { Authorization: tokenProvider.getAuthorizationHeader() }; // "Bearer <jwt>"
tokenProvider.stop(); // stop the background refresh loop when donelogin() performs a one-time password login and then refreshes the short-lived access token in the background, so getAuthorizationHeader() always returns a valid Bearer <jwt> value. Use the canonical Authorization header casing. See examples/client.js and examples/index.html for a complete, runnable example.
