@aristech-org/stt-client
Version:
A Node.js client library for the Aristech Speech-to-Text API
92 lines (91 loc) • 3.87 kB
TypeScript
import * as grpc from '@grpc/grpc-js';
import { AccountInfoRequest, type AccountInfoResponse, ModelsRequest, NLPFunctionsRequest, type NLPFunctionsResponse, NLPProcessRequest, type NLPProcessResponse, RecognitionConfig, StreamingRecognitionRequest, Model, StreamingRecognitionResponse, DeepPartial } from './generated/stt_service.js';
export * from './generated/stt_service.js';
export interface ConnectionOptions {
/**
* The Aristech STT-Server uri e.g. stt.example.com
*/
host?: string;
/**
* Whether to use SSL/TLS. Automatically enabled when rootCert is provided
*/
ssl?: boolean;
/**
* Allows providing a custom root certificate that might not exist
* in the root certificate chain
*/
rootCert?: string;
/**
* Optionally instead of providing a root cert path via `rootCert` the root cert content can be provided directly
*/
rootCertContent?: string;
/**
* Further grpc client options
*/
grpcClientOptions?: grpc.ClientOptions;
/**
* Authentication options.
* **Note:** Can only be used in combination with SSL/TLS.
*/
auth?: {
token: string;
secret: string;
};
/**
* Instead of providing an auth token and secret, an API key can be used.
* The key might also encode information such as the host to connect to.
*/
apiKey?: string;
/**
* The available models for the given credentials might be cached for performance reasons.
* To explicitly disable this, set this to true.
*/
disableModelCaching?: boolean;
}
export declare class SttClient {
private cOptions;
constructor(options?: ConnectionOptions);
/**
* Lists the available models and their specifications.
*/
listModels(request?: DeepPartial<ModelsRequest>): Promise<Model[]>;
/**
* Creates a bidirectional recognition stream.
* @param config The recognition configuration.
* @returns The recognition stream.
*/
recognize(config: DeepPartial<RecognitionConfig>): grpc.ClientDuplexStream<StreamingRecognitionRequest, StreamingRecognitionResponse>;
/**
* Recognizes a wave file.
* This is a convenience method to very easily recognize a wave file.
* @param waveFilePath Path to the wave file.
* @param config The recognition configuration. The sample rate is automatically determined from the wave file. If you don't provide a config, only the locale will be set to 'en' so that the server can determine which model to use. We usually recomment to provide a specific model however.
* @returns The recognition response.
*/
recognizeFile(waveFilePath: string, config?: DeepPartial<RecognitionConfig>): Promise<StreamingRecognitionResponse[]>;
/**
* Lists the available NLP functions and their specifications.
* @param request The NLP functions request.
* @returns The NLP functions response.
*/
listNlpFunctions(request?: DeepPartial<NLPFunctionsRequest>): Promise<NLPFunctionsResponse>;
/**
* Performs NLP processing on the given text.
* @param request The NLP processing request.
* @returns The NLP processing response.
*/
nlpProcess(request: DeepPartial<NLPProcessRequest>): Promise<NLPProcessResponse>;
/**
* Retrieves the account information.
* @param request The account info request.
* @returns The account info response.
*/
accountInfo(request?: DeepPartial<AccountInfoRequest>): Promise<AccountInfoResponse>;
private getClient;
}
/**
* A very simple helper function that reads the sample rate from a wave file (assuming it is a valid wave file with a 44 byte header).
* @param fileName The path to the wave file.
* @returns The sample rate of the wave file in Hz.
*/
export declare function getWaveSampleRate(fileName: string): number;