@ondewo/s2t-client-typescript
v7.5.0
Published
ONDEWO Speech to Text (S2T) Client library for Typescript
Maintainers
Readme
Overview
@ondewo/s2t-client-typescript is a compiled version of the ONDEWO S2T API using the ONDEWO PROTO COMPILER. Here you can find the S2T 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/s2t-client-typescriptUsing GitHub:
git clone https://github.com/ondewo/ondewo-s2t-client-typescript.git ## Clone repository
cd ondewo-s2t-client-typescript ## Change into repo-directoy
make setup_developer_environment_locally ## Install dependenciesPackage structure
npm
├── api
│ ├── google
│ │ └── protobuf
│ │ ├── empty_pb.d.ts
│ │ ├── empty_pb.js
│ │ ├── struct_pb.d.ts
│ │ └── struct_pb.js
│ └── ondewo
│ └── s2t
│ ├── speech-to-text_grpc_web_pb.d.ts
│ ├── speech-to-text_grpc_web_pb.js
│ ├── speech-to-text_pb.d.ts
│ └── speech-to-text_pb.js
├── auth
│ ├── offlineTokenProvider.d.ts
│ └── offlineTokenProvider.js
├── LICENSE
├── package.json
├── public-api.d.ts
├── public-api.js
└── README.mdapi/ and public-api.* are generated from ondewo/s2t/speech-to-text.proto by the
ONDEWO PROTO COMPILER; auth/ is hand-written and compiled into
the package by make create_npm_package.
Authentication
The service expects a Keycloak bearer token in the authorization gRPC metadata header. auth/offlineTokenProvider
performs the headless (2FA-exempt) ROPC + offline_access login against the public SDK client and keeps the
short-lived access token fresh in the background until tokenExpirationInS elapses:
import { login, OfflineTokenProvider } from '@ondewo/s2t-client-typescript/auth/offlineTokenProvider';
import { Speech2TextPromiseClient } from '@ondewo/s2t-client-typescript/api/ondewo/s2t/speech-to-text_grpc_web_pb';
import { ListS2tPipelinesRequest } from '@ondewo/s2t-client-typescript/api/ondewo/s2t/speech-to-text_pb';
const provider: OfflineTokenProvider = await login({
keycloakUrl: 'https://auth.ondewo.com/auth',
realm: 'ondewo-ccai-platform',
clientId: 'ondewo-nlu-cai-sdk-public',
username: process.env.KEYCLOAK_USER_NAME ?? '',
password: process.env.KEYCLOAK_PASSWORD ?? ''
// keycloakVerifySsl: false // ONLY for a self-signed local Envoy; Node-only, ignored in a browser
});
const client = new Speech2TextPromiseClient('http://localhost:8080');
const request = new ListS2tPipelinesRequest();
request.setLanguagesList(['en-US']);
const response = await client.listS2tPipelines(request, { Authorization: provider.getAuthorizationHeader() });
provider.stop(); // stops the background refresh loop so the process can exitA runnable version of exactly this flow, configured from examples/environment.env, lives in
examples/ts-client.ts.
