@deepgram/sdk 3.0.0 → 3.1.3
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/dist/main/DeepgramClient.d.ts +14 -1
- package/dist/main/DeepgramClient.d.ts.map +1 -1
- package/dist/main/DeepgramClient.js +31 -1
- package/dist/main/DeepgramClient.js.map +1 -1
- package/dist/main/index.d.ts +10 -1
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js +14 -1
- package/dist/main/index.js.map +1 -1
- package/dist/main/lib/enums/LiveTranscriptionEvents.d.ts +3 -1
- package/dist/main/lib/enums/LiveTranscriptionEvents.d.ts.map +1 -1
- package/dist/main/lib/enums/LiveTranscriptionEvents.js +2 -0
- package/dist/main/lib/enums/LiveTranscriptionEvents.js.map +1 -1
- package/dist/main/lib/errors.d.ts +3 -0
- package/dist/main/lib/errors.d.ts.map +1 -1
- package/dist/main/lib/errors.js +8 -1
- package/dist/main/lib/errors.js.map +1 -1
- package/dist/main/lib/helpers.d.ts +3 -2
- package/dist/main/lib/helpers.d.ts.map +1 -1
- package/dist/main/lib/helpers.js +7 -1
- package/dist/main/lib/helpers.js.map +1 -1
- package/dist/main/lib/types/AnalyzeSchema.d.ts +18 -0
- package/dist/main/lib/types/AnalyzeSchema.d.ts.map +1 -0
- package/dist/main/lib/types/{PrerecordedSource.js → AnalyzeSchema.js} +1 -1
- package/dist/main/lib/types/AnalyzeSchema.js.map +1 -0
- package/dist/main/lib/types/AsyncAnalyzeResponse.d.ts +4 -0
- package/dist/main/lib/types/AsyncAnalyzeResponse.d.ts.map +1 -0
- package/dist/main/lib/types/AsyncAnalyzeResponse.js +3 -0
- package/dist/main/lib/types/AsyncAnalyzeResponse.js.map +1 -0
- package/dist/main/lib/types/{PrerecordedSource.d.ts → DeepgramSource.d.ts} +5 -1
- package/dist/main/lib/types/DeepgramSource.d.ts.map +1 -0
- package/dist/main/lib/types/DeepgramSource.js +3 -0
- package/dist/main/lib/types/DeepgramSource.js.map +1 -0
- package/dist/main/lib/types/LiveTranscriptionEvent.d.ts +1 -1
- package/dist/main/lib/types/LiveTranscriptionEvent.d.ts.map +1 -1
- package/dist/main/lib/types/SpeechStartedEvent.d.ts +6 -0
- package/dist/main/lib/types/SpeechStartedEvent.d.ts.map +1 -0
- package/dist/main/lib/types/SpeechStartedEvent.js +3 -0
- package/dist/main/lib/types/SpeechStartedEvent.js.map +1 -0
- package/dist/main/lib/types/SyncAnalyzeResponse.d.ts +76 -0
- package/dist/main/lib/types/SyncAnalyzeResponse.d.ts.map +1 -0
- package/dist/main/lib/types/SyncAnalyzeResponse.js +3 -0
- package/dist/main/lib/types/SyncAnalyzeResponse.js.map +1 -0
- package/dist/main/lib/types/SyncPrerecordedResponse.d.ts +63 -1
- package/dist/main/lib/types/SyncPrerecordedResponse.d.ts.map +1 -1
- package/dist/main/lib/types/TranscriptionSchema.d.ts +67 -2
- package/dist/main/lib/types/TranscriptionSchema.d.ts.map +1 -1
- package/dist/main/lib/types/UtteranceEndEvent.d.ts +6 -0
- package/dist/main/lib/types/UtteranceEndEvent.d.ts.map +1 -0
- package/dist/main/lib/types/UtteranceEndEvent.js +3 -0
- package/dist/main/lib/types/UtteranceEndEvent.js.map +1 -0
- package/dist/main/lib/types/index.d.ts +6 -1
- package/dist/main/lib/types/index.d.ts.map +1 -1
- package/dist/main/lib/version.d.ts +1 -1
- package/dist/main/lib/version.js +1 -1
- package/dist/main/packages/AbstractClient.d.ts.map +1 -1
- package/dist/main/packages/AbstractClient.js +23 -7
- package/dist/main/packages/AbstractClient.js.map +1 -1
- package/dist/main/packages/AbstractRestfulClient.d.ts +1 -0
- package/dist/main/packages/AbstractRestfulClient.d.ts.map +1 -1
- package/dist/main/packages/AbstractRestfulClient.js +6 -1
- package/dist/main/packages/AbstractRestfulClient.js.map +1 -1
- package/dist/main/packages/LiveClient.d.ts.map +1 -1
- package/dist/main/packages/LiveClient.js +6 -9
- package/dist/main/packages/LiveClient.js.map +1 -1
- package/dist/main/packages/PrerecordedClient.js +2 -2
- package/dist/main/packages/PrerecordedClient.js.map +1 -1
- package/dist/main/packages/ReadClient.d.ts +10 -0
- package/dist/main/packages/ReadClient.d.ts.map +1 -0
- package/dist/main/packages/ReadClient.js +123 -0
- package/dist/main/packages/ReadClient.js.map +1 -0
- package/dist/module/DeepgramClient.d.ts +14 -1
- package/dist/module/DeepgramClient.d.ts.map +1 -1
- package/dist/module/DeepgramClient.js +31 -1
- package/dist/module/DeepgramClient.js.map +1 -1
- package/dist/module/index.d.ts +10 -1
- package/dist/module/index.d.ts.map +1 -1
- package/dist/module/index.js +13 -1
- package/dist/module/index.js.map +1 -1
- package/dist/module/lib/enums/LiveTranscriptionEvents.d.ts +3 -1
- package/dist/module/lib/enums/LiveTranscriptionEvents.d.ts.map +1 -1
- package/dist/module/lib/enums/LiveTranscriptionEvents.js +2 -0
- package/dist/module/lib/enums/LiveTranscriptionEvents.js.map +1 -1
- package/dist/module/lib/errors.d.ts +3 -0
- package/dist/module/lib/errors.d.ts.map +1 -1
- package/dist/module/lib/errors.js +6 -0
- package/dist/module/lib/errors.js.map +1 -1
- package/dist/module/lib/helpers.d.ts +3 -2
- package/dist/module/lib/helpers.d.ts.map +1 -1
- package/dist/module/lib/helpers.js +5 -0
- package/dist/module/lib/helpers.js.map +1 -1
- package/dist/module/lib/types/AnalyzeSchema.d.ts +18 -0
- package/dist/module/lib/types/AnalyzeSchema.d.ts.map +1 -0
- package/dist/module/lib/types/AnalyzeSchema.js +2 -0
- package/dist/module/lib/types/AnalyzeSchema.js.map +1 -0
- package/dist/module/lib/types/AsyncAnalyzeResponse.d.ts +4 -0
- package/dist/module/lib/types/AsyncAnalyzeResponse.d.ts.map +1 -0
- package/dist/module/lib/types/AsyncAnalyzeResponse.js +2 -0
- package/dist/module/lib/types/AsyncAnalyzeResponse.js.map +1 -0
- package/dist/module/lib/types/{PrerecordedSource.d.ts → DeepgramSource.d.ts} +5 -1
- package/dist/module/lib/types/DeepgramSource.d.ts.map +1 -0
- package/dist/module/lib/types/DeepgramSource.js +2 -0
- package/dist/module/lib/types/DeepgramSource.js.map +1 -0
- package/dist/module/lib/types/LiveTranscriptionEvent.d.ts +1 -1
- package/dist/module/lib/types/LiveTranscriptionEvent.d.ts.map +1 -1
- package/dist/module/lib/types/SpeechStartedEvent.d.ts +6 -0
- package/dist/module/lib/types/SpeechStartedEvent.d.ts.map +1 -0
- package/dist/module/lib/types/SpeechStartedEvent.js +2 -0
- package/dist/module/lib/types/SpeechStartedEvent.js.map +1 -0
- package/dist/module/lib/types/SyncAnalyzeResponse.d.ts +76 -0
- package/dist/module/lib/types/SyncAnalyzeResponse.d.ts.map +1 -0
- package/dist/module/lib/types/SyncAnalyzeResponse.js +2 -0
- package/dist/module/lib/types/SyncAnalyzeResponse.js.map +1 -0
- package/dist/module/lib/types/SyncPrerecordedResponse.d.ts +63 -1
- package/dist/module/lib/types/SyncPrerecordedResponse.d.ts.map +1 -1
- package/dist/module/lib/types/TranscriptionSchema.d.ts +67 -2
- package/dist/module/lib/types/TranscriptionSchema.d.ts.map +1 -1
- package/dist/module/lib/types/UtteranceEndEvent.d.ts +6 -0
- package/dist/module/lib/types/UtteranceEndEvent.d.ts.map +1 -0
- package/dist/module/lib/types/UtteranceEndEvent.js +2 -0
- package/dist/module/lib/types/UtteranceEndEvent.js.map +1 -0
- package/dist/module/lib/types/index.d.ts +6 -1
- package/dist/module/lib/types/index.d.ts.map +1 -1
- package/dist/module/lib/version.d.ts +1 -1
- package/dist/module/lib/version.js +1 -1
- package/dist/module/packages/AbstractClient.d.ts.map +1 -1
- package/dist/module/packages/AbstractClient.js +23 -7
- package/dist/module/packages/AbstractClient.js.map +1 -1
- package/dist/module/packages/AbstractRestfulClient.d.ts +1 -0
- package/dist/module/packages/AbstractRestfulClient.d.ts.map +1 -1
- package/dist/module/packages/AbstractRestfulClient.js +6 -1
- package/dist/module/packages/AbstractRestfulClient.js.map +1 -1
- package/dist/module/packages/LiveClient.d.ts.map +1 -1
- package/dist/module/packages/LiveClient.js +6 -9
- package/dist/module/packages/LiveClient.js.map +1 -1
- package/dist/module/packages/PrerecordedClient.js +2 -2
- package/dist/module/packages/PrerecordedClient.js.map +1 -1
- package/dist/module/packages/ReadClient.d.ts +10 -0
- package/dist/module/packages/ReadClient.d.ts.map +1 -0
- package/dist/module/packages/ReadClient.js +119 -0
- package/dist/module/packages/ReadClient.js.map +1 -0
- package/dist/umd/deepgram.js +1 -1
- package/package.json +1 -1
- package/src/DeepgramClient.ts +39 -1
- package/src/index.ts +11 -1
- package/src/lib/enums/LiveTranscriptionEvents.ts +2 -0
- package/src/lib/errors.ts +10 -0
- package/src/lib/helpers.ts +19 -2
- package/src/lib/types/AnalyzeSchema.ts +28 -0
- package/src/lib/types/AsyncAnalyzeResponse.ts +3 -0
- package/src/lib/types/{PrerecordedSource.ts → DeepgramSource.ts} +6 -0
- package/src/lib/types/LiveTranscriptionEvent.ts +1 -1
- package/src/lib/types/SpeechStartedEvent.ts +5 -0
- package/src/lib/types/SyncAnalyzeResponse.ts +88 -0
- package/src/lib/types/SyncPrerecordedResponse.ts +74 -1
- package/src/lib/types/TranscriptionSchema.ts +82 -2
- package/src/lib/types/UtteranceEndEvent.ts +5 -0
- package/src/lib/types/index.ts +12 -1
- package/src/lib/version.ts +1 -1
- package/src/packages/AbstractClient.ts +31 -6
- package/src/packages/AbstractRestfulClient.ts +7 -1
- package/src/packages/LiveClient.ts +10 -11
- package/src/packages/PrerecordedClient.ts +2 -2
- package/src/packages/ReadClient.ts +161 -0
- package/dist/main/lib/types/PrerecordedSource.d.ts.map +0 -1
- package/dist/main/lib/types/PrerecordedSource.js.map +0 -1
- package/dist/module/lib/types/PrerecordedSource.d.ts.map +0 -1
- package/dist/module/lib/types/PrerecordedSource.js +0 -2
- package/dist/module/lib/types/PrerecordedSource.js.map +0 -1
|
@@ -18,6 +18,7 @@ interface Channel {
|
|
|
18
18
|
search?: Search[];
|
|
19
19
|
alternatives: Alternative[];
|
|
20
20
|
detected_language?: string;
|
|
21
|
+
language_confidence?: number;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
interface Entity {
|
|
@@ -43,8 +44,15 @@ interface Metadata {
|
|
|
43
44
|
duration: number;
|
|
44
45
|
channels: number;
|
|
45
46
|
models: string[];
|
|
46
|
-
model_info: Record<string, ModelInfo>;
|
|
47
47
|
warnings?: Warning[];
|
|
48
|
+
model_info: Record<string, ModelInfo>;
|
|
49
|
+
summary_info?: SummaryInfo;
|
|
50
|
+
intents_info?: IntentsInfo;
|
|
51
|
+
sentiment_info?: SentimentInfo;
|
|
52
|
+
topics_info?: TopicsInfo;
|
|
53
|
+
extra: {
|
|
54
|
+
[key: string]: unknown;
|
|
55
|
+
};
|
|
48
56
|
}
|
|
49
57
|
|
|
50
58
|
interface ModelInfo {
|
|
@@ -53,6 +61,30 @@ interface ModelInfo {
|
|
|
53
61
|
arch: string;
|
|
54
62
|
}
|
|
55
63
|
|
|
64
|
+
interface SummaryInfo {
|
|
65
|
+
input_tokens: number;
|
|
66
|
+
output_tokens: number;
|
|
67
|
+
model_uuid: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
interface IntentsInfo {
|
|
71
|
+
model_uuid: string;
|
|
72
|
+
input_tokens: number;
|
|
73
|
+
output_tokens: number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
interface SentimentInfo {
|
|
77
|
+
model_uuid: string;
|
|
78
|
+
input_tokens: number;
|
|
79
|
+
output_tokens: number;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
interface TopicsInfo {
|
|
83
|
+
model_uuid: string;
|
|
84
|
+
input_tokens: number;
|
|
85
|
+
output_tokens: number;
|
|
86
|
+
}
|
|
87
|
+
|
|
56
88
|
interface Paragraph {
|
|
57
89
|
sentences: Sentence[];
|
|
58
90
|
start: number;
|
|
@@ -69,6 +101,47 @@ interface Result {
|
|
|
69
101
|
channels: Channel[];
|
|
70
102
|
utterances?: Utterance[];
|
|
71
103
|
summary?: TranscriptionSummary;
|
|
104
|
+
sentiments?: Sentiments;
|
|
105
|
+
topics?: Topics;
|
|
106
|
+
intents?: Intents;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
interface Sentiments {
|
|
110
|
+
segments: Segment[];
|
|
111
|
+
average: Average;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
interface Topics {
|
|
115
|
+
segments: Segment[];
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
interface Intents {
|
|
119
|
+
segments: Segment[];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
interface Intent {
|
|
123
|
+
intent: string;
|
|
124
|
+
confidence_score: number;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
interface Average {
|
|
128
|
+
sentiment: string;
|
|
129
|
+
sentiment_score: number;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
interface Topic {
|
|
133
|
+
topic: string;
|
|
134
|
+
confidence_score: number;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
interface Segment {
|
|
138
|
+
text: string;
|
|
139
|
+
start_word: number;
|
|
140
|
+
end_word: number;
|
|
141
|
+
sentiment?: string;
|
|
142
|
+
sentiment_score?: number;
|
|
143
|
+
topics?: Topic[];
|
|
144
|
+
intents?: Intent[];
|
|
72
145
|
}
|
|
73
146
|
|
|
74
147
|
interface Search {
|
|
@@ -8,6 +8,7 @@ interface TranscriptionSchema extends Record<string, unknown> {
|
|
|
8
8
|
model?: string;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
+
* @deprecated
|
|
11
12
|
* @see https://developers.deepgram.com/docs/tier
|
|
12
13
|
*/
|
|
13
14
|
tier?: string;
|
|
@@ -42,11 +43,21 @@ interface TranscriptionSchema extends Record<string, unknown> {
|
|
|
42
43
|
*/
|
|
43
44
|
diarize?: boolean;
|
|
44
45
|
|
|
46
|
+
/**
|
|
47
|
+
* @see https://developers.deepgram.com/docs/diarization
|
|
48
|
+
*/
|
|
49
|
+
diarize_version?: string;
|
|
50
|
+
|
|
45
51
|
/**
|
|
46
52
|
* @see https://developers.deepgram.com/docs/smart-format
|
|
47
53
|
*/
|
|
48
54
|
smart_format?: boolean;
|
|
49
55
|
|
|
56
|
+
/**
|
|
57
|
+
* @see https://developers.deepgram.com/docs/filler-words
|
|
58
|
+
*/
|
|
59
|
+
filler_words?: boolean;
|
|
60
|
+
|
|
50
61
|
/**
|
|
51
62
|
* @see https://developers.deepgram.com/docs/multichannel
|
|
52
63
|
*/
|
|
@@ -73,6 +84,11 @@ interface TranscriptionSchema extends Record<string, unknown> {
|
|
|
73
84
|
*/
|
|
74
85
|
callback?: string;
|
|
75
86
|
|
|
87
|
+
/**
|
|
88
|
+
* @see https://developers.deepgram.com/docs/callback#results
|
|
89
|
+
*/
|
|
90
|
+
callback_method?: string;
|
|
91
|
+
|
|
76
92
|
/**
|
|
77
93
|
* @see https://developers.deepgram.com/docs/keywords
|
|
78
94
|
*/
|
|
@@ -83,6 +99,46 @@ interface TranscriptionSchema extends Record<string, unknown> {
|
|
|
83
99
|
*/
|
|
84
100
|
tag?: string[];
|
|
85
101
|
|
|
102
|
+
/**
|
|
103
|
+
* As yet unreleased.
|
|
104
|
+
*/
|
|
105
|
+
sentiment?: boolean;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* As yet unreleased.
|
|
109
|
+
*/
|
|
110
|
+
intents?: boolean;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* As yet unreleased.
|
|
114
|
+
*/
|
|
115
|
+
custom_intent?: string[] | string;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* As yet unreleased.
|
|
119
|
+
*/
|
|
120
|
+
custom_intent_mode?: "strict" | "extended";
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* As yet unreleased.
|
|
124
|
+
*/
|
|
125
|
+
topics?: boolean;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* As yet unreleased.
|
|
129
|
+
*/
|
|
130
|
+
custom_topic?: string[] | string;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* As yet unreleased.
|
|
134
|
+
*/
|
|
135
|
+
custom_topic_mode?: "strict" | "extended";
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @see https://developers.deepgram.com/docs/extra
|
|
139
|
+
*/
|
|
140
|
+
extra?: boolean;
|
|
141
|
+
|
|
86
142
|
[key: string]: unknown;
|
|
87
143
|
}
|
|
88
144
|
|
|
@@ -103,7 +159,11 @@ interface PrerecordedSchema extends TranscriptionSchema {
|
|
|
103
159
|
detect_topics?: boolean;
|
|
104
160
|
|
|
105
161
|
/**
|
|
106
|
-
*
|
|
162
|
+
* Alternatives will run your transcription X number of times and return
|
|
163
|
+
* that many variations of the transcription, allowing for the selection
|
|
164
|
+
* of the most accurate. Cost increases by number of alternatives.
|
|
165
|
+
*
|
|
166
|
+
* @deprecated
|
|
107
167
|
*/
|
|
108
168
|
alternatives?: number;
|
|
109
169
|
|
|
@@ -126,6 +186,16 @@ interface PrerecordedSchema extends TranscriptionSchema {
|
|
|
126
186
|
* @see https://developers.deepgram.com/docs/utterance-split
|
|
127
187
|
*/
|
|
128
188
|
utt_split?: number;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* @see https://developers.deepgram.com/docs/smart-format#dictation
|
|
192
|
+
*/
|
|
193
|
+
dictation?: boolean;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* @see https://developers.deepgram.com/docs/smart-format#measurements
|
|
197
|
+
*/
|
|
198
|
+
measurements?: boolean;
|
|
129
199
|
}
|
|
130
200
|
|
|
131
201
|
interface LiveSchema extends TranscriptionSchema {
|
|
@@ -147,12 +217,22 @@ interface LiveSchema extends TranscriptionSchema {
|
|
|
147
217
|
/**
|
|
148
218
|
* @see https://developers.deepgram.com/docs/endpointing
|
|
149
219
|
*/
|
|
150
|
-
endpointing?: number;
|
|
220
|
+
endpointing?: false | number;
|
|
151
221
|
|
|
152
222
|
/**
|
|
153
223
|
* @see https://developers.deepgram.com/docs/interim-results
|
|
154
224
|
*/
|
|
155
225
|
interim_results?: boolean;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* @see https://developers.deepgram.com/docs/understanding-end-of-speech-detection
|
|
229
|
+
*/
|
|
230
|
+
utterance_end_ms?: number;
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* @see https://developers.deepgram.com/docs/start-of-speech-detection
|
|
234
|
+
*/
|
|
235
|
+
vad_events?: boolean;
|
|
156
236
|
}
|
|
157
237
|
|
|
158
238
|
export type { TranscriptionSchema, PrerecordedSchema, LiveSchema };
|
package/src/lib/types/index.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
export type { AnalyzeSchema } from "./AnalyzeSchema";
|
|
1
2
|
export type { AsyncPrerecordedResponse } from "./AsyncPrerecordedResponse";
|
|
3
|
+
export type { AsyncAnalyzeResponse } from "./AsyncAnalyzeResponse";
|
|
2
4
|
export type { CreateOnPremCredentialsSchema } from "./CreateOnPremCredentialsSchema";
|
|
3
5
|
export type { CreateProjectKeySchema } from "./CreateProjectKeySchema";
|
|
4
6
|
export type { CreateProjectKeyResponse } from "./CreateProjectKeyResponse";
|
|
@@ -32,10 +34,19 @@ export type { LiveConfigOptions } from "./LiveConfigOptions";
|
|
|
32
34
|
export type { LiveMetadataEvent } from "./LiveMetadataEvent";
|
|
33
35
|
export type { LiveTranscriptionEvent } from "./LiveTranscriptionEvent";
|
|
34
36
|
export type { MessageResponse } from "./MessageResponse";
|
|
35
|
-
export type {
|
|
37
|
+
export type {
|
|
38
|
+
FileSource,
|
|
39
|
+
PrerecordedSource,
|
|
40
|
+
UrlSource,
|
|
41
|
+
TextSource,
|
|
42
|
+
AnalyzeSource,
|
|
43
|
+
} from "./DeepgramSource";
|
|
36
44
|
export type { SendProjectInviteSchema } from "./SendProjectInviteSchema";
|
|
45
|
+
export type { SpeechStartedEvent } from "./SpeechStartedEvent";
|
|
37
46
|
export type { SyncPrerecordedResponse } from "./SyncPrerecordedResponse";
|
|
47
|
+
export type { SyncAnalyzeResponse } from "./SyncAnalyzeResponse";
|
|
38
48
|
export type { TranscriptionSchema, PrerecordedSchema, LiveSchema } from "./TranscriptionSchema";
|
|
39
49
|
export type { UpdateProjectMemberScopeSchema } from "./UpdateProjectMemberScopeSchema";
|
|
40
50
|
export type { UpdateProjectSchema } from "./UpdateProjectSchema";
|
|
51
|
+
export type { UtteranceEndEvent } from "./UtteranceEndEvent";
|
|
41
52
|
export type { VoidResponse } from "./VoidResponse";
|
package/src/lib/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "3.
|
|
1
|
+
export const version = "3.1.3";
|
|
@@ -31,21 +31,46 @@ export abstract class AbstractClient {
|
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
let baseUrlString: string = this.options.global.url;
|
|
35
|
+
let proxyUrlString: string;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Check if the base URL provided is missing a protocol and warn in the console.
|
|
39
|
+
*/
|
|
40
|
+
if (!baseUrlString.startsWith("http") && !baseUrlString.startsWith("ws")) {
|
|
41
|
+
console.warn(
|
|
42
|
+
`The base URL provided does not begin with http, https, ws, or wss and will default to https as standard.`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Applying proxy to base URL.
|
|
48
|
+
*/
|
|
49
|
+
if (this.options.restProxy?.url) {
|
|
50
|
+
/**
|
|
51
|
+
* Prevent client using a real API key when using a proxy configuration.
|
|
52
|
+
*/
|
|
35
53
|
if (this.key !== "proxy") {
|
|
36
54
|
throw new DeepgramError(
|
|
37
55
|
`Do not attempt to pass any other API key than the string "proxy" when making proxied REST requests. Please ensure your proxy application is responsible for writing our API key to the Authorization header.`
|
|
38
56
|
);
|
|
39
57
|
}
|
|
40
58
|
|
|
41
|
-
|
|
59
|
+
proxyUrlString = this.options.restProxy.url;
|
|
42
60
|
|
|
43
|
-
|
|
44
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Check if the proxy URL provided is missing a protocol and warn in the console.
|
|
63
|
+
*/
|
|
64
|
+
if (!proxyUrlString.startsWith("http") && !proxyUrlString.startsWith("ws")) {
|
|
65
|
+
console.warn(
|
|
66
|
+
`The proxy URL provided does not begin with http, https, ws, or wss and will default to https as standard.`
|
|
67
|
+
);
|
|
45
68
|
}
|
|
46
|
-
|
|
47
|
-
|
|
69
|
+
|
|
70
|
+
baseUrlString = proxyUrlString;
|
|
48
71
|
}
|
|
72
|
+
|
|
73
|
+
this.baseUrl = this.resolveBaseUrl(baseUrlString);
|
|
49
74
|
}
|
|
50
75
|
|
|
51
76
|
protected resolveBaseUrl(url: string) {
|
|
@@ -12,7 +12,7 @@ export abstract class AbstractRestfulClient extends AbstractClient {
|
|
|
12
12
|
constructor(protected key: string, protected options: DeepgramClientOptions) {
|
|
13
13
|
super(key, options);
|
|
14
14
|
|
|
15
|
-
if (isBrowser() && !this.
|
|
15
|
+
if (isBrowser() && !this._willProxy()) {
|
|
16
16
|
throw new DeepgramError(
|
|
17
17
|
"Due to CORS we are unable to support REST-based API calls to our API from the browser. Please consider using a proxy, and including a `restProxy: { url: ''}` in your Deepgram client options."
|
|
18
18
|
);
|
|
@@ -130,4 +130,10 @@ export abstract class AbstractRestfulClient extends AbstractClient {
|
|
|
130
130
|
): Promise<any> {
|
|
131
131
|
return this._handleRequest(fetcher, "DELETE", url, headers, parameters);
|
|
132
132
|
}
|
|
133
|
+
|
|
134
|
+
private _willProxy() {
|
|
135
|
+
const proxyUrl = this.options.restProxy?.url;
|
|
136
|
+
|
|
137
|
+
return !!proxyUrl;
|
|
138
|
+
}
|
|
133
139
|
}
|
|
@@ -11,6 +11,8 @@ import type {
|
|
|
11
11
|
LiveMetadataEvent,
|
|
12
12
|
LiveTranscriptionEvent,
|
|
13
13
|
DeepgramClientOptions,
|
|
14
|
+
UtteranceEndEvent,
|
|
15
|
+
SpeechStartedEvent,
|
|
14
16
|
} from "../lib/types";
|
|
15
17
|
|
|
16
18
|
export class LiveClient extends AbstractWsClient {
|
|
@@ -35,17 +37,6 @@ export class LiveClient extends AbstractWsClient {
|
|
|
35
37
|
};
|
|
36
38
|
|
|
37
39
|
this._socket.onclose = (event: any) => {
|
|
38
|
-
/**
|
|
39
|
-
* changing the event.target to any to access the private _req
|
|
40
|
-
* property that isn't available on the WebSocket.CloseEvent type
|
|
41
|
-
**/
|
|
42
|
-
const newTarget: any = event.target;
|
|
43
|
-
|
|
44
|
-
if (newTarget["_req"]) {
|
|
45
|
-
const dgErrorIndex = newTarget["_req"].res.rawHeaders.indexOf("dg-error");
|
|
46
|
-
event.reason = newTarget["_req"].res.rawHeaders[dgErrorIndex + 1];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
40
|
this.emit(LiveTranscriptionEvents.Close, event);
|
|
50
41
|
};
|
|
51
42
|
|
|
@@ -64,6 +55,14 @@ export class LiveClient extends AbstractWsClient {
|
|
|
64
55
|
if (data.type === LiveTranscriptionEvents.Transcript) {
|
|
65
56
|
this.emit(LiveTranscriptionEvents.Transcript, data as LiveTranscriptionEvent);
|
|
66
57
|
}
|
|
58
|
+
|
|
59
|
+
if (data.type === LiveTranscriptionEvents.UtteranceEnd) {
|
|
60
|
+
this.emit(LiveTranscriptionEvents.UtteranceEnd, data as UtteranceEndEvent);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (data.type === LiveTranscriptionEvents.SpeechStarted) {
|
|
64
|
+
this.emit(LiveTranscriptionEvents.SpeechStarted, data as SpeechStartedEvent);
|
|
65
|
+
}
|
|
67
66
|
} catch (error) {
|
|
68
67
|
this.emit(LiveTranscriptionEvents.Error, {
|
|
69
68
|
event,
|
|
@@ -28,7 +28,7 @@ export class PrerecordedClient extends AbstractRestfulClient {
|
|
|
28
28
|
|
|
29
29
|
if (options !== undefined && "callback" in options) {
|
|
30
30
|
throw new DeepgramError(
|
|
31
|
-
"Callback cannot be provided as an option to a synchronous transcription. Use `
|
|
31
|
+
"Callback cannot be provided as an option to a synchronous transcription. Use `transcribeUrlCallback` or `transcribeFileCallback` instead."
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -65,7 +65,7 @@ export class PrerecordedClient extends AbstractRestfulClient {
|
|
|
65
65
|
|
|
66
66
|
if (options !== undefined && "callback" in options) {
|
|
67
67
|
throw new DeepgramError(
|
|
68
|
-
"Callback cannot be provided as an option to a synchronous transcription. Use `
|
|
68
|
+
"Callback cannot be provided as an option to a synchronous transcription. Use `transcribeUrlCallback` or `transcribeFileCallback` instead."
|
|
69
69
|
);
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { AbstractRestfulClient } from "./AbstractRestfulClient";
|
|
2
|
+
import { CallbackUrl, appendSearchParams, isTextSource, isUrlSource } from "../lib/helpers";
|
|
3
|
+
import { DeepgramError, isDeepgramError } from "../lib/errors";
|
|
4
|
+
import type {
|
|
5
|
+
AnalyzeSchema,
|
|
6
|
+
AsyncAnalyzeResponse,
|
|
7
|
+
DeepgramResponse,
|
|
8
|
+
Fetch,
|
|
9
|
+
PrerecordedSchema,
|
|
10
|
+
SyncAnalyzeResponse,
|
|
11
|
+
TextSource,
|
|
12
|
+
UrlSource,
|
|
13
|
+
} from "../lib/types";
|
|
14
|
+
|
|
15
|
+
export class ReadClient extends AbstractRestfulClient {
|
|
16
|
+
async analyzeUrl(
|
|
17
|
+
source: UrlSource,
|
|
18
|
+
options?: AnalyzeSchema,
|
|
19
|
+
endpoint = "v1/read"
|
|
20
|
+
): Promise<DeepgramResponse<SyncAnalyzeResponse>> {
|
|
21
|
+
try {
|
|
22
|
+
let body;
|
|
23
|
+
|
|
24
|
+
if (isUrlSource(source)) {
|
|
25
|
+
body = JSON.stringify(source);
|
|
26
|
+
} else {
|
|
27
|
+
throw new DeepgramError("Unknown source type");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (options !== undefined && "callback" in options) {
|
|
31
|
+
throw new DeepgramError(
|
|
32
|
+
"Callback cannot be provided as an option to a synchronous transcription. Use `analyzeUrlCallback` or `analyzeTextCallback` instead."
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const analyzeOptions: AnalyzeSchema = { ...{}, ...options };
|
|
37
|
+
|
|
38
|
+
const url = new URL(endpoint, this.baseUrl);
|
|
39
|
+
appendSearchParams(url.searchParams, analyzeOptions);
|
|
40
|
+
|
|
41
|
+
const result: SyncAnalyzeResponse = await this.post(this.fetch as Fetch, url, body);
|
|
42
|
+
|
|
43
|
+
return { result, error: null };
|
|
44
|
+
} catch (error) {
|
|
45
|
+
if (isDeepgramError(error)) {
|
|
46
|
+
return { result: null, error };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async analyzeText(
|
|
54
|
+
source: TextSource,
|
|
55
|
+
options?: AnalyzeSchema,
|
|
56
|
+
endpoint = "v1/read"
|
|
57
|
+
): Promise<DeepgramResponse<SyncAnalyzeResponse>> {
|
|
58
|
+
try {
|
|
59
|
+
let body;
|
|
60
|
+
|
|
61
|
+
if (isTextSource(source)) {
|
|
62
|
+
body = JSON.stringify(source);
|
|
63
|
+
} else {
|
|
64
|
+
throw new DeepgramError("Unknown source type");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (options !== undefined && "callback" in options) {
|
|
68
|
+
throw new DeepgramError(
|
|
69
|
+
"Callback cannot be provided as an option to a synchronous requests. Use `analyzeUrlCallback` or `analyzeTextCallback` instead."
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const analyzeOptions: AnalyzeSchema = { ...{}, ...options };
|
|
74
|
+
|
|
75
|
+
const url = new URL(endpoint, this.baseUrl);
|
|
76
|
+
appendSearchParams(url.searchParams, analyzeOptions);
|
|
77
|
+
|
|
78
|
+
const result: SyncAnalyzeResponse = await this.post(this.fetch as Fetch, url, body);
|
|
79
|
+
|
|
80
|
+
return { result, error: null };
|
|
81
|
+
} catch (error) {
|
|
82
|
+
if (isDeepgramError(error)) {
|
|
83
|
+
return { result: null, error };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async analyzeUrlCallback(
|
|
91
|
+
source: UrlSource,
|
|
92
|
+
callback: CallbackUrl,
|
|
93
|
+
options?: AnalyzeSchema,
|
|
94
|
+
endpoint = "v1/read"
|
|
95
|
+
): Promise<DeepgramResponse<AsyncAnalyzeResponse>> {
|
|
96
|
+
try {
|
|
97
|
+
let body;
|
|
98
|
+
|
|
99
|
+
if (isUrlSource(source)) {
|
|
100
|
+
body = JSON.stringify(source);
|
|
101
|
+
} else {
|
|
102
|
+
throw new DeepgramError("Unknown source type");
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const transcriptionOptions: PrerecordedSchema = {
|
|
106
|
+
...options,
|
|
107
|
+
...{ callback: callback.toString() },
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const url = new URL(endpoint, this.baseUrl);
|
|
111
|
+
appendSearchParams(url.searchParams, transcriptionOptions);
|
|
112
|
+
|
|
113
|
+
const result: AsyncAnalyzeResponse = await this.post(this.fetch as Fetch, url, body);
|
|
114
|
+
|
|
115
|
+
return { result, error: null };
|
|
116
|
+
} catch (error) {
|
|
117
|
+
if (isDeepgramError(error)) {
|
|
118
|
+
return { result: null, error };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async analyzeTextCallback(
|
|
126
|
+
source: TextSource,
|
|
127
|
+
callback: CallbackUrl,
|
|
128
|
+
options?: AnalyzeSchema,
|
|
129
|
+
endpoint = "v1/read"
|
|
130
|
+
): Promise<DeepgramResponse<AsyncAnalyzeResponse>> {
|
|
131
|
+
try {
|
|
132
|
+
let body;
|
|
133
|
+
|
|
134
|
+
if (isTextSource(source)) {
|
|
135
|
+
body = JSON.stringify(source);
|
|
136
|
+
} else {
|
|
137
|
+
throw new DeepgramError("Unknown source type");
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const transcriptionOptions: PrerecordedSchema = {
|
|
141
|
+
...options,
|
|
142
|
+
...{ callback: callback.toString() },
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const url = new URL(endpoint, this.baseUrl);
|
|
146
|
+
appendSearchParams(url.searchParams, transcriptionOptions);
|
|
147
|
+
|
|
148
|
+
const result: AsyncAnalyzeResponse = await this.post(this.fetch as Fetch, url, body, {
|
|
149
|
+
"Content-Type": "deepgram/audio+video",
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
return { result, error: null };
|
|
153
|
+
} catch (error) {
|
|
154
|
+
if (isDeepgramError(error)) {
|
|
155
|
+
return { result: null, error };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
throw error;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrerecordedSource.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/PrerecordedSource.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,oBAAY,iBAAiB,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE9D,oBAAY,UAAU,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE3C,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;CACb"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrerecordedSource.js","sourceRoot":"","sources":["../../../../src/lib/types/PrerecordedSource.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrerecordedSource.d.ts","sourceRoot":"","sources":["../../../../src/lib/types/PrerecordedSource.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,oBAAY,iBAAiB,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE9D,oBAAY,UAAU,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE3C,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;CACb"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PrerecordedSource.js","sourceRoot":"","sources":["../../../../src/lib/types/PrerecordedSource.ts"],"names":[],"mappings":""}
|