Skip to content

Commit e83c6d1

Browse files
committed
Adding utterances and modifying property names
1 parent a35d86e commit e83c6d1

14 files changed

+238
-66
lines changed

CHANGELOG.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,50 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
---
1111

12+
## [1.0.2]
13+
14+
### Added
15+
16+
- `deepgram.projects.update` will now update a project
17+
- Prerecorded transcription responses now include utterances
18+
19+
### Updated
20+
21+
- The project type has been modified to the following:
22+
23+
```ts
24+
{
25+
project_id: string;
26+
name?: string;
27+
company?: string;
28+
};
29+
```
30+
31+
- The key type has been modified to the following:
32+
33+
```ts
34+
{
35+
api_key_id: string;
36+
key?: string;
37+
comment: string;
38+
created: string;
39+
scopes: Array<string>;
40+
};
41+
```
42+
43+
- The usage request type has been modified to the following:
44+
45+
```ts
46+
{
47+
request_id: string;
48+
created: string;
49+
path: string;
50+
accessor: string;
51+
response?: UsageRequestDetail | UsageRequestMessage;
52+
callback?: UsageCallback;
53+
};
54+
```
55+
1256
## [1.0.0]
1357

1458
### Added
@@ -52,7 +96,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5296

5397
---
5498

55-
[unreleased]: https://github.com/deepgram/node-sdk/compare/1.0.0...HEAD
99+
[unreleased]: https://github.com/deepgram/node-sdk/compare/1.0.2...HEAD
100+
[1.0.2]: https://github.com/deepgram/node-sdk/compare/1.0.0...1.0.2
56101
[1.0.0]: https://github.com/deepgram/node-sdk/compare/0.6.5...1.0.0
57102
[0.6.5]: https://github.com/deepgram/node-sdk/compare/0.6.4...0.6.5
58103
[0.6.4]: https://github.com/deepgram/node-sdk/compare/edc07b4...0.6.4

README.md

Lines changed: 109 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,62 @@ Additional transcription options can be provided for prerecorded transcriptions.
194194
}
195195
```
196196

197+
#### Prerecorded Transcription Response
198+
199+
```ts
200+
{
201+
request_id?: string;
202+
metadata?: {
203+
request_id: string;
204+
transaction_key: string;
205+
sha256: string;
206+
created: string;
207+
duration: number;
208+
channels: number;
209+
};
210+
results?: {
211+
channels: Array<{
212+
search?: Array<{
213+
query: string;
214+
hits: Array<{
215+
confidence: number;
216+
start: number;
217+
end: number;
218+
snippet: string;
219+
}>;
220+
}>;
221+
alternatives: Array<{
222+
transcript: string;
223+
confidence: number;
224+
words: Array<{
225+
word: string;
226+
start: number;
227+
end: number;
228+
confidence: number;
229+
punctuated_word?: string;
230+
}>;
231+
}>;
232+
}>;
233+
utterances?: Array<{
234+
start: number;
235+
end: number;
236+
confidence: number;
237+
channel: number;
238+
transcript: string;
239+
words: Array<{
240+
word: string;
241+
start: number;
242+
end: number;
243+
confidence: number;
244+
punctuated_word?: string;
245+
}>;
246+
speaker?: number;
247+
id: string;
248+
}>;
249+
};
250+
};
251+
```
252+
197253
### Live Transcription
198254

199255
The `transcription.live` method provides access to a websocket connection
@@ -378,52 +434,38 @@ Additional transcription options can be provided for live transcriptions.
378434
}
379435
```
380436

381-
### Transcription Response
437+
#### Live Transcription Response
382438

383-
```js
439+
```ts
384440
{
385-
"metadata": {
386-
"request_id": "string",
387-
"transaction_key": "string",
388-
"sha256": "string",
389-
"created": "string",
390-
"duration": 0,
391-
"channels": 0
392-
},
393-
"results": {
394-
"channels": [
395-
{
396-
"search": [
397-
{
398-
"query": "string",
399-
"hits": [
400-
{
401-
"confidence": 0,
402-
"start": 0,
403-
"end": 0,
404-
"snippet": "string"
405-
}
406-
]
407-
}
408-
],
409-
"alternatives": [
410-
{
411-
"transcript": "string",
412-
"confidence": 0,
413-
"words": [
414-
{
415-
"word": "string",
416-
"start": 0,
417-
"end": 0,
418-
"confidence": 0
419-
}
420-
]
421-
}
422-
]
423-
}
424-
]
441+
channel_index: Array<number>;
442+
duration: number;
443+
start: number;
444+
is_final: boolean;
445+
speech_final: boolean;
446+
channel: {
447+
search?: Array<{
448+
query: string;
449+
hits: Array<{
450+
confidence: number;
451+
start: number;
452+
end: number;
453+
snippet: string;
454+
}>
455+
}>,
456+
alternatives: Array<{
457+
transcript: string;
458+
confidence: number;
459+
words: Array<{
460+
word: string;
461+
start: number;
462+
end: number;
463+
confidence: number;
464+
punctuated_word?: string;
465+
}>
466+
}>
425467
}
426-
}
468+
};
427469
```
428470

429471
## Project Management
@@ -466,6 +508,23 @@ const project = await deepgram.projects.get(PROJECT_ID);
466508
}
467509
```
468510

511+
### Update a Project
512+
513+
Updates a project based on a provided project object. This object must contain
514+
`project_id` and `name` properties.
515+
516+
```js
517+
const updateResponse = await deepgram.projects.update(project);
518+
```
519+
520+
#### Update a Project Response
521+
522+
```ts
523+
{
524+
message: string;
525+
}
526+
```
527+
469528
## Key Management
470529

471530
### List Keys
@@ -480,11 +539,11 @@ const response = await deepgram.keys.list(PROJECT_ID);
480539

481540
```ts
482541
{
483-
keys: [
542+
api_keys: [
484543
{
485-
id: string,
544+
api_key_id: string,
486545
comment: string,
487-
created: Date,
546+
created: string,
488547
scopes: Array<string>
489548
},
490549
];
@@ -504,10 +563,10 @@ const response = await deepgram.keys.create(PROJECT_ID, COMMENT_FOR_KEY);
504563

505564
```ts
506565
{
507-
id: string,
566+
api_key_id: string,
508567
key: string,
509568
comment: string,
510-
created: Date,
569+
created: string,
511570
scopes: Array<string>
512571
}
513572
```
@@ -564,7 +623,7 @@ const response = await deepgram.usage.listRequests(PROJECT_ID, {
564623
limit: number,
565624
requests?: [
566625
{
567-
id: string;
626+
request_id: string;
568627
created: string;
569628
path: string;
570629
accessor: string;
@@ -623,7 +682,7 @@ const response = await deepgram.usage.getRequest(PROJECT_ID, REQUEST_ID);
623682

624683
```ts
625684
{
626-
id: string;
685+
request_id: string;
627686
created: string;
628687
path: string;
629688
accessor: string;

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@deepgram/sdk",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "An SDK for the Deepgram automated speech recognition platform",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
@@ -54,4 +54,4 @@
5454
"dependencies": {
5555
"ws": "^7.4.6"
5656
}
57-
}
57+
}

sample/index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,26 @@ function main() {
2121
const project = projects.projects[0];
2222

2323
/** Create an API key in the project */
24-
const apiKey = await deepgram.keys.create(project.id, "test key", ['member']);
25-
console.log(`Key created: ${apiKey.id}`);
24+
const apiKey = await deepgram.keys.create(project.project_id, "test key", ['member']);
25+
console.log(`Key created: ${apiKey.api_key_id}`);
2626

2727
const newDeepgram = new Deepgram(apiKey.key);
2828

2929
/** Send a pre-recorded file for transcription */
3030
const transcription = await newDeepgram.transcription.preRecorded({
3131
url: config.urlToFile
3232
}, {
33-
punctuate: true
33+
punctuate: true,
34+
utterances: true
3435
});
3536
console.dir(transcription, { depth: null });
3637

3738
/** Retrieve & log usage for this project */
38-
const usage = await newDeepgram.usage.listRequests(project.id);
39+
const usage = await newDeepgram.usage.listRequests(project.project_id);
3940
console.dir(usage, { depth: null });
4041

41-
await deepgram.keys.delete(project.id, apiKey.id);
42-
console.log(`Key deleted: ${apiKey.id}`);
42+
await deepgram.keys.delete(project.project_id, apiKey.api_key_id);
43+
console.log(`Key deleted: ${apiKey.api_key_id}`);
4344

4445
resolve();
4546
}

src/httpRequest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export function _request<T>(
6161
dgRes.on("end", () => {
6262
let dgResponse;
6363
try {
64+
console.log(`content: ${dgResContent}`);
6465
dgResponse = JSON.parse(dgResContent);
6566
} catch (err) {
6667
dgResponse = { error: dgResContent };

src/projects.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { _request } from "./httpRequest";
2-
import { Project, ProjectResponse } from "./types";
2+
import { Project, ProjectPatchResponse, ProjectResponse } from "./types";
33

44
export class Projects {
55
constructor(private _credentials: string, private _apiUrl: string) {}
@@ -30,4 +30,17 @@ export class Projects {
3030
`${this.apiPath}/${projectId}`
3131
);
3232
}
33+
34+
/**
35+
* Update a specific project
36+
* @param project project to update
37+
*/
38+
async update(project: Project): Promise<ProjectPatchResponse> {
39+
return _request<ProjectPatchResponse>(
40+
"PATCH",
41+
this._credentials,
42+
this._apiUrl,
43+
`${this.apiPath}/${project.project_id}`
44+
);
45+
}
3346
}

src/types/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export * from "./metadata";
99
export * from "./prerecordedTranscriptionOptions";
1010
export * from "./prerecordedTranscriptionResponse";
1111
export * from "./project";
12+
export * from "./projectPatchResponse";
1213
export * from "./projectResponse";
1314
export * from "./search";
1415
export * from "./transcriptionSource";
@@ -22,4 +23,5 @@ export * from "./usageRequestList";
2223
export * from "./usageRequestListOptions";
2324
export * from "./usageResponse";
2425
export * from "./usageResponseDetail";
26+
export * from "./utterance";
2527
export * from "./wordBase";

src/types/key.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export type Key = {
55
/**
66
* Unique identifier of the key to use in API requests
77
*/
8-
id: string;
8+
api_key_id: string;
99
/**
1010
* API key to send in API requests (Only displayed when first created)
1111
*/
@@ -17,7 +17,7 @@ export type Key = {
1717
/**
1818
* Timestamp of the date/time the key was created
1919
*/
20-
created: Date;
20+
created: string;
2121
/**
2222
* Array of scopes assigned to the key
2323
*/

0 commit comments

Comments
 (0)