Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillatrev committed Dec 19, 2023
1 parent 722959f commit ced21fd
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,13 @@ export class RevAiApiClient {
{ 'Accept': TranscriptType.JSON }, 'json');
}

/**
* See https://docs.rev.ai/api/asynchronous/reference/#operation/GetTranscriptById
* Get translated transcript of a job as a javascript object, see the RevAiApiTranscript object.
* @param id Id of job to retrieve the transcript of
* @param language requested language
* @returns Transcript of job as a javascript object.
*/
async getTranslatedTranscriptObject(id: string, language: string): Promise<RevAiApiTranscript> {
const url = `/jobs/${id}/transcript/translation/${language}`;
return await this.apiHandler.makeApiRequest<RevAiApiTranscript>('get', url,
Expand All @@ -215,7 +222,14 @@ export class RevAiApiClient {
return await this.apiHandler.makeApiRequest<Readable>('get',
`/jobs/${id}/transcript`, { 'Accept': TranscriptType.JSON }, 'stream');
}

/**
* See https://docs.rev.ai/api/asynchronous/reference/#operation/GetTranscriptById
* Get translated transcript of a job as a stream of JSON.
* Use for large transcripts or transcripts meant to be written directly to file.
* @param id Id of job to retrieve transcript of
* @param language requested language
* @returns ReadableStream containing JSON of transcript
*/
async getTranslatedTranscriptObjectStream(id: string, language: string): Promise<Readable> {
const url = `/jobs/${id}/transcript/translation/${language}`;
return await this.apiHandler.makeApiRequest<Readable>('get', url,
Expand All @@ -233,6 +247,13 @@ export class RevAiApiClient {
{ 'Accept': TranscriptType.TEXT }, 'text');
}

/**
* See https://docs.rev.ai/api/asynchronous/reference/#operation/GetTranscriptById
* Get translated transcript of a job as plain text.
* @param id Id of job to retrieve transcript of
* @param language requested language
* @returns Transcript of the requested job as a readable text string
*/
async getTranslatedTranscriptText(id: string, language: string): Promise<string> {
const url = `/jobs/${id}/transcript/translation/${language}`;
return await this.apiHandler.makeApiRequest<string>('get', url,
Expand Down Expand Up @@ -295,13 +316,23 @@ export class RevAiApiClient {
'get', url, { 'Accept': contentType || CaptionType.SRT }, 'stream');
}

/**
* Get transcript summary as text.
* @param id The ID of the job to return a transcript summary for.
* @return The transcript summary as a String in text format.
*/
async getTranscriptSummaryText(id: string): Promise<string> {
const url = `/jobs/${id}/transcript/summary`;

return await this.apiHandler.makeApiRequest<string>('get', url,
{ 'Accept': TranscriptType.TEXT }, 'text');
}

/**
* Get transcript summary as object.
* @param id The ID of the job to return a transcript summary for.
* @return The transcript summary as a javscript object. See the Summary object.
*/
async getTranscriptSummaryObject(id: string): Promise<Summary> {
const url = `/jobs/${id}/transcript/summary`;
return await this.apiHandler.makeApiRequest<Summary>('get', url,
Expand Down

0 comments on commit ced21fd

Please sign in to comment.