Skip to content

Commit 6b90c35

Browse files
adds translation feature (#83)
* adds translation feature * fixed comment
1 parent 5d978f4 commit 6b90c35

6 files changed

Lines changed: 38 additions & 2 deletions

File tree

src/types/alternatives.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ParagraphGroup } from "./paragraphGroup";
22
import { WordBase } from "./wordBase";
33
import { Entity } from "./entity";
44
import { Summary } from "./summary";
5+
import { Translation } from "./translation"
56
import { TopicGroup } from "./topicGroup";
67

78
export type Alternative = {
@@ -34,7 +35,11 @@ export type Alternative = {
3435
*/
3536
detected_language?: string;
3637
/**
37-
* Array of topic group objects.
38+
* Array of language objects for each language the response has been translated into
3839
*/
40+
translations?: Array<Translation>;
41+
/**
42+
* Array of topic group objects.
43+
*/
3944
topics?: Array<TopicGroup>;
4045
};

src/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export * from "./summary";
3232
export * from "./topic";
3333
export * from "./topicGroup";
3434
export * from "./transcriptionSource";
35+
export * from "./translation";
3536
export * from "./usageCallback";
3637
export * from "./usageField";
3738
export * from "./usageFieldOptions";

src/types/prerecordedTranscriptionOptions.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,19 @@ export type PrerecordedTranscriptionOptions = {
4343
* @see https://developers.deepgram.com/api-reference/speech-recognition-api#operation/transcribeAudio/properties/language
4444
*/
4545
language?: string;
46+
4647
/**
4748
* Indicates whether to add punctuation and capitalization to the transcript.
4849
* @see https://developers.deepgram.com/api-reference/speech-recognition-api#operation/transcribeAudio/properties/punctuate
4950
*/
5051
punctuate?: boolean;
52+
5153
/**
5254
* Indicates whether to remove profanity from the transcript.
5355
* @see https://developers.deepgram.com/api-reference/speech-recognition-api#operation/transcribeAudio/properties/profanity_filter
5456
*/
5557
profanity_filter?: boolean;
58+
5659
/**
5760
* Indicates whether to redact sensitive information, replacing redacted content with asterisks (*).
5861
* @remarks Options include:
@@ -89,12 +92,14 @@ export type PrerecordedTranscriptionOptions = {
8992
* @see https://developers.deepgram.com/api-reference/speech-recognition-api#operation/transcribeAudio/properties/multichannel
9093
*/
9194
multichannel?: boolean;
95+
9296
/**
9397
* Maximum number of transcript alternatives to return. Just like a human listener,
9498
* Deepgram can provide multiple possible interpretations of what it hears.
9599
* @default 1
96100
*/
97101
alternatives?: number;
102+
98103
/**
99104
* Indicates whether to convert numbers from written format (e.g., one) to
100105
* numerical format (e.g., 1). Deepgram can format numbers up to 999,999.
@@ -103,13 +108,15 @@ export type PrerecordedTranscriptionOptions = {
103108
* @see https://developers.deepgram.com/api-reference/speech-recognition-api#operation/transcribeAudio/properties/numerals
104109
*/
105110
numerals?: boolean;
111+
106112
/**
107113
* Terms or phrases to search for in the submitted audio. Deepgram searches
108114
* for acoustic patterns in audio rather than text patterns in transcripts
109115
* because we have noticed that acoustic pattern matching is more performant.
110116
* @see https://developers.deepgram.com/api-reference/speech-recognition-api#operation/transcribeAudio/properties/search
111117
*/
112118
search?: Array<string>;
119+
113120
/**
114121
* Callback URL to provide if you would like your submitted audio to be
115122
* processed asynchronously. When passed, Deepgram will immediately respond
@@ -120,6 +127,7 @@ export type PrerecordedTranscriptionOptions = {
120127
* @see https://developers.deepgram.com/api-reference/speech-recognition-api#operation/transcribeAudio/properties/callback
121128
*/
122129
callback?: string;
130+
123131
/**
124132
* Keywords to which the model should pay particular attention to boosting
125133
* or suppressing to help it understand context. Just like a human listener,
@@ -128,6 +136,7 @@ export type PrerecordedTranscriptionOptions = {
128136
* @see https://developers.deepgram.com/api-reference/speech-recognition-api#operation/transcribeAudio/properties/keywords
129137
*/
130138
keywords?: Array<string>;
139+
131140
/**
132141
* Indicates whether Deepgram will segment speech into meaningful semantic
133142
* units, which allows the model to interact more naturally and effectively
@@ -143,6 +152,7 @@ export type PrerecordedTranscriptionOptions = {
143152
* @see https://developers.deepgram.com/api-reference/speech-recognition-api#operation/transcribeAudio/properties/utterances
144153
*/
145154
utterances?: boolean;
155+
146156
/**
147157
* Length of time in seconds of silence between words that Deepgram will
148158
* use when determining where to split utterances. Used when utterances
@@ -151,8 +161,9 @@ export type PrerecordedTranscriptionOptions = {
151161
* @see https://developers.deepgram.com/api-reference/speech-recognition-api#operation/transcribeAudio/properties/utt_split
152162
*/
153163
utt_split?: number;
164+
154165
/**
155-
* Detects the language of the reocrded audio and passes audio through appropriate model
166+
* Detects the language of the recorded audio and passes audio through appropriate model
156167
*
157168
*
158169
* @see https://developers.deepgram.com/api-reference/#detect-language-pr
@@ -175,6 +186,13 @@ export type PrerecordedTranscriptionOptions = {
175186
* Indicates whether Deepgram should provide summarizations of sections of the provided audio.
176187
*/
177188
summarize?: boolean;
189+
190+
/**
191+
* Corresponds to the language code Deepgram will translate the results into
192+
* For example, 'es', 'fr', 'ja'
193+
* If requests translation in the same language as their ASR request, a 400 will be returned.
194+
*/
195+
translation?: Array<string>;
178196

179197
/**
180198
* Indicates whether Deepgram will identify and detect topics in the transcript.

src/types/translation.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export type Translation = {
2+
/**
3+
* Language code of the translation.
4+
*/
5+
language: string;
6+
/**
7+
* Translated transcript.
8+
*/
9+
translation: string;
10+
};

src/types/usageOptions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export type UsageOptions = {
2020
redact?: boolean;
2121
alternatives?: boolean;
2222
numerals?: boolean;
23+
translation?:boolean;
2324
detect_entities?: boolean;
2425
detect_topics?: boolean;
2526
summarize?: boolean;

src/types/usageRequestDetail.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export type UsageRequestDetail = {
2525
redact?: boolean;
2626
alternatives?: boolean;
2727
numerals?: boolean;
28+
translation?:boolean;
2829
};
2930
};
3031
};

0 commit comments

Comments
 (0)