@remotion/openai-whisper 4.0.458 → 4.0.460

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,6 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.openAiWhisperApiToCaptions = void 0;
4
+ const escapeRegex = (text) => {
5
+ return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
6
+ };
7
+ const apostropheVariants = ['\u0027', '\u2018', '\u2019', '\u02bc', '\uff07'];
8
+ const apostropheVariantRegex = `[${apostropheVariants.map(escapeRegex).join('')}]`;
9
+ const escapeWordForRegex = (text) => {
10
+ return Array.from(text)
11
+ .map((character) => {
12
+ return apostropheVariants.includes(character)
13
+ ? apostropheVariantRegex
14
+ : escapeRegex(character);
15
+ })
16
+ .join('');
17
+ };
4
18
  const openAiWhisperApiToCaptions = ({ transcription, }) => {
5
19
  const captions = [];
6
20
  if (!transcription.words) {
@@ -17,8 +31,9 @@ const openAiWhisperApiToCaptions = ({ transcription, }) => {
17
31
  if (firstWord) {
18
32
  word.word = word.word.trimStart();
19
33
  }
20
- const punctuation = `\\?,\\.\\%\\–\\!\\;\\:\\'\\"\\-\\_\\(\\)\\[\\]\\{\\}\\@\\#\\$\\^\\&\\*\\+\\=\\/\\|\\<\\>\\~\``;
21
- const match = new RegExp(`^([\\s?${punctuation}]{0,4})${word.word.replace(new RegExp(`^[${punctuation}]+`), '').replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}([${punctuation}]{0,3})?`).exec(remainingText);
34
+ const punctuation = `\\?,\\.\\%\\–\\!\\;\\:\\'\\"\\-\\_\\(\\)\\[\\]\\{\\}\\@\\#\\$\\^\\&\\*\\+\\=\\/\\|\\<\\>\\~\`\\u2018\\u2019\\u02bc\\uff07`;
35
+ const wordToMatch = word.word.replace(new RegExp(`^[${punctuation}]+`), '');
36
+ const match = new RegExp(`^([\\s?${punctuation}]{0,4})${escapeWordForRegex(wordToMatch)}([${punctuation}]{0,3})?`).exec(remainingText);
22
37
  if (!match) {
23
38
  throw new Error(`Unable to parse punctuation from OpenAI Whisper output. Could not find word "${word.word}" in text "${remainingText.slice(0, 100)}". File an issue under https://remotion.dev/issue and post the input for openAiWhisperApiToCaptions() to ask for a fix.`);
24
39
  }
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.458",
6
+ "version": "4.0.460",
7
7
  "description": "Work with the output of the OpenAI Whisper API",
8
8
  "main": "dist/index.js",
9
9
  "sideEffects": false,
@@ -20,12 +20,12 @@
20
20
  "author": "Jonny Burger <jonny@remotion.dev>",
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
- "@remotion/captions": "4.0.458"
23
+ "@remotion/captions": "4.0.460"
24
24
  },
25
25
  "peerDependencies": {},
26
26
  "devDependencies": {
27
27
  "openai": "4.67.1",
28
- "@remotion/eslint-config-internal": "4.0.458",
28
+ "@remotion/eslint-config-internal": "4.0.460",
29
29
  "eslint": "9.19.0",
30
30
  "@typescript/native-preview": "7.0.0-dev.20260217.1"
31
31
  },