@twick/studio 0.15.26 → 0.15.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { TrackElement, VideoElement } from '@twick/timeline';
2
- import { ICaptionGenerationPollingResponse } from '../../types';
2
+ import { CaptionPhraseLength, ICaptionGenerationPollingResponse } from '../../types';
3
3
 
4
4
  export declare function GenerateCaptionsPanel({ selectedElement, addCaptionsToTimeline, onGenerateCaptions, getCaptionstatus, pollingIntervalMs, }: {
5
5
  selectedElement: TrackElement;
@@ -7,8 +7,9 @@ export declare function GenerateCaptionsPanel({ selectedElement, addCaptionsToTi
7
7
  s: number;
8
8
  e: number;
9
9
  t: string;
10
+ w?: number[];
10
11
  }[]) => void;
11
- onGenerateCaptions: (videoElement: VideoElement, language?: string, wordsPerPhrase?: number) => Promise<string | null>;
12
+ onGenerateCaptions: (videoElement: VideoElement, language?: string, phraseLength?: CaptionPhraseLength) => Promise<string | null>;
12
13
  getCaptionstatus: (reqId: string) => Promise<ICaptionGenerationPollingResponse>;
13
14
  pollingIntervalMs?: number;
14
15
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import { ProjectJSON, VideoElement } from '@twick/timeline';
2
- import { ICaptionGenerationPollingResponse, ICaptionGenerationService, CaptionEntry } from '../types';
2
+ import { CaptionEntry, CaptionPhraseLength, ICaptionGenerationPollingResponse, ICaptionGenerationService } from '../types';
3
3
 
4
4
  declare class GenerateCaptionsService implements ICaptionGenerationService {
5
5
  /**
@@ -8,13 +8,13 @@ declare class GenerateCaptionsService implements ICaptionGenerationService {
8
8
  */
9
9
  videoElement: VideoElement | null;
10
10
  projectJSON: ProjectJSON | null;
11
- generateSubtiltesApi: (videoUrl: string) => Promise<string>;
11
+ generateSubtiltesApi: (videoUrl: string, language?: string, phraseLength?: CaptionPhraseLength) => Promise<string>;
12
12
  requestStatusApi: (reqId: string) => Promise<ICaptionGenerationPollingResponse>;
13
13
  constructor({ generateSubtiltesApi, requestStatusApi, }: {
14
- generateSubtiltesApi: (videoUrl: string) => Promise<string>;
14
+ generateSubtiltesApi: (videoUrl: string, language?: string, phraseLength?: CaptionPhraseLength) => Promise<string>;
15
15
  requestStatusApi: (reqId: string) => Promise<ICaptionGenerationPollingResponse>;
16
16
  });
17
- generateCaptions(videoElement: VideoElement, projectJSON: ProjectJSON): Promise<string>;
17
+ generateCaptions(videoElement: VideoElement, projectJSON: ProjectJSON, language?: string, phraseLength?: CaptionPhraseLength): Promise<string>;
18
18
  getRequestStatus(reqId: string): Promise<ICaptionGenerationPollingResponse>;
19
19
  updateProjectWithCaptions(captions: CaptionEntry[]): ProjectJSON;
20
20
  generateCaptionVideo(videoUrl: string, videoSize?: {
@@ -1,8 +1,8 @@
1
1
  import { VideoElement } from '@twick/timeline';
2
- import { ICaptionGenerationPollingResponse, StudioConfig, CaptionEntry } from '../types';
2
+ import { ICaptionGenerationPollingResponse, StudioConfig, CaptionEntry, CaptionPhraseLength } from '../types';
3
3
 
4
4
  declare const useGenerateCaptions: (studioConfig?: StudioConfig) => {
5
- onGenerateCaptions: (videoElement: VideoElement, language?: string, wordsPerPhrase?: number) => Promise<string | null>;
5
+ onGenerateCaptions: (videoElement: VideoElement, language?: string, phraseLength?: CaptionPhraseLength) => Promise<string | null>;
6
6
  addCaptionsToTimeline: (captions: CaptionEntry[]) => void;
7
7
  getCaptionstatus: (reqId: string) => Promise<ICaptionGenerationPollingResponse>;
8
8
  pollingIntervalMs: number;
package/dist/index.js CHANGED
@@ -6944,7 +6944,7 @@ function GenerateCaptionsPanel({
6944
6944
  const [pollingStatus, setPollingStatus] = react.useState("idle");
6945
6945
  const [errorMessage, setErrorMessage] = react.useState(null);
6946
6946
  const [selectedLanguage, setSelectedLanguage] = react.useState("auto");
6947
- const [wordsPerPhrase, setWordsPerPhrase] = react.useState(4);
6947
+ const [phraseLength, setPhraseLength] = react.useState("medium");
6948
6948
  const pollingIntervalRef = react.useRef(null);
6949
6949
  const currentReqIdRef = react.useRef(null);
6950
6950
  react.useEffect(() => {
@@ -7009,7 +7009,7 @@ function GenerateCaptionsPanel({
7009
7009
  const reqId = await onGenerateCaptions(
7010
7010
  videoElement,
7011
7011
  language,
7012
- wordsPerPhrase
7012
+ phraseLength
7013
7013
  );
7014
7014
  if (!reqId) {
7015
7015
  setPollingStatus("error");
@@ -7094,18 +7094,19 @@ function GenerateCaptionsPanel({
7094
7094
  )
7095
7095
  ] }),
7096
7096
  !isLoading && containsAudio === true && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "panel-section", children: [
7097
- /* @__PURE__ */ jsxRuntime.jsx("label", { className: "label-dark", htmlFor: "caption-words-per-phrase", children: "Words per phrase" }),
7098
- /* @__PURE__ */ jsxRuntime.jsx(
7097
+ /* @__PURE__ */ jsxRuntime.jsx("label", { className: "label-dark", htmlFor: "caption-phrase-length", children: "Caption length" }),
7098
+ /* @__PURE__ */ jsxRuntime.jsxs(
7099
7099
  "select",
7100
7100
  {
7101
- id: "caption-words-per-phrase",
7101
+ id: "caption-phrase-length",
7102
7102
  className: "select-dark",
7103
- value: String(wordsPerPhrase),
7104
- onChange: (e) => setWordsPerPhrase(Number(e.target.value) || 4),
7105
- children: Array.from({ length: 10 }).map((_, index) => {
7106
- const value = index + 1;
7107
- return /* @__PURE__ */ jsxRuntime.jsx("option", { value, children: value }, value);
7108
- })
7103
+ value: phraseLength,
7104
+ onChange: (e) => setPhraseLength(e.target.value),
7105
+ children: [
7106
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "short", children: "Short" }),
7107
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "medium", children: "Medium" }),
7108
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "long", children: "Long" })
7109
+ ]
7109
7110
  }
7110
7111
  )
7111
7112
  ] }),
@@ -7776,14 +7777,14 @@ function TwickStudio({ studioConfig }) {
7776
7777
  const useGenerateCaptions = (studioConfig) => {
7777
7778
  var _a;
7778
7779
  const { editor, present } = timeline.useTimelineContext();
7779
- const onGenerateCaptions = async (videoElement, language, wordsPerPhrase) => {
7780
+ const onGenerateCaptions = async (videoElement, language, phraseLength) => {
7780
7781
  if (studioConfig == null ? void 0 : studioConfig.captionGenerationService) {
7781
7782
  const service = studioConfig.captionGenerationService;
7782
7783
  const reqId = await service.generateCaptions(
7783
7784
  videoElement,
7784
7785
  present,
7785
7786
  language,
7786
- wordsPerPhrase
7787
+ phraseLength
7787
7788
  );
7788
7789
  return reqId;
7789
7790
  }