@gladiaio/sdk
Version:
Gladia JavaScript/TypeScript SDK
41 lines (39 loc) • 1.17 kB
JavaScript
import { HttpClient } from "../../network/httpClient.js";
import { WebSocketClient } from "../../network/wsClient.js";
import { LiveV2Session } from "./session.js";
//#region src/v2/live/client.ts
/**
* Client used to interact with Gladia Live Speech-To-Text API.
*/
var LiveV2Client = class {
httpClient;
webSocketClient;
constructor(options) {
const httpBaseUrl = new URL(options.apiUrl);
httpBaseUrl.protocol = httpBaseUrl.protocol.replace(/^ws/, "http");
this.httpClient = new HttpClient({
baseUrl: httpBaseUrl,
headers: options.httpHeaders,
...options.region ? { queryParams: { region: options.region } } : {},
retry: options.httpRetry,
timeout: options.httpTimeout
});
const wsBaseUrl = new URL(options.apiUrl);
wsBaseUrl.protocol = wsBaseUrl.protocol.replace(/^http/, "ws");
this.webSocketClient = new WebSocketClient({
baseUrl: wsBaseUrl,
retry: options.wsRetry,
timeout: options.wsTimeout
});
}
startSession(options) {
return new LiveV2Session({
options,
httpClient: this.httpClient,
webSocketClient: this.webSocketClient
});
}
};
//#endregion
export { LiveV2Client };
//# sourceMappingURL=client.js.map