Skip to content

Commit 545ddf6

Browse files
committed
Updating transcription auth
1 parent 3e307c1 commit 545ddf6

File tree

7 files changed

+21
-10
lines changed

7 files changed

+21
-10
lines changed

src/transcription/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
LiveTranscriptionOptions,
33
PrerecordedTranscriptionOptions,
4-
TranscriptionResponse,
4+
PrerecordedTranscriptionResponse,
55
TranscriptionSource,
66
} from "../types";
77
import { LiveTranscription } from "./liveTranscription";
@@ -18,7 +18,7 @@ export class Transcriber {
1818
async preRecorded(
1919
source: TranscriptionSource,
2020
options?: PrerecordedTranscriptionOptions
21-
): Promise<TranscriptionResponse> {
21+
): Promise<PrerecordedTranscriptionResponse> {
2222
return await preRecordedTranscription(
2323
this._credentials,
2424
this._apiUrl || "",

src/transcription/liveTranscription.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class LiveTranscription extends EventEmitter {
1818
`wss://${apiUrl}/v1/listen?${querystring.stringify(options)}`,
1919
{
2020
headers: {
21-
Authorization: `Basic ${credentials}`,
21+
Authorization: `token ${credentials}`,
2222
"User-Agent": userAgent(),
2323
},
2424
}
@@ -40,7 +40,7 @@ export class LiveTranscription extends EventEmitter {
4040
};
4141

4242
this._socket.onmessage = (m) => {
43-
this.emit(LiveTranscriptionEvents.TranscriptReceived, m);
43+
this.emit(LiveTranscriptionEvents.TranscriptReceived, m.data);
4444
};
4545
}
4646

src/transcription/preRecordedTranscription.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import querystring from "querystring";
22
import {
3-
TranscriptionResponse,
43
PrerecordedTranscriptionOptions,
4+
PrerecordedTranscriptionResponse,
55
TranscriptionSource,
66
UrlSource,
77
} from "../types";
@@ -25,7 +25,7 @@ export const preRecordedTranscription = async (
2525
apiUrl: string,
2626
source: TranscriptionSource,
2727
options?: PrerecordedTranscriptionOptions
28-
): Promise<TranscriptionResponse> => {
28+
): Promise<PrerecordedTranscriptionResponse> => {
2929
const transcriptionOptions = { ...{}, ...options };
3030

3131
if (
@@ -35,7 +35,7 @@ export const preRecordedTranscription = async (
3535
throw new Error("DG: Mimetype must be provided if the source is a Buffer");
3636
}
3737

38-
return await _request<TranscriptionResponse>(
38+
return await _request<PrerecordedTranscriptionResponse>(
3939
"POST",
4040
apiKey,
4141
apiUrl,

src/types/channel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export type Channel = {
88
/**
99
* Searched terms & results
1010
*/
11-
search: Array<Search>;
11+
search?: Array<Search>;
1212
alternatives: Array<{
1313
/**
1414
* Text of speech identified by API

src/types/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ export * from "./hit";
33
export * from "./key";
44
export * from "./keyResponse";
55
export * from "./liveTranscriptionOptions";
6+
export * from "./liveTranscriptionResponse";
67
export * from "./member";
78
export * from "./metadata";
89
export * from "./prerecordedTranscriptionOptions";
10+
export * from "./prerecordedTranscriptionResponse";
911
export * from "./project";
1012
export * from "./projectResponse";
1113
export * from "./search";
12-
export * from "./transcriptionResponse";
1314
export * from "./transcriptionSource";
1415
export * from "./usageCallback";
1516
export * from "./usageField";
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Channel } from "./channel";
2+
3+
export type LiveTranscriptionResponse = {
4+
channel_index: Array<number>;
5+
duration: number;
6+
start: number;
7+
is_final: boolean;
8+
speech_final: boolean;
9+
channel: Channel;
10+
};

src/types/transcriptionResponse.ts renamed to src/types/prerecordedTranscriptionResponse.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Metadata } from "./metadata";
22
import { Channel } from "./channel";
33

4-
export type TranscriptionResponse = {
4+
export type PrerecordedTranscriptionResponse = {
55
request_id?: string;
66
metadata?: Metadata;
77
results?: {

0 commit comments

Comments
 (0)