@remotion/openai-whisper 4.0.243 → 4.0.244
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.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}([\\?,\\.\\%\\–\\!\\;\\:\\'\\"\\-\\_\\(\\)\\[\\]\\{\\}\\@\\#\\$\\^\\&\\*\\+\\=\\/\\|\\<\\>\\~\`]{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
|
}
|
|
@@ -88,7 +88,7 @@ if (!process.env.CI) {
|
|
|
88
88
|
(0, bun_test_1.test)('Should convert to captions', async () => {
|
|
89
89
|
const openai = new openai_1.default();
|
|
90
90
|
const transcription = await openai.audio.transcriptions.create({
|
|
91
|
-
file: fs_1.default.createReadStream(path_1.default.join(__dirname, '..', '..', '..', 'template-audiogram', 'public', 'audio.
|
|
91
|
+
file: fs_1.default.createReadStream(path_1.default.join(__dirname, '..', '..', '..', 'template-audiogram', 'public', 'audio.wav')),
|
|
92
92
|
model: 'whisper-1',
|
|
93
93
|
response_format: 'verbose_json',
|
|
94
94
|
prompt: 'Hello, welcome to my lecture.',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,139 @@
|
|
|
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 text = ' $500 that you can spend on a computer right now.';
|
|
6
|
+
const transcript = {
|
|
7
|
+
task: 'transcribe',
|
|
8
|
+
text,
|
|
9
|
+
words: [
|
|
10
|
+
{
|
|
11
|
+
start: 1,
|
|
12
|
+
end: 2,
|
|
13
|
+
word: '$500',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
start: 3,
|
|
17
|
+
end: 4,
|
|
18
|
+
word: 'that',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
start: 5,
|
|
22
|
+
end: 6,
|
|
23
|
+
word: 'you',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
start: 7,
|
|
27
|
+
end: 8,
|
|
28
|
+
word: 'can',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
start: 9,
|
|
32
|
+
end: 10,
|
|
33
|
+
word: 'spend',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
start: 11,
|
|
37
|
+
end: 12,
|
|
38
|
+
word: 'on',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
start: 13,
|
|
42
|
+
end: 14,
|
|
43
|
+
word: 'a',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
start: 15,
|
|
47
|
+
end: 16,
|
|
48
|
+
word: 'computer',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
start: 17,
|
|
52
|
+
end: 18,
|
|
53
|
+
word: 'right',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
start: 19,
|
|
57
|
+
end: 20,
|
|
58
|
+
word: 'now.',
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
duration: 4,
|
|
62
|
+
language: 'english',
|
|
63
|
+
};
|
|
64
|
+
(0, bun_test_1.test)('should not crash', () => {
|
|
65
|
+
(0, bun_test_1.expect)((0, openai_whisper_api_to_captions_1.openAiWhisperApiToCaptions)({ transcription: transcript })).toEqual({
|
|
66
|
+
captions: [
|
|
67
|
+
{
|
|
68
|
+
confidence: null,
|
|
69
|
+
endMs: 2000,
|
|
70
|
+
startMs: 1000,
|
|
71
|
+
text: ' $500',
|
|
72
|
+
timestampMs: 1500,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
confidence: null,
|
|
76
|
+
endMs: 4000,
|
|
77
|
+
startMs: 3000,
|
|
78
|
+
text: ' that',
|
|
79
|
+
timestampMs: 3500,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
confidence: null,
|
|
83
|
+
endMs: 6000,
|
|
84
|
+
startMs: 5000,
|
|
85
|
+
text: ' you',
|
|
86
|
+
timestampMs: 5500,
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
confidence: null,
|
|
90
|
+
endMs: 8000,
|
|
91
|
+
startMs: 7000,
|
|
92
|
+
text: ' can',
|
|
93
|
+
timestampMs: 7500,
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
confidence: null,
|
|
97
|
+
endMs: 10000,
|
|
98
|
+
startMs: 9000,
|
|
99
|
+
text: ' spend',
|
|
100
|
+
timestampMs: 9500,
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
confidence: null,
|
|
104
|
+
endMs: 12000,
|
|
105
|
+
startMs: 11000,
|
|
106
|
+
text: ' on',
|
|
107
|
+
timestampMs: 11500,
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
confidence: null,
|
|
111
|
+
endMs: 14000,
|
|
112
|
+
startMs: 13000,
|
|
113
|
+
text: ' a',
|
|
114
|
+
timestampMs: 13500,
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
confidence: null,
|
|
118
|
+
endMs: 16000,
|
|
119
|
+
startMs: 15000,
|
|
120
|
+
text: ' computer',
|
|
121
|
+
timestampMs: 15500,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
confidence: null,
|
|
125
|
+
endMs: 18000,
|
|
126
|
+
startMs: 17000,
|
|
127
|
+
text: ' right',
|
|
128
|
+
timestampMs: 17500,
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
confidence: null,
|
|
132
|
+
endMs: 20000,
|
|
133
|
+
startMs: 19000,
|
|
134
|
+
text: ' now.',
|
|
135
|
+
timestampMs: 19500,
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
});
|
|
139
|
+
});
|
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.
|
|
6
|
+
"version": "4.0.244",
|
|
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.
|
|
19
|
+
"@remotion/captions": "4.0.244"
|
|
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.
|
|
25
|
+
"@remotion/eslint-config-internal": "4.0.244"
|
|
26
26
|
},
|
|
27
27
|
"keywords": [
|
|
28
28
|
"remotion"
|