@remotion/openai-whisper 4.0.228 → 4.0.229

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.
@@ -8,7 +8,7 @@ const openAiWhisperApiToCaptions = ({ transcription, }) => {
8
8
  }
9
9
  let remainingText = transcription.text;
10
10
  for (const word of transcription.words) {
11
- const match = new RegExp(`^([\\s\\.]{0,4})${word.word}([\\?,\\.]{0,3})?`).exec(remainingText);
11
+ const match = new RegExp(`^([\\s\\.]{0,4})${word.word}([\\?,\\.\\%\\–\\!\\;\\:\\'\\"\\-\\_\\(\\)\\[\\]\\{\\}\\@\\#\\$\\^\\&\\*\\+\\=\\/\\|\\<\\>\\~\`]{0,3})?`).exec(remainingText);
12
12
  if (!match) {
13
13
  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 to ask for a fix.`);
14
14
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,124 @@
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
+ const transcript1 = {
6
+ task: 'transcribe',
7
+ text: 'it is 99% better',
8
+ words: [
9
+ {
10
+ start: 1,
11
+ end: 2,
12
+ word: 'it',
13
+ },
14
+ {
15
+ start: 2,
16
+ end: 3,
17
+ word: 'is',
18
+ },
19
+ {
20
+ start: 3,
21
+ end: 4,
22
+ word: '99',
23
+ },
24
+ {
25
+ start: 4,
26
+ end: 5,
27
+ word: 'better',
28
+ },
29
+ ],
30
+ duration: 3,
31
+ language: 'english',
32
+ };
33
+ const transcript2 = {
34
+ task: 'transcribe',
35
+ text: 'in real-time functions.',
36
+ words: [
37
+ {
38
+ end: 1,
39
+ word: 'in',
40
+ start: 0,
41
+ },
42
+ {
43
+ end: 2,
44
+ word: 'real',
45
+ start: 1,
46
+ },
47
+ {
48
+ end: 3,
49
+ word: 'time',
50
+ start: 2,
51
+ },
52
+ {
53
+ end: 4,
54
+ word: 'functions',
55
+ start: 3,
56
+ },
57
+ ],
58
+ duration: 4,
59
+ language: 'english',
60
+ };
61
+ (0, bun_test_1.test)('Regression test 1', () => {
62
+ (0, bun_test_1.expect)((0, openai_whisper_api_to_captions_1.openAiWhisperApiToCaptions)({ transcription: transcript1 }).captions).toEqual([
63
+ {
64
+ confidence: null,
65
+ endMs: 2000,
66
+ startMs: 1000,
67
+ text: 'it',
68
+ timestampMs: 1500,
69
+ },
70
+ {
71
+ confidence: null,
72
+ endMs: 3000,
73
+ startMs: 2000,
74
+ text: ' is',
75
+ timestampMs: 2500,
76
+ },
77
+ {
78
+ confidence: null,
79
+ endMs: 4000,
80
+ startMs: 3000,
81
+ text: ' 99%',
82
+ timestampMs: 3500,
83
+ },
84
+ {
85
+ confidence: null,
86
+ endMs: 5000,
87
+ startMs: 4000,
88
+ text: ' better',
89
+ timestampMs: 4500,
90
+ },
91
+ ]);
92
+ });
93
+ (0, bun_test_1.test)('Regression test 2', () => {
94
+ (0, bun_test_1.expect)((0, openai_whisper_api_to_captions_1.openAiWhisperApiToCaptions)({ transcription: transcript2 }).captions).toEqual([
95
+ {
96
+ confidence: null,
97
+ endMs: 1000,
98
+ startMs: 0,
99
+ text: 'in',
100
+ timestampMs: 500,
101
+ },
102
+ {
103
+ confidence: null,
104
+ endMs: 2000,
105
+ startMs: 1000,
106
+ text: ' real-',
107
+ timestampMs: 1500,
108
+ },
109
+ {
110
+ confidence: null,
111
+ endMs: 3000,
112
+ startMs: 2000,
113
+ text: 'time',
114
+ timestampMs: 2500,
115
+ },
116
+ {
117
+ confidence: null,
118
+ endMs: 4000,
119
+ startMs: 3000,
120
+ text: ' functions.',
121
+ timestampMs: 3500,
122
+ },
123
+ ]);
124
+ });
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.228",
6
+ "version": "4.0.229",
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.228"
19
+ "@remotion/captions": "4.0.229"
20
20
  },
21
21
  "peerDependencies": {},
22
22
  "devDependencies": {
23
23
  "openai": "4.67.1",
24
24
  "eslint": "9.14.0",
25
- "@remotion/eslint-config-internal": "4.0.228"
25
+ "@remotion/eslint-config-internal": "4.0.229"
26
26
  },
27
27
  "keywords": [
28
28
  "remotion"