Skip to content

Commit

Permalink
Rename BatchClient.createJob => BatchClient.createTranscriptionJob
Browse files Browse the repository at this point in the history
- Update types to enforce presence of `transcription_config`
  • Loading branch information
mnemitz committed Jan 25, 2024
1 parent 9ce5742 commit e03c4c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/batch/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
RetrieveJobsResponse,
JobConfig,
DataFetchConfig,
BatchTranscriptionConfig,
} from '../types';
import { ConnectionConfig, ConnectionConfigFull } from '../config/connection';
import { QueryParams, request, SM_APP_PARAM_NAME } from '../utils/request';
Expand Down Expand Up @@ -104,13 +105,13 @@ export class BatchTranscription {
*/
async transcribe(
input: JobInput,
jobConfig: Omit<JobConfig, 'type'>,
jobConfig: Parameters<typeof this.createTranscriptionJob>[1],
format?: TranscriptionFormat,
): Promise<RetrieveTranscriptResponse | string> {
if (this.config.apiKey === undefined)
throw new Error('Error: apiKey is undefined');

const submitResponse = await this.createJob(input, jobConfig);
const submitResponse = await this.createTranscriptionJob(input, jobConfig);

if (submitResponse === null || submitResponse === undefined) {
throw 'Error: submitResponse is undefined';
Expand All @@ -134,9 +135,11 @@ export class BatchTranscription {
return await this.getJobResult(submitResponse.id, format || 'json-v2');
}

async createJob(
async createTranscriptionJob(
input: JobInput,
jobConfig: Omit<JobConfig, 'type'>,
jobConfig: Omit<JobConfig, 'type'> & {
transcription_config: BatchTranscriptionConfig;
},
): Promise<CreateJobResponse> {
if (this.config.apiKey === undefined)
throw new Error('Error: apiKey is undefined');
Expand Down
2 changes: 1 addition & 1 deletion tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('Testing batch capabilities', () => {

it('can fetch plain text transcripts', async () => {
const speechmatics = new Speechmatics(process.env.API_KEY as string);
const { id } = await speechmatics.batch.createJob(
const { id } = await speechmatics.batch.createTranscriptionJob(
{ data: EXAMPLE_FILE, fileName: exampleFileName },
{
transcription_config: {
Expand Down

0 comments on commit e03c4c0

Please sign in to comment.