@aristech-org/tts-client
Version:
A Node.js client library for the Aristech Text-to-Speech API
87 lines (86 loc) • 3.43 kB
TypeScript
import * as grpc from '@grpc/grpc-js';
import { ClearCacheRequest, ClearCacheResponse, PhonesetRequest, PhonesetResponse, SpeechRequest, SpeechResponse, SsmlDocumentationRequest, SsmlDocumentationResponse, TranscriptionRequest, TranscriptionResponse, VoiceListRequest } from './generated/TTSServices.js';
import { DeepPartial, Voice } from './generated/TTSTypes.js';
export * from './generated/TTSTypes.js';
export { PhonesetRequest, PhonesetResponse, SpeechRequest, SpeechResponse, SpeechServiceClient, SsmlDocumentationRequest, SsmlDocumentationResponse, TranscriptionRequest, TranscriptionResponse, VoiceListRequest } from './generated/TTSServices.js';
export type Stream = grpc.ClientReadableStream<SpeechResponse>;
export interface ConnectionOptions {
/**
* The Aristech TTS-Server uri e.g. tts.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;
};
}
export declare class TtsClient {
private cOptions;
constructor(options: ConnectionOptions);
/**
* Lists all available voices.
*/
listVoices(request?: DeepPartial<VoiceListRequest>): Promise<Array<Voice>>;
/**
* Creates a stream of audio data from the given text.
* @param request The request object
* @returns The response stream
*/
streamAudio(request: DeepPartial<SpeechRequest>): Promise<Stream>;
/**
* Creates an audio buffer from the given text.
* @param request The request object
* @returns The audio buffer
*/
synthesize(request: DeepPartial<SpeechRequest>): Promise<Buffer>;
/**
* This is an alias for the `synthesize` method.
*/
audioBuffer(request: DeepPartial<SpeechRequest>): Promise<Buffer>;
/**
* Retrieves the phoneset for the given voice.
* @param request The request object
* @returns The phoneset response
*/
getPhoneset(request: DeepPartial<PhonesetRequest>): Promise<PhonesetResponse>;
/**
* Retrieves the transcription for the given request.
* @param request The request object
* @returns The transcription response
*/
getTranscription(request: DeepPartial<TranscriptionRequest>): Promise<TranscriptionResponse>;
/**
* Clears the cache of the server, removing all cached audio data.
* @param request The request object
* @returns The clear cache response
*/
clearCache(request?: DeepPartial<ClearCacheRequest>): Promise<ClearCacheResponse>;
/**
* Retrieves SSML documentation for a specific voice.
* @param request The request object containing voice_id and optional locale
* @returns The SSML documentation response
*/
getSsmlDocumentation(request: DeepPartial<SsmlDocumentationRequest>): Promise<SsmlDocumentationResponse>;
private getClient;
}