@remotion/openai-whisper 4.0.278 → 4.0.280

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.
@@ -10,7 +10,13 @@ const openAiWhisperApiToCaptions = ({ transcription, }) => {
10
10
  throw new Error('The transcription does need to be been generated with `timestamp_granularities: ["word"]`');
11
11
  }
12
12
  let remainingText = transcription.text;
13
- for (const word of transcription.words) {
13
+ for (let i = 0; i < transcription.words.length; i++) {
14
+ const word = transcription.words[i];
15
+ const firstWord = i === 0;
16
+ // https://github.com/remotion-dev/remotion/issues/5031
17
+ if (firstWord) {
18
+ word.word = word.word.trimStart();
19
+ }
14
20
  const punctuation = `\\?,\\.\\%\\–\\!\\;\\:\\'\\"\\-\\_\\(\\)\\[\\]\\{\\}\\@\\#\\$\\^\\&\\*\\+\\=\\/\\|\\<\\>\\~\``;
15
21
  const match = new RegExp(`^([\\s${punctuation}]{0,4})${word.word.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}([${punctuation}]{0,3})?`).exec(remainingText);
16
22
  if (!match) {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,278 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const bun_test_1 = require("bun:test");
4
+ const openai_whisper_api_to_captions_1 = require("../openai-whisper-api-to-captions");
5
+ (0, bun_test_1.test)('foreign API (https://github.com/remotion-dev/remotion/issues/5031)', () => {
6
+ const res = {
7
+ text: "Hello world. It's great to finally be here, surrounded by the endless possibilities that this universe has to offer, and I'm excited to see what the future holds for all of us.",
8
+ task: 'transcribe',
9
+ language: '',
10
+ duration: 10.625,
11
+ words: [
12
+ { word: ' Hello', start: 0, end: 0.46000000834465027 },
13
+ { word: ' world.', start: 0.46000000834465027, end: 0.9800000190734863 },
14
+ { word: " It's", start: 0.9800000190734863, end: 1.5800000429153442 },
15
+ { word: ' great', start: 1.5800000429153442, end: 1.7999999523162842 },
16
+ { word: ' to', start: 1.7999999523162842, end: 1.9600000381469727 },
17
+ { word: ' finally', start: 1.9600000381469727, end: 2.319999933242798 },
18
+ { word: ' be', start: 2.319999933242798, end: 2.5799999237060547 },
19
+ { word: ' here,', start: 2.5799999237060547, end: 3 },
20
+ { word: ' surrounded', start: 3, end: 3.5999999046325684 },
21
+ { word: ' by', start: 3.5999999046325684, end: 4.019999980926514 },
22
+ { word: ' the', start: 4.019999980926514, end: 4.179999828338623 },
23
+ { word: ' endless', start: 4.179999828338623, end: 4.519999980926514 },
24
+ {
25
+ word: ' possibilities',
26
+ start: 4.519999980926514,
27
+ end: 5.119999885559082,
28
+ },
29
+ { word: ' that', start: 5.119999885559082, end: 5.639999866485596 },
30
+ { word: ' this', start: 5.639999866485596, end: 5.820000171661377 },
31
+ { word: ' universe', start: 5.820000171661377, end: 6.179999828338623 },
32
+ { word: ' has', start: 6.179999828338623, end: 6.519999980926514 },
33
+ { word: ' to', start: 6.519999980926514, end: 6.659999847412109 },
34
+ { word: ' offer,', start: 6.659999847412109, end: 7.179999828338623 },
35
+ { word: ' and', start: 7.179999828338623, end: 7.679999828338623 },
36
+ { word: " I'm", start: 7.679999828338623, end: 7.820000171661377 },
37
+ { word: ' excited', start: 7.820000171661377, end: 8.180000305175781 },
38
+ { word: ' to', start: 8.180000305175781, end: 8.420000076293945 },
39
+ { word: ' see', start: 8.420000076293945, end: 8.600000381469727 },
40
+ { word: ' what', start: 8.600000381469727, end: 8.739999771118164 },
41
+ { word: ' the', start: 8.739999771118164, end: 8.859999656677246 },
42
+ { word: ' future', start: 8.859999656677246, end: 9.180000305175781 },
43
+ { word: ' holds', start: 9.180000305175781, end: 9.520000457763672 },
44
+ { word: ' for', start: 9.520000457763672, end: 9.779999732971191 },
45
+ { word: ' all', start: 9.779999732971191, end: 9.979999542236328 },
46
+ { word: ' of', start: 9.979999542236328, end: 10.079999923706055 },
47
+ { word: ' us.', start: 10.079999923706055, end: 10.34000015258789 },
48
+ ],
49
+ };
50
+ (0, bun_test_1.expect)((0, openai_whisper_api_to_captions_1.openAiWhisperApiToCaptions)({ transcription: res })).toEqual({
51
+ captions: [
52
+ {
53
+ confidence: null,
54
+ endMs: 460.00000834465027,
55
+ startMs: 0,
56
+ text: 'Hello',
57
+ timestampMs: 230.00000417232513,
58
+ },
59
+ {
60
+ confidence: null,
61
+ endMs: 980.0000190734863,
62
+ startMs: 460.00000834465027,
63
+ text: ' world.',
64
+ timestampMs: 720.0000137090683,
65
+ },
66
+ {
67
+ confidence: null,
68
+ endMs: 1580.0000429153442,
69
+ startMs: 980.0000190734863,
70
+ text: " It's",
71
+ timestampMs: 1280.0000309944153,
72
+ },
73
+ {
74
+ confidence: null,
75
+ endMs: 1799.9999523162842,
76
+ startMs: 1580.0000429153442,
77
+ text: ' great',
78
+ timestampMs: 1689.9999976158142,
79
+ },
80
+ {
81
+ confidence: null,
82
+ endMs: 1960.0000381469727,
83
+ startMs: 1799.9999523162842,
84
+ text: ' to',
85
+ timestampMs: 1879.9999952316284,
86
+ },
87
+ {
88
+ confidence: null,
89
+ endMs: 2319.999933242798,
90
+ startMs: 1960.0000381469727,
91
+ text: ' finally',
92
+ timestampMs: 2139.9999856948853,
93
+ },
94
+ {
95
+ confidence: null,
96
+ endMs: 2579.9999237060547,
97
+ startMs: 2319.999933242798,
98
+ text: ' be',
99
+ timestampMs: 2449.9999284744263,
100
+ },
101
+ {
102
+ confidence: null,
103
+ endMs: 3000,
104
+ startMs: 2579.9999237060547,
105
+ text: ' here,',
106
+ timestampMs: 2789.9999618530273,
107
+ },
108
+ {
109
+ confidence: null,
110
+ endMs: 3599.9999046325684,
111
+ startMs: 3000,
112
+ text: ' surrounded',
113
+ timestampMs: 3299.999952316284,
114
+ },
115
+ {
116
+ confidence: null,
117
+ endMs: 4019.9999809265137,
118
+ startMs: 3599.9999046325684,
119
+ text: ' by',
120
+ timestampMs: 3809.999942779541,
121
+ },
122
+ {
123
+ confidence: null,
124
+ endMs: 4179.999828338623,
125
+ startMs: 4019.9999809265137,
126
+ text: ' the',
127
+ timestampMs: 4099.999904632568,
128
+ },
129
+ {
130
+ confidence: null,
131
+ endMs: 4519.999980926514,
132
+ startMs: 4179.999828338623,
133
+ text: ' endless',
134
+ timestampMs: 4349.999904632568,
135
+ },
136
+ {
137
+ confidence: null,
138
+ endMs: 5119.999885559082,
139
+ startMs: 4519.999980926514,
140
+ text: ' possibilities',
141
+ timestampMs: 4819.999933242798,
142
+ },
143
+ {
144
+ confidence: null,
145
+ endMs: 5639.999866485596,
146
+ startMs: 5119.999885559082,
147
+ text: ' that',
148
+ timestampMs: 5379.999876022339,
149
+ },
150
+ {
151
+ confidence: null,
152
+ endMs: 5820.000171661377,
153
+ startMs: 5639.999866485596,
154
+ text: ' this',
155
+ timestampMs: 5730.000019073486,
156
+ },
157
+ {
158
+ confidence: null,
159
+ endMs: 6179.999828338623,
160
+ startMs: 5820.000171661377,
161
+ text: ' universe',
162
+ timestampMs: 6000,
163
+ },
164
+ {
165
+ confidence: null,
166
+ endMs: 6519.999980926514,
167
+ startMs: 6179.999828338623,
168
+ text: ' has',
169
+ timestampMs: 6349.999904632568,
170
+ },
171
+ {
172
+ confidence: null,
173
+ endMs: 6659.999847412109,
174
+ startMs: 6519.999980926514,
175
+ text: ' to',
176
+ timestampMs: 6589.9999141693115,
177
+ },
178
+ {
179
+ confidence: null,
180
+ endMs: 7179.999828338623,
181
+ startMs: 6659.999847412109,
182
+ text: ' offer,',
183
+ timestampMs: 6919.999837875366,
184
+ },
185
+ {
186
+ confidence: null,
187
+ endMs: 7679.999828338623,
188
+ startMs: 7179.999828338623,
189
+ text: ' and',
190
+ timestampMs: 7429.999828338623,
191
+ },
192
+ {
193
+ confidence: null,
194
+ endMs: 7820.000171661377,
195
+ startMs: 7679.999828338623,
196
+ text: " I'm",
197
+ timestampMs: 7750,
198
+ },
199
+ {
200
+ confidence: null,
201
+ endMs: 8180.000305175781,
202
+ startMs: 7820.000171661377,
203
+ text: ' excited',
204
+ timestampMs: 8000.000238418579,
205
+ },
206
+ {
207
+ confidence: null,
208
+ endMs: 8420.000076293945,
209
+ startMs: 8180.000305175781,
210
+ text: ' to',
211
+ timestampMs: 8300.000190734863,
212
+ },
213
+ {
214
+ confidence: null,
215
+ endMs: 8600.000381469727,
216
+ startMs: 8420.000076293945,
217
+ text: ' see',
218
+ timestampMs: 8510.000228881836,
219
+ },
220
+ {
221
+ confidence: null,
222
+ endMs: 8739.999771118164,
223
+ startMs: 8600.000381469727,
224
+ text: ' what',
225
+ timestampMs: 8670.000076293945,
226
+ },
227
+ {
228
+ confidence: null,
229
+ endMs: 8859.999656677246,
230
+ startMs: 8739.999771118164,
231
+ text: ' the',
232
+ timestampMs: 8799.999713897705,
233
+ },
234
+ {
235
+ confidence: null,
236
+ endMs: 9180.000305175781,
237
+ startMs: 8859.999656677246,
238
+ text: ' future',
239
+ timestampMs: 9019.999980926514,
240
+ },
241
+ {
242
+ confidence: null,
243
+ endMs: 9520.000457763672,
244
+ startMs: 9180.000305175781,
245
+ text: ' holds',
246
+ timestampMs: 9350.000381469727,
247
+ },
248
+ {
249
+ confidence: null,
250
+ endMs: 9779.999732971191,
251
+ startMs: 9520.000457763672,
252
+ text: ' for',
253
+ timestampMs: 9650.000095367432,
254
+ },
255
+ {
256
+ confidence: null,
257
+ endMs: 9979.999542236328,
258
+ startMs: 9779.999732971191,
259
+ text: ' all',
260
+ timestampMs: 9879.99963760376,
261
+ },
262
+ {
263
+ confidence: null,
264
+ endMs: 10079.999923706055,
265
+ startMs: 9979.999542236328,
266
+ text: ' of',
267
+ timestampMs: 10029.999732971191,
268
+ },
269
+ {
270
+ confidence: null,
271
+ endMs: 10340.00015258789,
272
+ startMs: 10079.999923706055,
273
+ text: ' us.',
274
+ timestampMs: 10210.000038146973,
275
+ },
276
+ ],
277
+ });
278
+ });
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "url": "https://github.com/remotion-dev/remotion/tree/main/packages/openai-whisper"
4
4
  },
5
5
  "name": "@remotion/openai-whisper",
6
- "version": "4.0.278",
6
+ "version": "4.0.280",
7
7
  "description": "Work with the output of the OpenAI Whisper API",
8
8
  "main": "dist/index.js",
9
9
  "sideEffects": false,
@@ -16,13 +16,13 @@
16
16
  "author": "Jonny Burger <jonny@remotion.dev>",
17
17
  "license": "MIT",
18
18
  "dependencies": {
19
- "@remotion/captions": "4.0.278"
19
+ "@remotion/captions": "4.0.280"
20
20
  },
21
21
  "peerDependencies": {},
22
22
  "devDependencies": {
23
23
  "openai": "4.67.1",
24
24
  "eslint": "9.19.0",
25
- "@remotion/eslint-config-internal": "4.0.278"
25
+ "@remotion/eslint-config-internal": "4.0.280"
26
26
  },
27
27
  "keywords": [
28
28
  "remotion"