telnyx 6.71.0 → 6.73.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/client.d.mts +14 -8
- package/client.d.mts.map +1 -1
- package/client.d.ts +14 -8
- package/client.d.ts.map +1 -1
- package/client.js +12 -6
- package/client.js.map +1 -1
- package/client.mjs +12 -6
- package/client.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/ai/ai.d.mts +1 -1
- package/resources/ai/ai.d.mts.map +1 -1
- package/resources/ai/ai.d.ts +1 -1
- package/resources/ai/ai.d.ts.map +1 -1
- package/resources/ai/ai.js +2 -2
- package/resources/ai/ai.js.map +1 -1
- package/resources/ai/ai.mjs +2 -2
- package/resources/ai/ai.mjs.map +1 -1
- package/resources/index.d.mts +3 -2
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +3 -2
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +4 -2
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -0
- package/resources/index.mjs.map +1 -1
- package/resources/sip-registration-status.d.mts +91 -0
- package/resources/sip-registration-status.d.mts.map +1 -0
- package/resources/sip-registration-status.d.ts +91 -0
- package/resources/sip-registration-status.d.ts.map +1 -0
- package/resources/sip-registration-status.js +20 -0
- package/resources/sip-registration-status.js.map +1 -0
- package/resources/sip-registration-status.mjs +16 -0
- package/resources/sip-registration-status.mjs.map +1 -0
- package/resources/speech-to-text/index.d.mts +3 -3
- package/resources/speech-to-text/index.d.mts.map +1 -1
- package/resources/speech-to-text/index.d.ts +3 -3
- package/resources/speech-to-text/index.d.ts.map +1 -1
- package/resources/speech-to-text/index.js +1 -5
- package/resources/speech-to-text/index.js.map +1 -1
- package/resources/speech-to-text/index.mjs +0 -2
- package/resources/speech-to-text/index.mjs.map +1 -1
- package/resources/speech-to-text/internal-base.d.mts +42 -11
- package/resources/speech-to-text/internal-base.d.mts.map +1 -1
- package/resources/speech-to-text/internal-base.d.ts +42 -11
- package/resources/speech-to-text/internal-base.d.ts.map +1 -1
- package/resources/speech-to-text/internal-base.js +5 -9
- package/resources/speech-to-text/internal-base.js.map +1 -1
- package/resources/speech-to-text/internal-base.mjs +5 -9
- package/resources/speech-to-text/internal-base.mjs.map +1 -1
- package/resources/speech-to-text/speech-to-text.d.mts +79 -100
- package/resources/speech-to-text/speech-to-text.d.mts.map +1 -1
- package/resources/speech-to-text/speech-to-text.d.ts +79 -100
- package/resources/speech-to-text/speech-to-text.d.ts.map +1 -1
- package/resources/speech-to-text/speech-to-text.js +16 -19
- package/resources/speech-to-text/speech-to-text.js.map +1 -1
- package/resources/speech-to-text/speech-to-text.mjs +16 -19
- package/resources/speech-to-text/speech-to-text.mjs.map +1 -1
- package/resources/speech-to-text/ws-base.d.mts +106 -0
- package/resources/speech-to-text/ws-base.d.mts.map +1 -0
- package/resources/speech-to-text/ws-base.d.ts +106 -0
- package/resources/speech-to-text/ws-base.d.ts.map +1 -0
- package/resources/speech-to-text/ws-base.js +476 -0
- package/resources/speech-to-text/ws-base.js.map +1 -0
- package/resources/speech-to-text/ws-base.mjs +472 -0
- package/resources/speech-to-text/ws-base.mjs.map +1 -0
- package/resources/speech-to-text/ws.d.mts +9 -28
- package/resources/speech-to-text/ws.d.mts.map +1 -1
- package/resources/speech-to-text/ws.d.ts +9 -28
- package/resources/speech-to-text/ws.d.ts.map +1 -1
- package/resources/speech-to-text/ws.js +17 -97
- package/resources/speech-to-text/ws.js.map +1 -1
- package/resources/speech-to-text/ws.mjs +17 -97
- package/resources/speech-to-text/ws.mjs.map +1 -1
- package/resources/speech-to-text.d.mts +1 -80
- package/resources/speech-to-text.d.mts.map +1 -1
- package/resources/speech-to-text.d.ts +1 -80
- package/resources/speech-to-text.d.ts.map +1 -1
- package/resources/speech-to-text.js +2 -32
- package/resources/speech-to-text.js.map +1 -1
- package/resources/speech-to-text.mjs +1 -30
- package/resources/speech-to-text.mjs.map +1 -1
- package/resources/texml/accounts/calls/calls.d.mts +31 -465
- package/resources/texml/accounts/calls/calls.d.mts.map +1 -1
- package/resources/texml/accounts/calls/calls.d.ts +31 -465
- package/resources/texml/accounts/calls/calls.d.ts.map +1 -1
- package/resources/texml/accounts/calls/calls.js +7 -1
- package/resources/texml/accounts/calls/calls.js.map +1 -1
- package/resources/texml/accounts/calls/calls.mjs +7 -1
- package/resources/texml/accounts/calls/calls.mjs.map +1 -1
- package/resources/text-to-speech/index.d.mts +1 -1
- package/resources/text-to-speech/index.d.mts.map +1 -1
- package/resources/text-to-speech/index.d.ts +1 -1
- package/resources/text-to-speech/index.d.ts.map +1 -1
- package/resources/text-to-speech/index.js.map +1 -1
- package/resources/text-to-speech/index.mjs.map +1 -1
- package/resources/text-to-speech/text-to-speech.d.mts +79 -13
- package/resources/text-to-speech/text-to-speech.d.mts.map +1 -1
- package/resources/text-to-speech/text-to-speech.d.ts +79 -13
- package/resources/text-to-speech/text-to-speech.d.ts.map +1 -1
- package/resources/text-to-speech/text-to-speech.js +33 -1
- package/resources/text-to-speech/text-to-speech.js.map +1 -1
- package/resources/text-to-speech/text-to-speech.mjs +33 -1
- package/resources/text-to-speech/text-to-speech.mjs.map +1 -1
- package/src/client.ts +42 -20
- package/src/resources/ai/ai.ts +3 -3
- package/src/resources/index.ts +10 -2
- package/src/resources/sip-registration-status.ts +123 -0
- package/src/resources/speech-to-text/index.ts +6 -9
- package/src/resources/speech-to-text/internal-base.ts +49 -22
- package/src/resources/speech-to-text/speech-to-text.ts +102 -128
- package/src/resources/speech-to-text/ws-base.ts +619 -0
- package/src/resources/speech-to-text/ws.ts +26 -111
- package/src/resources/speech-to-text.ts +1 -112
- package/src/resources/texml/accounts/calls/calls.ts +36 -564
- package/src/resources/text-to-speech/index.ts +3 -2
- package/src/resources/text-to-speech/text-to-speech.ts +100 -16
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -1,127 +1,42 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
3
|
import * as WS from 'ws';
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
4
|
+
import { NodeWebSocket } from '../../internal/ws-adapter-node';
|
|
5
|
+
import { SpeechToTextWSBase, type SpeechToTextWSBaseOptions } from './ws-base';
|
|
6
6
|
import { Telnyx } from '../../client';
|
|
7
7
|
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
export type { SpeechToTextWSReconnectOptions } from './ws-base';
|
|
9
|
+
|
|
10
|
+
export interface SpeechToTextWSClientOptions extends WS.ClientOptions, SpeechToTextWSBaseOptions {}
|
|
11
|
+
|
|
12
|
+
export class SpeechToTextWS extends SpeechToTextWSBase<NodeWebSocket> {
|
|
13
|
+
private _wsOptions: WS.ClientOptions | null | undefined;
|
|
12
14
|
|
|
13
15
|
constructor(
|
|
14
16
|
client: Telnyx,
|
|
15
|
-
parameters
|
|
16
|
-
options?:
|
|
17
|
+
parameters?: Record<string, unknown> | undefined,
|
|
18
|
+
options?: SpeechToTextWSClientOptions | null | undefined,
|
|
17
19
|
) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
...options,
|
|
23
|
-
headers: {
|
|
24
|
-
...this.authHeaders(),
|
|
25
|
-
...options?.headers,
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
this.socket.on('open', () => {
|
|
30
|
-
// Connection established, ready to send audio
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
this.socket.on('message', (wsEvent) => {
|
|
34
|
-
const event = (() => {
|
|
35
|
-
try {
|
|
36
|
-
return JSON.parse(wsEvent.toString()) as SpeechToTextAPI.SttServerEvent;
|
|
37
|
-
} catch (err) {
|
|
38
|
-
this._onError(null, 'could not parse websocket event', err);
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
})();
|
|
42
|
-
|
|
43
|
-
if (event) {
|
|
44
|
-
this._emit('event', event);
|
|
45
|
-
|
|
46
|
-
if (event.type === 'error') {
|
|
47
|
-
this._onError(event);
|
|
48
|
-
} else {
|
|
49
|
-
// @ts-ignore TS isn't smart enough to get the relationship right here
|
|
50
|
-
this._emit(event.type, event);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
this.socket.on('error', (err) => {
|
|
56
|
-
this._onError(null, err.message, err);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
this.socket.on('close', (code, reason) => {
|
|
60
|
-
// Connection closed
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Send binary audio data to the server for transcription.
|
|
66
|
-
* @param data - Raw audio bytes (mp3 or wav format)
|
|
67
|
-
*/
|
|
68
|
-
send(data: SpeechToTextAPI.SttClientEvent) {
|
|
69
|
-
try {
|
|
70
|
-
this.socket.send(data);
|
|
71
|
-
} catch (err) {
|
|
72
|
-
this._onError(null, 'could not send audio data', err);
|
|
20
|
+
if (!WS?.WebSocket) {
|
|
21
|
+
throw new Error(
|
|
22
|
+
'SpeechToTextWS from "telnyx/resources/speech-to-text/ws" requires the "ws" package but it could not be loaded.',
|
|
23
|
+
);
|
|
73
24
|
}
|
|
74
|
-
}
|
|
75
25
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
try {
|
|
81
|
-
this.socket.close(props?.code ?? 1000, props?.reason ?? 'OK');
|
|
82
|
-
} catch (err) {
|
|
83
|
-
this._onError(null, 'could not close the connection', err);
|
|
84
|
-
}
|
|
26
|
+
const { reconnect, maxQueueSize, ...wsOptions } = options ?? {};
|
|
27
|
+
super(client, parameters, { reconnect, maxQueueSize });
|
|
28
|
+
this._wsOptions = wsOptions;
|
|
29
|
+
this._connectInitial();
|
|
85
30
|
}
|
|
86
31
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Wait for the connection to be established.
|
|
96
|
-
*/
|
|
97
|
-
waitForOpen(): Promise<void> {
|
|
98
|
-
return new Promise((resolve, reject) => {
|
|
99
|
-
if (this.socket.readyState === WS.WebSocket.OPEN) {
|
|
100
|
-
resolve();
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const onOpen = () => {
|
|
105
|
-
this.socket.off('open', onOpen);
|
|
106
|
-
this.socket.off('error', onError);
|
|
107
|
-
resolve();
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const onError = (err: Error) => {
|
|
111
|
-
this.socket.off('open', onOpen);
|
|
112
|
-
this.socket.off('error', onError);
|
|
113
|
-
reject(err);
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
this.socket.on('open', onOpen);
|
|
117
|
-
this.socket.on('error', onError);
|
|
32
|
+
protected _createSocket(url: URL, authHeaders: Record<string, string>): NodeWebSocket {
|
|
33
|
+
const ws = new WS.WebSocket(url, {
|
|
34
|
+
...this._wsOptions,
|
|
35
|
+
headers: {
|
|
36
|
+
...authHeaders,
|
|
37
|
+
...this._wsOptions?.headers,
|
|
38
|
+
},
|
|
118
39
|
});
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
private authHeaders(): Record<string, string> {
|
|
122
|
-
if (this.client.apiKey) {
|
|
123
|
-
return { Authorization: `Bearer ${this.client.apiKey}` };
|
|
124
|
-
}
|
|
125
|
-
return {};
|
|
40
|
+
return new NodeWebSocket(ws);
|
|
126
41
|
}
|
|
127
42
|
}
|
|
@@ -1,114 +1,3 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
import { APIPromise } from '../core/api-promise';
|
|
5
|
-
import { RequestOptions } from '../internal/request-options';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Discover available speech-to-text providers, models, and supported languages.
|
|
9
|
-
*/
|
|
10
|
-
export class SpeechToText extends APIResource {
|
|
11
|
-
/**
|
|
12
|
-
* Retrieve the canonical list of supported speech-to-text providers, models,
|
|
13
|
-
* accepted language codes, and the service types each model supports.
|
|
14
|
-
*
|
|
15
|
-
* Service types:
|
|
16
|
-
*
|
|
17
|
-
* - `streaming` — standalone WebSocket transcription via
|
|
18
|
-
* `/speech-to-text/transcription`.
|
|
19
|
-
* - `file_transcription` — file-based transcription via
|
|
20
|
-
* `/ai/audio/transcriptions`.
|
|
21
|
-
* - `in_call_transcription` — live call transcription via Call Control
|
|
22
|
-
* `transcription_start`.
|
|
23
|
-
*
|
|
24
|
-
* Use this endpoint to discover which (provider, model) combinations are available
|
|
25
|
-
* for the surface you need, and which language codes each accepts. `auto` in a
|
|
26
|
-
* `languages` array indicates the provider performs language detection.
|
|
27
|
-
*/
|
|
28
|
-
listProviders(
|
|
29
|
-
query: SpeechToTextListProvidersParams | null | undefined = {},
|
|
30
|
-
options?: RequestOptions,
|
|
31
|
-
): APIPromise<SpeechToTextListProvidersResponse> {
|
|
32
|
-
return this._client.get('/speech-to-text/providers', {
|
|
33
|
-
query,
|
|
34
|
-
defaultBaseURL: 'https://api.telnyx.com/v2',
|
|
35
|
-
...options,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* List of supported STT providers and models.
|
|
42
|
-
*/
|
|
43
|
-
export interface SpeechToTextListProvidersResponse {
|
|
44
|
-
data: Array<SpeechToTextListProvidersResponse.Data>;
|
|
45
|
-
|
|
46
|
-
meta: SpeechToTextListProvidersResponse.Meta;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export namespace SpeechToTextListProvidersResponse {
|
|
50
|
-
/**
|
|
51
|
-
* A (provider, model) tuple along with its supported service types and languages.
|
|
52
|
-
*/
|
|
53
|
-
export interface Data {
|
|
54
|
-
/**
|
|
55
|
-
* Languages this (provider, model) accepts, in the provider's native code format.
|
|
56
|
-
* `auto` indicates the provider performs language detection.
|
|
57
|
-
*/
|
|
58
|
-
languages: Array<string>;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Provider-scoped model name.
|
|
62
|
-
*/
|
|
63
|
-
model: string;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* STT provider name.
|
|
67
|
-
*/
|
|
68
|
-
provider: string;
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Service surfaces this (provider, model) supports.
|
|
72
|
-
*/
|
|
73
|
-
service_types: Array<'streaming' | 'file_transcription' | 'in_call_transcription'>;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export interface Meta {
|
|
77
|
-
/**
|
|
78
|
-
* Total number of entries returned.
|
|
79
|
-
*/
|
|
80
|
-
total: number;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export interface SpeechToTextListProvidersParams {
|
|
85
|
-
/**
|
|
86
|
-
* Filter to entries for a specific STT provider. The enum mirrors the providers
|
|
87
|
-
* advertised across the speech-to-text spec (including `google` and `telnyx`,
|
|
88
|
-
* which are accepted as WebSocket transcription engines). A provider that has no
|
|
89
|
-
* models currently registered for any service type will return an empty `data`
|
|
90
|
-
* array rather than an error.
|
|
91
|
-
*/
|
|
92
|
-
provider?:
|
|
93
|
-
| 'deepgram'
|
|
94
|
-
| 'speechmatics'
|
|
95
|
-
| 'assemblyai'
|
|
96
|
-
| 'xai'
|
|
97
|
-
| 'soniox'
|
|
98
|
-
| 'azure'
|
|
99
|
-
| 'openai'
|
|
100
|
-
| 'google'
|
|
101
|
-
| 'telnyx';
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Filter to entries that support the given service type.
|
|
105
|
-
*/
|
|
106
|
-
service_type?: 'streaming' | 'file_transcription' | 'in_call_transcription';
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export declare namespace SpeechToText {
|
|
110
|
-
export {
|
|
111
|
-
type SpeechToTextListProvidersResponse as SpeechToTextListProvidersResponse,
|
|
112
|
-
type SpeechToTextListProvidersParams as SpeechToTextListProvidersParams,
|
|
113
|
-
};
|
|
114
|
-
}
|
|
3
|
+
export * from './speech-to-text/index';
|