Skip to content

Commit

Permalink
Add support for subtitles
Browse files Browse the repository at this point in the history
  • Loading branch information
casperkloppenburg committed Sep 7, 2023
1 parent c3a4ff8 commit 315c753
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 1,453 deletions.
1,454 changes: 4 additions & 1,450 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "creatomate",
"version": "1.0.5",
"version": "1.0.6",
"description": "Official Node.js SDK for the Creatomate video rendering API",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class Client {
try {
const updatedRender = await this.fetchRender(render.id);

if (updatedRender.status !== 'planned' && updatedRender.status !== 'rendering') {
if (updatedRender.status !== 'planned' && updatedRender.status !== 'rendering' && updatedRender.status !== 'transcribing') {
unfinishedRenders = unfinishedRenders.filter(({ id }) => id !== render.id);

finishedRenders.push(updatedRender);
Expand Down
2 changes: 1 addition & 1 deletion src/RenderStatus.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export type RenderStatus = 'planned' | 'rendering' | 'succeeded' | 'failed';
export type RenderStatus = 'planned' | 'rendering' | 'transcribing' | 'succeeded' | 'failed';
5 changes: 5 additions & 0 deletions src/elements/ElementBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ import { AnimationBase } from '../animations';
import { expandProperties, transformObjectKeys, transformCamelToSnakeCase } from '../utility';

export interface ElementProperties {
/**
* A unique identifier for this element.
*/
id?: string;

/**
* The track number on which this element is placed. If you are rendering an image, you can leave this value undefined.
*/
Expand Down
34 changes: 34 additions & 0 deletions src/elements/Text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import {
StrokeJoin,
TextBackground,
TextTransform,
TranscriptEffect,
TranscriptPlacement,
TranscriptSplit,
ValueOrKeyframes,
} from '../properties';
import { ElementBase, ElementProperties } from './ElementBase';
Expand Down Expand Up @@ -175,6 +178,37 @@ export interface TextProperties extends ElementProperties {
* width. A value of 0% disables alignment.
*/
backgroundAlignThreshold?: ValueOrKeyframes<number | string>;

/**
* To use auto-transcription for this text element, set it to the ID of the video element for which subtitles are to
* be generated.
*/
transcriptSource?: string;

/**
* The transcript effect: color, karaoke, highlight, fade, bounce, slide, or enlarge.
*/
transcriptEffect?: TranscriptEffect;

/**
* The transcript split: none, word, or line.
*/
transcriptSplit?: TranscriptSplit;

/**
* The transcript placement: static, animate, or align.
*/
transcriptPlacement?: TranscriptPlacement;

/**
* The maximum number of characters shown simultaneously.
*/
transcriptMaximumLength?: number;

/**
* The color applied to the currently spoken text (word or line). Use this in conjunction with "transcriptSplit".
*/
transcriptColor?: string;
}

export class Text extends ElementBase<TextProperties> {
Expand Down
1 change: 1 addition & 0 deletions src/properties/TranscriptEffect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type TranscriptEffect = 'color' | 'karaoke' | 'highlight' | 'fade' | 'bounce' | 'slide' | 'enlarge';
1 change: 1 addition & 0 deletions src/properties/TranscriptPlacement.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type TranscriptPlacement = 'static' | 'animate' | 'align';
1 change: 1 addition & 0 deletions src/properties/TranscriptSplit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type TranscriptSplit = 'none' | 'word' | 'line';
3 changes: 3 additions & 0 deletions src/properties/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export * from './StrokeCap';
export * from './StrokeJoin';
export * from './TextBackground';
export * from './TextTransform';
export * from './TranscriptEffect';
export * from './TranscriptPlacement';
export * from './TranscriptSplit';
export * from './Warp';
export * from './WarpMode';
export * from './WarpPoint';

0 comments on commit 315c753

Please sign in to comment.