@livekit/agents 0.4.6 → 0.5.1
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.
- package/README.md +17 -0
- package/dist/audio.cjs +77 -0
- package/dist/audio.cjs.map +1 -0
- package/dist/audio.js +48 -37
- package/dist/audio.js.map +1 -1
- package/dist/cli.cjs +131 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.js +96 -122
- package/dist/cli.js.map +1 -1
- package/dist/generator.cjs +36 -0
- package/dist/generator.cjs.map +1 -0
- package/dist/generator.js +8 -22
- package/dist/generator.js.map +1 -1
- package/dist/http_server.cjs +72 -0
- package/dist/http_server.cjs.map +1 -0
- package/dist/http_server.d.ts +1 -1
- package/dist/http_server.js +44 -47
- package/dist/http_server.js.map +1 -1
- package/dist/index.cjs +78 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +26 -28
- package/dist/index.js.map +1 -1
- package/dist/ipc/job_executor.cjs +33 -0
- package/dist/ipc/job_executor.cjs.map +1 -0
- package/dist/ipc/job_executor.js +7 -4
- package/dist/ipc/job_executor.js.map +1 -1
- package/dist/ipc/job_main.cjs +147 -0
- package/dist/ipc/job_main.cjs.map +1 -0
- package/dist/ipc/job_main.d.ts +1 -1
- package/dist/ipc/job_main.js +103 -103
- package/dist/ipc/job_main.js.map +1 -1
- package/dist/ipc/message.cjs +17 -0
- package/dist/ipc/message.cjs.map +1 -0
- package/dist/ipc/message.js +0 -1
- package/dist/ipc/message.js.map +1 -1
- package/dist/ipc/proc_job_executor.cjs +174 -0
- package/dist/ipc/proc_job_executor.cjs.map +1 -0
- package/dist/ipc/proc_job_executor.js +130 -126
- package/dist/ipc/proc_job_executor.js.map +1 -1
- package/dist/ipc/proc_pool.cjs +126 -0
- package/dist/ipc/proc_pool.cjs.map +1 -0
- package/dist/ipc/proc_pool.js +93 -96
- package/dist/ipc/proc_pool.js.map +1 -1
- package/dist/job.cjs +230 -0
- package/dist/job.cjs.map +1 -0
- package/dist/job.d.ts +6 -1
- package/dist/job.d.ts.map +1 -1
- package/dist/job.js +195 -198
- package/dist/job.js.map +1 -1
- package/dist/llm/chat_context.cjs +131 -0
- package/dist/llm/chat_context.cjs.map +1 -0
- package/dist/llm/chat_context.js +98 -86
- package/dist/llm/chat_context.js.map +1 -1
- package/dist/llm/function_context.cjs +103 -0
- package/dist/llm/function_context.cjs.map +1 -0
- package/dist/llm/function_context.js +72 -81
- package/dist/llm/function_context.js.map +1 -1
- package/dist/llm/function_context.test.cjs +218 -0
- package/dist/llm/function_context.test.cjs.map +1 -0
- package/dist/llm/function_context.test.js +209 -210
- package/dist/llm/function_context.test.js.map +1 -1
- package/dist/llm/index.cjs +43 -0
- package/dist/llm/index.cjs.map +1 -0
- package/dist/llm/index.js +22 -6
- package/dist/llm/index.js.map +1 -1
- package/dist/llm/llm.cjs +76 -0
- package/dist/llm/llm.cjs.map +1 -0
- package/dist/llm/llm.js +48 -42
- package/dist/llm/llm.js.map +1 -1
- package/dist/log.cjs +57 -0
- package/dist/log.cjs.map +1 -0
- package/dist/log.js +27 -26
- package/dist/log.js.map +1 -1
- package/dist/multimodal/agent_playout.cjs +228 -0
- package/dist/multimodal/agent_playout.cjs.map +1 -0
- package/dist/multimodal/agent_playout.d.ts +1 -1
- package/dist/multimodal/agent_playout.js +193 -180
- package/dist/multimodal/agent_playout.js.map +1 -1
- package/dist/multimodal/index.cjs +25 -0
- package/dist/multimodal/index.cjs.map +1 -0
- package/dist/multimodal/index.js +2 -5
- package/dist/multimodal/index.js.map +1 -1
- package/dist/multimodal/multimodal_agent.cjs +404 -0
- package/dist/multimodal/multimodal_agent.cjs.map +1 -0
- package/dist/multimodal/multimodal_agent.d.ts +1 -1
- package/dist/multimodal/multimodal_agent.js +351 -330
- package/dist/multimodal/multimodal_agent.js.map +1 -1
- package/dist/pipeline/agent_output.cjs +172 -0
- package/dist/pipeline/agent_output.cjs.map +1 -0
- package/dist/pipeline/agent_output.js +136 -138
- package/dist/pipeline/agent_output.js.map +1 -1
- package/dist/pipeline/agent_playout.cjs +169 -0
- package/dist/pipeline/agent_playout.cjs.map +1 -0
- package/dist/pipeline/agent_playout.js +126 -136
- package/dist/pipeline/agent_playout.js.map +1 -1
- package/dist/pipeline/human_input.cjs +158 -0
- package/dist/pipeline/human_input.cjs.map +1 -0
- package/dist/pipeline/human_input.js +124 -125
- package/dist/pipeline/human_input.js.map +1 -1
- package/dist/pipeline/index.cjs +31 -0
- package/dist/pipeline/index.cjs.map +1 -0
- package/dist/pipeline/index.js +8 -4
- package/dist/pipeline/index.js.map +1 -1
- package/dist/pipeline/pipeline_agent.cjs +642 -0
- package/dist/pipeline/pipeline_agent.cjs.map +1 -0
- package/dist/pipeline/pipeline_agent.js +595 -651
- package/dist/pipeline/pipeline_agent.js.map +1 -1
- package/dist/pipeline/speech_handle.cjs +128 -0
- package/dist/pipeline/speech_handle.cjs.map +1 -0
- package/dist/pipeline/speech_handle.js +102 -100
- package/dist/pipeline/speech_handle.js.map +1 -1
- package/dist/plugin.cjs +46 -0
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.js +20 -20
- package/dist/plugin.js.map +1 -1
- package/dist/stt/index.cjs +38 -0
- package/dist/stt/index.cjs.map +1 -0
- package/dist/stt/index.js +13 -5
- package/dist/stt/index.js.map +1 -1
- package/dist/stt/stream_adapter.cjs +87 -0
- package/dist/stt/stream_adapter.cjs.map +1 -0
- package/dist/stt/stream_adapter.js +58 -55
- package/dist/stt/stream_adapter.js.map +1 -1
- package/dist/stt/stt.cjs +98 -0
- package/dist/stt/stt.cjs.map +1 -0
- package/dist/stt/stt.js +63 -98
- package/dist/stt/stt.js.map +1 -1
- package/dist/tokenize/basic/basic.cjs +98 -0
- package/dist/tokenize/basic/basic.cjs.map +1 -0
- package/dist/tokenize/basic/basic.d.ts +1 -1
- package/dist/tokenize/basic/basic.d.ts.map +1 -1
- package/dist/tokenize/basic/basic.js +56 -45
- package/dist/tokenize/basic/basic.js.map +1 -1
- package/dist/tokenize/basic/hyphenator.cjs +425 -0
- package/dist/tokenize/basic/hyphenator.cjs.map +1 -0
- package/dist/tokenize/basic/hyphenator.js +66 -82
- package/dist/tokenize/basic/hyphenator.js.map +1 -1
- package/dist/tokenize/basic/index.cjs +35 -0
- package/dist/tokenize/basic/index.cjs.map +1 -0
- package/dist/tokenize/basic/index.js +7 -4
- package/dist/tokenize/basic/index.js.map +1 -1
- package/dist/tokenize/basic/paragraph.cjs +57 -0
- package/dist/tokenize/basic/paragraph.cjs.map +1 -0
- package/dist/tokenize/basic/paragraph.js +30 -35
- package/dist/tokenize/basic/paragraph.js.map +1 -1
- package/dist/tokenize/basic/sentence.cjs +89 -0
- package/dist/tokenize/basic/sentence.cjs.map +1 -0
- package/dist/tokenize/basic/sentence.d.ts.map +1 -1
- package/dist/tokenize/basic/sentence.js +62 -57
- package/dist/tokenize/basic/sentence.js.map +1 -1
- package/dist/tokenize/basic/word.cjs +44 -0
- package/dist/tokenize/basic/word.cjs.map +1 -0
- package/dist/tokenize/basic/word.js +17 -20
- package/dist/tokenize/basic/word.js.map +1 -1
- package/dist/tokenize/index.cjs +55 -0
- package/dist/tokenize/index.cjs.map +1 -0
- package/dist/tokenize/index.js +18 -7
- package/dist/tokenize/index.js.map +1 -1
- package/dist/tokenize/token_stream.cjs +164 -0
- package/dist/tokenize/token_stream.cjs.map +1 -0
- package/dist/tokenize/token_stream.js +133 -139
- package/dist/tokenize/token_stream.js.map +1 -1
- package/dist/tokenize/tokenizer.cjs +184 -0
- package/dist/tokenize/tokenizer.cjs.map +1 -0
- package/dist/tokenize/tokenizer.js +138 -99
- package/dist/tokenize/tokenizer.js.map +1 -1
- package/dist/tokenize/tokenizer.test.cjs +220 -0
- package/dist/tokenize/tokenizer.test.cjs.map +1 -0
- package/dist/tokenize/tokenizer.test.d.ts +2 -0
- package/dist/tokenize/tokenizer.test.d.ts.map +1 -0
- package/dist/tokenize/tokenizer.test.js +219 -0
- package/dist/tokenize/tokenizer.test.js.map +1 -0
- package/dist/transcription.cjs +131 -0
- package/dist/transcription.cjs.map +1 -0
- package/dist/transcription.js +99 -96
- package/dist/transcription.js.map +1 -1
- package/dist/tts/index.cjs +38 -0
- package/dist/tts/index.cjs.map +1 -0
- package/dist/tts/index.js +13 -5
- package/dist/tts/index.js.map +1 -1
- package/dist/tts/stream_adapter.cjs +78 -0
- package/dist/tts/stream_adapter.cjs.map +1 -0
- package/dist/tts/stream_adapter.js +50 -47
- package/dist/tts/stream_adapter.js.map +1 -1
- package/dist/tts/tts.cjs +127 -0
- package/dist/tts/tts.cjs.map +1 -0
- package/dist/tts/tts.js +90 -120
- package/dist/tts/tts.js.map +1 -1
- package/dist/utils.cjs +284 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.js +242 -247
- package/dist/utils.js.map +1 -1
- package/dist/vad.cjs +92 -0
- package/dist/vad.cjs.map +1 -0
- package/dist/vad.js +57 -52
- package/dist/vad.js.map +1 -1
- package/dist/version.cjs +29 -0
- package/dist/version.cjs.map +1 -0
- package/dist/version.js +4 -4
- package/dist/version.js.map +1 -1
- package/dist/worker.cjs +577 -0
- package/dist/worker.cjs.map +1 -0
- package/dist/worker.d.ts +1 -1
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +512 -484
- package/dist/worker.js.map +1 -1
- package/package.json +18 -8
- package/src/ipc/job_main.ts +66 -64
- package/src/job.ts +3 -2
- package/src/pipeline/pipeline_agent.ts +23 -23
- package/src/tokenize/basic/basic.ts +1 -1
- package/src/tokenize/basic/sentence.ts +14 -8
- package/src/tokenize/tokenizer.test.ts +255 -0
- package/src/worker.ts +1 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { SentenceTokenizer, WordTokenizer, hyphenateWord } from "./basic/index.js";
|
|
3
|
+
import { splitParagraphs } from "./basic/paragraph.js";
|
|
4
|
+
const TEXT = "Hi! LiveKit is a platform for live audio and video applications and services. R.T.C stands for Real-Time Communication... again R.T.C. Mr. Theo is testing the sentence tokenizer. This is a test. Another test. A short sentence. A longer sentence that is longer than the previous sentence. f(x) = x * 2.54 + 42. Hey! Hi! Hello! ";
|
|
5
|
+
const EXPECTED_MIN_20 = [
|
|
6
|
+
"Hi! LiveKit is a platform for live audio and video applications and services.",
|
|
7
|
+
"R.T.C stands for Real-Time Communication... again R.T.C.",
|
|
8
|
+
"Mr. Theo is testing the sentence tokenizer.",
|
|
9
|
+
"This is a test. Another test.",
|
|
10
|
+
"A short sentence. A longer sentence that is longer than the previous sentence.",
|
|
11
|
+
"f(x) = x * 2.54 + 42.",
|
|
12
|
+
"Hey! Hi! Hello!"
|
|
13
|
+
];
|
|
14
|
+
const WORDS_TEXT = "This is a test. Blabla another test! multiple consecutive spaces: done";
|
|
15
|
+
const WORDS_EXPECTED = [
|
|
16
|
+
"This",
|
|
17
|
+
"is",
|
|
18
|
+
"a",
|
|
19
|
+
"test",
|
|
20
|
+
"Blabla",
|
|
21
|
+
"another",
|
|
22
|
+
"test",
|
|
23
|
+
"multiple",
|
|
24
|
+
"consecutive",
|
|
25
|
+
"spaces",
|
|
26
|
+
"done"
|
|
27
|
+
];
|
|
28
|
+
const WORDS_PUNCT_TEXT = 'This is <phoneme alphabet="cmu-arpabet" ph="AE K CH UW AH L IY">actually</phoneme> tricky to handle.';
|
|
29
|
+
const WORDS_PUNCT_EXPECTED = [
|
|
30
|
+
"This",
|
|
31
|
+
"is",
|
|
32
|
+
"<phoneme",
|
|
33
|
+
'alphabet="cmu-arpabet"',
|
|
34
|
+
'ph="AE',
|
|
35
|
+
"K",
|
|
36
|
+
"CH",
|
|
37
|
+
"UW",
|
|
38
|
+
"AH",
|
|
39
|
+
"L",
|
|
40
|
+
'IY">actually</phoneme>',
|
|
41
|
+
"tricky",
|
|
42
|
+
"to",
|
|
43
|
+
"handle."
|
|
44
|
+
];
|
|
45
|
+
const HYPHENATOR_TEXT = ["Segment", "expected", "communication", "window", "welcome", "bedroom"];
|
|
46
|
+
const HYPHENATOR_EXPECTED = [
|
|
47
|
+
["Seg", "ment"],
|
|
48
|
+
["ex", "pect", "ed"],
|
|
49
|
+
["com", "mu", "ni", "ca", "tion"],
|
|
50
|
+
["win", "dow"],
|
|
51
|
+
["wel", "come"],
|
|
52
|
+
["bed", "room"]
|
|
53
|
+
];
|
|
54
|
+
const PARAGRAPH_TEST_CASES = [
|
|
55
|
+
["Single paragraph.", [["Single paragraph.", 0, 17]]],
|
|
56
|
+
[
|
|
57
|
+
"Paragraph 1.\n\nParagraph 2.",
|
|
58
|
+
[
|
|
59
|
+
["Paragraph 1.", 0, 12],
|
|
60
|
+
["Paragraph 2.", 14, 26]
|
|
61
|
+
]
|
|
62
|
+
],
|
|
63
|
+
[
|
|
64
|
+
"Para 1.\n\nPara 2.\n\nPara 3.",
|
|
65
|
+
[
|
|
66
|
+
["Para 1.", 0, 7],
|
|
67
|
+
["Para 2.", 9, 16],
|
|
68
|
+
["Para 3.", 18, 25]
|
|
69
|
+
]
|
|
70
|
+
],
|
|
71
|
+
["\n\nParagraph with leading newlines.", [["Paragraph with leading newlines.", 2, 34]]],
|
|
72
|
+
["Paragraph with trailing newlines.\n\n", [["Paragraph with trailing newlines.", 0, 33]]],
|
|
73
|
+
[
|
|
74
|
+
"\n\n Paragraph with leading and trailing spaces. \n\n",
|
|
75
|
+
[["Paragraph with leading and trailing spaces.", 4, 47]]
|
|
76
|
+
],
|
|
77
|
+
[
|
|
78
|
+
"Para 1.\n\n\n\nPara 2.",
|
|
79
|
+
// Multiple newlines between paragraphs
|
|
80
|
+
[
|
|
81
|
+
["Para 1.", 0, 7],
|
|
82
|
+
["Para 2.", 11, 18]
|
|
83
|
+
]
|
|
84
|
+
],
|
|
85
|
+
[
|
|
86
|
+
"Para 1.\n \n \nPara 2.",
|
|
87
|
+
// Newlines with spaces between paragraphs
|
|
88
|
+
[
|
|
89
|
+
["Para 1.", 0, 7],
|
|
90
|
+
["Para 2.", 12, 19]
|
|
91
|
+
]
|
|
92
|
+
],
|
|
93
|
+
[
|
|
94
|
+
"",
|
|
95
|
+
// Empty string
|
|
96
|
+
[]
|
|
97
|
+
],
|
|
98
|
+
[
|
|
99
|
+
"\n\n\n",
|
|
100
|
+
// Only newlines
|
|
101
|
+
[]
|
|
102
|
+
],
|
|
103
|
+
[
|
|
104
|
+
"Line 1\nLine 2\nLine 3",
|
|
105
|
+
// Single paragraph with newlines
|
|
106
|
+
[["Line 1\nLine 2\nLine 3", 0, 20]]
|
|
107
|
+
]
|
|
108
|
+
];
|
|
109
|
+
describe("tokenizer", () => {
|
|
110
|
+
describe("SentenceTokenizer", () => {
|
|
111
|
+
const tokenizer = new SentenceTokenizer();
|
|
112
|
+
it("should tokenize sentences correctly", () => {
|
|
113
|
+
expect(tokenizer.tokenize(TEXT).every((x, i) => EXPECTED_MIN_20[i] === x)).toBeTruthy();
|
|
114
|
+
});
|
|
115
|
+
it("should stream tokenize sentences correctly", async () => {
|
|
116
|
+
const pattern = [1, 2, 4];
|
|
117
|
+
let text = TEXT;
|
|
118
|
+
const chunks = [];
|
|
119
|
+
const patternIter = Array(Math.ceil(text.length / pattern.reduce((sum, num) => sum + num, 0))).fill(pattern).flat()[Symbol.iterator]();
|
|
120
|
+
for (const size of patternIter) {
|
|
121
|
+
if (!text) break;
|
|
122
|
+
chunks.push(text.slice(void 0, size));
|
|
123
|
+
text = text.slice(size);
|
|
124
|
+
}
|
|
125
|
+
const stream = tokenizer.stream();
|
|
126
|
+
for (const chunk of chunks) {
|
|
127
|
+
stream.pushText(chunk);
|
|
128
|
+
}
|
|
129
|
+
stream.endInput();
|
|
130
|
+
stream.close();
|
|
131
|
+
for (const x of EXPECTED_MIN_20) {
|
|
132
|
+
await stream.next().then((value) => {
|
|
133
|
+
if (value.value) {
|
|
134
|
+
expect(value.value.token).toStrictEqual(x);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
describe("WordTokenizer", () => {
|
|
141
|
+
const tokenizer = new WordTokenizer();
|
|
142
|
+
it("should tokenize words correctly", () => {
|
|
143
|
+
expect(tokenizer.tokenize(WORDS_TEXT).every((x, i) => WORDS_EXPECTED[i] === x)).toBeTruthy();
|
|
144
|
+
});
|
|
145
|
+
it("should stream tokenize words correctly", async () => {
|
|
146
|
+
const pattern = [1, 2, 4];
|
|
147
|
+
let text = WORDS_TEXT;
|
|
148
|
+
const chunks = [];
|
|
149
|
+
const patternIter = Array(Math.ceil(text.length / pattern.reduce((sum, num) => sum + num, 0))).fill(pattern).flat()[Symbol.iterator]();
|
|
150
|
+
for (const size of patternIter) {
|
|
151
|
+
if (!text) break;
|
|
152
|
+
chunks.push(text.slice(void 0, size));
|
|
153
|
+
text = text.slice(size);
|
|
154
|
+
}
|
|
155
|
+
const stream = tokenizer.stream();
|
|
156
|
+
for (const chunk of chunks) {
|
|
157
|
+
stream.pushText(chunk);
|
|
158
|
+
}
|
|
159
|
+
stream.endInput();
|
|
160
|
+
stream.close();
|
|
161
|
+
for (const x of WORDS_EXPECTED) {
|
|
162
|
+
await stream.next().then((value) => {
|
|
163
|
+
if (value.value) {
|
|
164
|
+
expect(value.value.token).toStrictEqual(x);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
describe("punctuation handling", () => {
|
|
170
|
+
const tokenizerPunct = new WordTokenizer(false);
|
|
171
|
+
it("should tokenize words correctly", () => {
|
|
172
|
+
expect(
|
|
173
|
+
tokenizerPunct.tokenize(WORDS_PUNCT_TEXT).every((x, i) => WORDS_PUNCT_EXPECTED[i] === x)
|
|
174
|
+
).toBeTruthy();
|
|
175
|
+
});
|
|
176
|
+
it("should stream tokenize words correctly", async () => {
|
|
177
|
+
const pattern = [1, 2, 4];
|
|
178
|
+
let text = WORDS_PUNCT_TEXT;
|
|
179
|
+
const chunks = [];
|
|
180
|
+
const patternIter = Array(
|
|
181
|
+
Math.ceil(text.length / pattern.reduce((sum, num) => sum + num, 0))
|
|
182
|
+
).fill(pattern).flat()[Symbol.iterator]();
|
|
183
|
+
for (const size of patternIter) {
|
|
184
|
+
if (!text) break;
|
|
185
|
+
chunks.push(text.slice(void 0, size));
|
|
186
|
+
text = text.slice(size);
|
|
187
|
+
}
|
|
188
|
+
const stream = tokenizerPunct.stream();
|
|
189
|
+
for (const chunk of chunks) {
|
|
190
|
+
stream.pushText(chunk);
|
|
191
|
+
}
|
|
192
|
+
stream.endInput();
|
|
193
|
+
stream.close();
|
|
194
|
+
for (const x of WORDS_PUNCT_EXPECTED) {
|
|
195
|
+
await stream.next().then((value) => {
|
|
196
|
+
if (value.value) {
|
|
197
|
+
expect(value.value.token).toStrictEqual(x);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
describe("hyphenateWord", () => {
|
|
205
|
+
it("should hyphenate correctly", () => {
|
|
206
|
+
HYPHENATOR_TEXT.forEach((x, i) => {
|
|
207
|
+
expect(hyphenateWord(x)).toStrictEqual(HYPHENATOR_EXPECTED[i]);
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
describe("splitParagraphs", () => {
|
|
212
|
+
it("should tokenize paragraphs correctly", () => {
|
|
213
|
+
PARAGRAPH_TEST_CASES.forEach(([a, b]) => {
|
|
214
|
+
expect(splitParagraphs(a)).toStrictEqual(b);
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
//# sourceMappingURL=tokenizer.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/tokenize/tokenizer.test.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { describe, expect, it } from 'vitest';\nimport { SentenceTokenizer, WordTokenizer, hyphenateWord } from './basic/index.js';\nimport { splitParagraphs } from './basic/paragraph.js';\n\nconst TEXT =\n 'Hi! ' +\n 'LiveKit is a platform for live audio and video applications and services. ' +\n 'R.T.C stands for Real-Time Communication... again R.T.C. ' +\n 'Mr. Theo is testing the sentence tokenizer. ' +\n 'This is a test. Another test. ' +\n 'A short sentence. ' +\n 'A longer sentence that is longer than the previous sentence. ' +\n 'f(x) = x * 2.54 + 42. ' +\n 'Hey! Hi! Hello! ';\n\nconst EXPECTED_MIN_20 = [\n 'Hi! LiveKit is a platform for live audio and video applications and services.',\n 'R.T.C stands for Real-Time Communication... again R.T.C.',\n 'Mr. Theo is testing the sentence tokenizer.',\n 'This is a test. Another test.',\n 'A short sentence. A longer sentence that is longer than the previous sentence.',\n 'f(x) = x * 2.54 + 42.',\n 'Hey! Hi! Hello!',\n];\n\nconst WORDS_TEXT = 'This is a test. Blabla another test! multiple consecutive spaces: done';\nconst WORDS_EXPECTED = [\n 'This',\n 'is',\n 'a',\n 'test',\n 'Blabla',\n 'another',\n 'test',\n 'multiple',\n 'consecutive',\n 'spaces',\n 'done',\n];\n\nconst WORDS_PUNCT_TEXT =\n 'This is <phoneme alphabet=\"cmu-arpabet\" ph=\"AE K CH UW AH L IY\">actually</phoneme> tricky to handle.';\nconst WORDS_PUNCT_EXPECTED = [\n 'This',\n 'is',\n '<phoneme',\n 'alphabet=\"cmu-arpabet\"',\n 'ph=\"AE',\n 'K',\n 'CH',\n 'UW',\n 'AH',\n 'L',\n 'IY\">actually</phoneme>',\n 'tricky',\n 'to',\n 'handle.',\n];\n\nconst HYPHENATOR_TEXT = ['Segment', 'expected', 'communication', 'window', 'welcome', 'bedroom'];\nconst HYPHENATOR_EXPECTED = [\n ['Seg', 'ment'],\n ['ex', 'pect', 'ed'],\n ['com', 'mu', 'ni', 'ca', 'tion'],\n ['win', 'dow'],\n ['wel', 'come'],\n ['bed', 'room'],\n];\n\nconst PARAGRAPH_TEST_CASES: [string, [string, number, number][]][] = [\n ['Single paragraph.', [['Single paragraph.', 0, 17]]],\n [\n 'Paragraph 1.\\n\\nParagraph 2.',\n [\n ['Paragraph 1.', 0, 12],\n ['Paragraph 2.', 14, 26],\n ],\n ],\n [\n 'Para 1.\\n\\nPara 2.\\n\\nPara 3.',\n [\n ['Para 1.', 0, 7],\n ['Para 2.', 9, 16],\n ['Para 3.', 18, 25],\n ],\n ],\n ['\\n\\nParagraph with leading newlines.', [['Paragraph with leading newlines.', 2, 34]]],\n ['Paragraph with trailing newlines.\\n\\n', [['Paragraph with trailing newlines.', 0, 33]]],\n [\n '\\n\\n Paragraph with leading and trailing spaces. \\n\\n',\n [['Paragraph with leading and trailing spaces.', 4, 47]],\n ],\n [\n 'Para 1.\\n\\n\\n\\nPara 2.', // Multiple newlines between paragraphs\n [\n ['Para 1.', 0, 7],\n ['Para 2.', 11, 18],\n ],\n ],\n [\n 'Para 1.\\n \\n \\nPara 2.', // Newlines with spaces between paragraphs\n [\n ['Para 1.', 0, 7],\n ['Para 2.', 12, 19],\n ],\n ],\n [\n '', // Empty string\n [],\n ],\n [\n '\\n\\n\\n', // Only newlines\n [],\n ],\n [\n 'Line 1\\nLine 2\\nLine 3', // Single paragraph with newlines\n [['Line 1\\nLine 2\\nLine 3', 0, 20]],\n ],\n];\n\ndescribe('tokenizer', () => {\n describe('SentenceTokenizer', () => {\n const tokenizer = new SentenceTokenizer();\n\n it('should tokenize sentences correctly', () => {\n expect(tokenizer.tokenize(TEXT).every((x, i) => EXPECTED_MIN_20[i] === x)).toBeTruthy();\n });\n\n it('should stream tokenize sentences correctly', async () => {\n const pattern = [1, 2, 4];\n let text = TEXT;\n const chunks = [];\n const patternIter = Array(Math.ceil(text.length / pattern.reduce((sum, num) => sum + num, 0)))\n .fill(pattern)\n .flat()\n [Symbol.iterator]();\n\n for (const size of patternIter) {\n if (!text) break;\n chunks.push(text.slice(undefined, size));\n text = text.slice(size);\n }\n const stream = tokenizer.stream();\n for (const chunk of chunks) {\n stream.pushText(chunk);\n }\n stream.endInput();\n stream.close();\n\n for (const x of EXPECTED_MIN_20) {\n await stream.next().then((value) => {\n if (value.value) {\n expect(value.value.token).toStrictEqual(x);\n }\n });\n }\n });\n });\n describe('WordTokenizer', () => {\n const tokenizer = new WordTokenizer();\n\n it('should tokenize words correctly', () => {\n expect(tokenizer.tokenize(WORDS_TEXT).every((x, i) => WORDS_EXPECTED[i] === x)).toBeTruthy();\n });\n\n it('should stream tokenize words correctly', async () => {\n const pattern = [1, 2, 4];\n let text = WORDS_TEXT;\n const chunks = [];\n const patternIter = Array(Math.ceil(text.length / pattern.reduce((sum, num) => sum + num, 0)))\n .fill(pattern)\n .flat()\n [Symbol.iterator]();\n\n for (const size of patternIter) {\n if (!text) break;\n chunks.push(text.slice(undefined, size));\n text = text.slice(size);\n }\n const stream = tokenizer.stream();\n for (const chunk of chunks) {\n stream.pushText(chunk);\n }\n stream.endInput();\n stream.close();\n\n for (const x of WORDS_EXPECTED) {\n await stream.next().then((value) => {\n if (value.value) {\n expect(value.value.token).toStrictEqual(x);\n }\n });\n }\n });\n\n describe('punctuation handling', () => {\n const tokenizerPunct = new WordTokenizer(false);\n\n it('should tokenize words correctly', () => {\n expect(\n tokenizerPunct.tokenize(WORDS_PUNCT_TEXT).every((x, i) => WORDS_PUNCT_EXPECTED[i] === x),\n ).toBeTruthy();\n });\n\n it('should stream tokenize words correctly', async () => {\n const pattern = [1, 2, 4];\n let text = WORDS_PUNCT_TEXT;\n const chunks = [];\n const patternIter = Array(\n Math.ceil(text.length / pattern.reduce((sum, num) => sum + num, 0)),\n )\n .fill(pattern)\n .flat()\n [Symbol.iterator]();\n\n for (const size of patternIter) {\n if (!text) break;\n chunks.push(text.slice(undefined, size));\n text = text.slice(size);\n }\n const stream = tokenizerPunct.stream();\n for (const chunk of chunks) {\n stream.pushText(chunk);\n }\n stream.endInput();\n stream.close();\n\n for (const x of WORDS_PUNCT_EXPECTED) {\n await stream.next().then((value) => {\n if (value.value) {\n expect(value.value.token).toStrictEqual(x);\n }\n });\n }\n });\n });\n });\n describe('hyphenateWord', () => {\n it('should hyphenate correctly', () => {\n HYPHENATOR_TEXT.forEach((x, i) => {\n expect(hyphenateWord(x)).toStrictEqual(HYPHENATOR_EXPECTED[i]);\n });\n });\n });\n describe('splitParagraphs', () => {\n it('should tokenize paragraphs correctly', () => {\n PARAGRAPH_TEST_CASES.forEach(([a, b]) => {\n expect(splitParagraphs(a)).toStrictEqual(b);\n });\n });\n });\n});\n"],"mappings":"AAGA,SAAS,UAAU,QAAQ,UAAU;AACrC,SAAS,mBAAmB,eAAe,qBAAqB;AAChE,SAAS,uBAAuB;AAEhC,MAAM,OACJ;AAUF,MAAM,kBAAkB;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,aAAa;AACnB,MAAM,iBAAiB;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,mBACJ;AACF,MAAM,uBAAuB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,kBAAkB,CAAC,WAAW,YAAY,iBAAiB,UAAU,WAAW,SAAS;AAC/F,MAAM,sBAAsB;AAAA,EAC1B,CAAC,OAAO,MAAM;AAAA,EACd,CAAC,MAAM,QAAQ,IAAI;AAAA,EACnB,CAAC,OAAO,MAAM,MAAM,MAAM,MAAM;AAAA,EAChC,CAAC,OAAO,KAAK;AAAA,EACb,CAAC,OAAO,MAAM;AAAA,EACd,CAAC,OAAO,MAAM;AAChB;AAEA,MAAM,uBAA+D;AAAA,EACnE,CAAC,qBAAqB,CAAC,CAAC,qBAAqB,GAAG,EAAE,CAAC,CAAC;AAAA,EACpD;AAAA,IACE;AAAA,IACA;AA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M;AAEb,mBAAW,KAAK,sBAAsB;AACpC,gBAAM,OAAO,KAAK,EAAE,KAAK,CAAC,UAAU;AAClC,gBAAI,MAAM,OAAO;AACf,qBAAO,MAAM,MAAM,KAAK,EAAE,cAAc,CAAC;AAAA,YAC3C;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC;AACD,WAAS,iBAAiB,MAAM;AAC9B,OAAG,8BAA8B,MAAM;AACrC,sBAAgB,QAAQ,CAAC,GAAG,MAAM;AAChC,eAAO,cAAc,CAAC,CAAC,EAAE,cAAc,oBAAoB,CAAC,CAAC;AAAA,MAC/D,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC;AACD,WAAS,mBAAmB,MAAM;AAChC,OAAG,wCAAwC,MAAM;AAC/C,2BAAqB,QAAQ,CAAC,CAAC,GAAG,CAAC,MAAM;AACvC,eAAO,gBAAgB,CAAC,CAAC,EAAE,cAAc,CAAC;AAAA,MAC5C,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC;AACH,CAAC;","names":[]}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var transcription_exports = {};
|
|
20
|
+
__export(transcription_exports, {
|
|
21
|
+
BasicTranscriptionForwarder: () => BasicTranscriptionForwarder
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(transcription_exports);
|
|
24
|
+
var import_log = require("./log.cjs");
|
|
25
|
+
class BasicTranscriptionForwarder {
|
|
26
|
+
#room;
|
|
27
|
+
#participantIdentity;
|
|
28
|
+
#trackSid;
|
|
29
|
+
#currentText = "";
|
|
30
|
+
#totalAudioDuration = 0;
|
|
31
|
+
#currentPlayoutTime = 0;
|
|
32
|
+
#DEFAULT_CHARS_PER_SECOND = 16;
|
|
33
|
+
#charsPerSecond = this.#DEFAULT_CHARS_PER_SECOND;
|
|
34
|
+
#messageId;
|
|
35
|
+
#isRunning = false;
|
|
36
|
+
#logger = (0, import_log.log)();
|
|
37
|
+
currentCharacterIndex = 0;
|
|
38
|
+
constructor(room, participantIdentity, trackSid, messageId) {
|
|
39
|
+
this.#room = room;
|
|
40
|
+
this.#participantIdentity = participantIdentity;
|
|
41
|
+
this.#trackSid = trackSid;
|
|
42
|
+
this.#messageId = messageId;
|
|
43
|
+
}
|
|
44
|
+
get text() {
|
|
45
|
+
return this.#currentText;
|
|
46
|
+
}
|
|
47
|
+
start() {
|
|
48
|
+
if (!this.#isRunning) {
|
|
49
|
+
this.#isRunning = true;
|
|
50
|
+
this.#startPublishingLoop().catch((error) => {
|
|
51
|
+
this.#logger.error("Error in publishing loop:", error);
|
|
52
|
+
this.#isRunning = false;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
pushAudio(frame) {
|
|
57
|
+
this.#totalAudioDuration += frame.samplesPerChannel / frame.sampleRate;
|
|
58
|
+
}
|
|
59
|
+
pushText(text) {
|
|
60
|
+
this.#currentText += text;
|
|
61
|
+
}
|
|
62
|
+
#textIsComplete = false;
|
|
63
|
+
#audioIsComplete = false;
|
|
64
|
+
markTextComplete() {
|
|
65
|
+
this.#textIsComplete = true;
|
|
66
|
+
this.#adjustTimingIfBothFinished();
|
|
67
|
+
}
|
|
68
|
+
markAudioComplete() {
|
|
69
|
+
this.#audioIsComplete = true;
|
|
70
|
+
this.#adjustTimingIfBothFinished();
|
|
71
|
+
}
|
|
72
|
+
#adjustTimingIfBothFinished() {
|
|
73
|
+
if (this.#textIsComplete && this.#audioIsComplete) {
|
|
74
|
+
const actualDuration = this.#totalAudioDuration;
|
|
75
|
+
if (actualDuration > 0 && this.#currentText.length > 0) {
|
|
76
|
+
this.#charsPerSecond = this.#currentText.length / actualDuration;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
#computeSleepInterval() {
|
|
81
|
+
return Math.min(Math.max(1 / this.#charsPerSecond, 0.0625), 0.5);
|
|
82
|
+
}
|
|
83
|
+
async #startPublishingLoop() {
|
|
84
|
+
this.#isRunning = true;
|
|
85
|
+
let sleepInterval = this.#computeSleepInterval();
|
|
86
|
+
let isComplete = false;
|
|
87
|
+
while (this.#isRunning && !isComplete) {
|
|
88
|
+
this.#currentPlayoutTime += sleepInterval;
|
|
89
|
+
this.currentCharacterIndex = Math.floor(this.#currentPlayoutTime * this.#charsPerSecond);
|
|
90
|
+
isComplete = this.#textIsComplete && this.currentCharacterIndex >= this.#currentText.length;
|
|
91
|
+
await this.#publishTranscription(false);
|
|
92
|
+
if (this.#isRunning && !isComplete) {
|
|
93
|
+
sleepInterval = this.#computeSleepInterval();
|
|
94
|
+
await new Promise((resolve) => setTimeout(resolve, sleepInterval * 1e3));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (this.#isRunning) {
|
|
98
|
+
this.close(false);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
async #publishTranscription(final) {
|
|
102
|
+
var _a;
|
|
103
|
+
const textToPublish = this.#currentText.slice(0, this.currentCharacterIndex);
|
|
104
|
+
await ((_a = this.#room.localParticipant) == null ? void 0 : _a.publishTranscription({
|
|
105
|
+
participantIdentity: this.#participantIdentity,
|
|
106
|
+
trackSid: this.#trackSid,
|
|
107
|
+
segments: [
|
|
108
|
+
{
|
|
109
|
+
text: textToPublish,
|
|
110
|
+
final,
|
|
111
|
+
id: this.#messageId,
|
|
112
|
+
startTime: BigInt(0),
|
|
113
|
+
endTime: BigInt(0),
|
|
114
|
+
language: ""
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
async close(interrupt) {
|
|
120
|
+
this.#isRunning = false;
|
|
121
|
+
if (!interrupt) {
|
|
122
|
+
this.currentCharacterIndex = this.#currentText.length;
|
|
123
|
+
}
|
|
124
|
+
await this.#publishTranscription(true);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
128
|
+
0 && (module.exports = {
|
|
129
|
+
BasicTranscriptionForwarder
|
|
130
|
+
});
|
|
131
|
+
//# sourceMappingURL=transcription.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/transcription.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { AudioFrame, Room } from '@livekit/rtc-node';\nimport { log } from './log.js';\n\nexport interface TranscriptionForwarder {\n start(): void;\n pushAudio(frame: AudioFrame): void;\n pushText(text: string): void;\n markTextComplete(): void;\n markAudioComplete(): void;\n close(interrupt: boolean): Promise<void>;\n currentCharacterIndex: number;\n text: string;\n}\n\nexport class BasicTranscriptionForwarder implements TranscriptionForwarder {\n #room: Room;\n #participantIdentity: string;\n #trackSid: string;\n #currentText: string = '';\n #totalAudioDuration: number = 0;\n #currentPlayoutTime: number = 0;\n #DEFAULT_CHARS_PER_SECOND = 16;\n #charsPerSecond: number = this.#DEFAULT_CHARS_PER_SECOND;\n #messageId: string;\n #isRunning: boolean = false;\n #logger = log();\n currentCharacterIndex: number = 0;\n\n constructor(room: Room, participantIdentity: string, trackSid: string, messageId: string) {\n this.#room = room;\n this.#participantIdentity = participantIdentity;\n this.#trackSid = trackSid;\n this.#messageId = messageId;\n }\n\n get text(): string {\n return this.#currentText;\n }\n\n start(): void {\n if (!this.#isRunning) {\n this.#isRunning = true;\n this.#startPublishingLoop().catch((error) => {\n this.#logger.error('Error in publishing loop:', error);\n this.#isRunning = false;\n });\n }\n }\n\n pushAudio(frame: AudioFrame): void {\n this.#totalAudioDuration += frame.samplesPerChannel / frame.sampleRate;\n }\n\n pushText(text: string): void {\n this.#currentText += text;\n }\n\n #textIsComplete: boolean = false;\n #audioIsComplete: boolean = false;\n\n markTextComplete(): void {\n this.#textIsComplete = true;\n this.#adjustTimingIfBothFinished();\n }\n\n markAudioComplete(): void {\n this.#audioIsComplete = true;\n this.#adjustTimingIfBothFinished();\n }\n\n #adjustTimingIfBothFinished(): void {\n if (this.#textIsComplete && this.#audioIsComplete) {\n const actualDuration = this.#totalAudioDuration;\n if (actualDuration > 0 && this.#currentText.length > 0) {\n this.#charsPerSecond = this.#currentText.length / actualDuration;\n }\n }\n }\n\n #computeSleepInterval(): number {\n return Math.min(Math.max(1 / this.#charsPerSecond, 0.0625), 0.5);\n }\n\n async #startPublishingLoop(): Promise<void> {\n this.#isRunning = true;\n let sleepInterval = this.#computeSleepInterval();\n let isComplete = false;\n while (this.#isRunning && !isComplete) {\n this.#currentPlayoutTime += sleepInterval;\n this.currentCharacterIndex = Math.floor(this.#currentPlayoutTime * this.#charsPerSecond);\n isComplete = this.#textIsComplete && this.currentCharacterIndex >= this.#currentText.length;\n await this.#publishTranscription(false);\n if (this.#isRunning && !isComplete) {\n sleepInterval = this.#computeSleepInterval();\n await new Promise((resolve) => setTimeout(resolve, sleepInterval * 1000));\n }\n }\n\n if (this.#isRunning) {\n this.close(false);\n }\n }\n\n async #publishTranscription(final: boolean): Promise<void> {\n const textToPublish = this.#currentText.slice(0, this.currentCharacterIndex);\n await this.#room.localParticipant?.publishTranscription({\n participantIdentity: this.#participantIdentity,\n trackSid: this.#trackSid,\n segments: [\n {\n text: textToPublish,\n final: final,\n id: this.#messageId,\n startTime: BigInt(0),\n endTime: BigInt(0),\n language: '',\n },\n ],\n });\n }\n\n async close(interrupt: boolean): Promise<void> {\n this.#isRunning = false;\n\n // Publish whatever we had as final\n if (!interrupt) {\n this.currentCharacterIndex = this.#currentText.length;\n }\n await this.#publishTranscription(true);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,iBAAoB;AAab,MAAM,4BAA8D;AAAA,EACzE;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAuB;AAAA,EACvB,sBAA8B;AAAA,EAC9B,sBAA8B;AAAA,EAC9B,4BAA4B;AAAA,EAC5B,kBAA0B,KAAK;AAAA,EAC/B;AAAA,EACA,aAAsB;AAAA,EACtB,cAAU,gBAAI;AAAA,EACd,wBAAgC;AAAA,EAEhC,YAAY,MAAY,qBAA6B,UAAkB,WAAmB;AACxF,SAAK,QAAQ;AACb,SAAK,uBAAuB;AAC5B,SAAK,YAAY;AACjB,SAAK,aAAa;AAAA,EACpB;AAAA,EAEA,IAAI,OAAe;AACjB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,QAAc;AACZ,QAAI,CAAC,KAAK,YAAY;AACpB,WAAK,aAAa;AAClB,WAAK,qBAAqB,EAAE,MAAM,CAAC,UAAU;AAC3C,aAAK,QAAQ,MAAM,6BAA6B,KAAK;AACrD,aAAK,aAAa;AAAA,MACpB,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,UAAU,OAAyB;AACjC,SAAK,uBAAuB,MAAM,oBAAoB,MAAM;AAAA,EAC9D;AAAA,EAEA,SAAS,MAAoB;AAC3B,SAAK,gBAAgB;AAAA,EACvB;AAAA,EAEA,kBAA2B;AAAA,EAC3B,mBAA4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ACR;AAAA,UACE,MAAM;AAAA,UACN;AAAA,UACA,IAAI,KAAK;AAAA,UACT,WAAW,OAAO,CAAC;AAAA,UACnB,SAAS,OAAO,CAAC;AAAA,UACjB,UAAU;AAAA,QACZ;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,MAAM,WAAmC;AAC7C,SAAK,aAAa;AAGlB,QAAI,CAAC,WAAW;AACd,WAAK,wBAAwB,KAAK,aAAa;AAAA,IACjD;AACA,UAAM,KAAK,sBAAsB,IAAI;AAAA,EACvC;AACF;","names":[]}
|
package/dist/transcription.js
CHANGED
|
@@ -1,104 +1,107 @@
|
|
|
1
|
-
import { log } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
pushAudio(frame) {
|
|
34
|
-
this.#totalAudioDuration += frame.samplesPerChannel / frame.sampleRate;
|
|
35
|
-
}
|
|
36
|
-
pushText(text) {
|
|
37
|
-
this.#currentText += text;
|
|
38
|
-
}
|
|
39
|
-
#textIsComplete = false;
|
|
40
|
-
#audioIsComplete = false;
|
|
41
|
-
markTextComplete() {
|
|
42
|
-
this.#textIsComplete = true;
|
|
43
|
-
this.#adjustTimingIfBothFinished();
|
|
44
|
-
}
|
|
45
|
-
markAudioComplete() {
|
|
46
|
-
this.#audioIsComplete = true;
|
|
47
|
-
this.#adjustTimingIfBothFinished();
|
|
48
|
-
}
|
|
49
|
-
#adjustTimingIfBothFinished() {
|
|
50
|
-
if (this.#textIsComplete && this.#audioIsComplete) {
|
|
51
|
-
const actualDuration = this.#totalAudioDuration;
|
|
52
|
-
if (actualDuration > 0 && this.#currentText.length > 0) {
|
|
53
|
-
this.#charsPerSecond = this.#currentText.length / actualDuration;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
1
|
+
import { log } from "./log.js";
|
|
2
|
+
class BasicTranscriptionForwarder {
|
|
3
|
+
#room;
|
|
4
|
+
#participantIdentity;
|
|
5
|
+
#trackSid;
|
|
6
|
+
#currentText = "";
|
|
7
|
+
#totalAudioDuration = 0;
|
|
8
|
+
#currentPlayoutTime = 0;
|
|
9
|
+
#DEFAULT_CHARS_PER_SECOND = 16;
|
|
10
|
+
#charsPerSecond = this.#DEFAULT_CHARS_PER_SECOND;
|
|
11
|
+
#messageId;
|
|
12
|
+
#isRunning = false;
|
|
13
|
+
#logger = log();
|
|
14
|
+
currentCharacterIndex = 0;
|
|
15
|
+
constructor(room, participantIdentity, trackSid, messageId) {
|
|
16
|
+
this.#room = room;
|
|
17
|
+
this.#participantIdentity = participantIdentity;
|
|
18
|
+
this.#trackSid = trackSid;
|
|
19
|
+
this.#messageId = messageId;
|
|
20
|
+
}
|
|
21
|
+
get text() {
|
|
22
|
+
return this.#currentText;
|
|
23
|
+
}
|
|
24
|
+
start() {
|
|
25
|
+
if (!this.#isRunning) {
|
|
26
|
+
this.#isRunning = true;
|
|
27
|
+
this.#startPublishingLoop().catch((error) => {
|
|
28
|
+
this.#logger.error("Error in publishing loop:", error);
|
|
29
|
+
this.#isRunning = false;
|
|
30
|
+
});
|
|
56
31
|
}
|
|
57
|
-
|
|
58
|
-
|
|
32
|
+
}
|
|
33
|
+
pushAudio(frame) {
|
|
34
|
+
this.#totalAudioDuration += frame.samplesPerChannel / frame.sampleRate;
|
|
35
|
+
}
|
|
36
|
+
pushText(text) {
|
|
37
|
+
this.#currentText += text;
|
|
38
|
+
}
|
|
39
|
+
#textIsComplete = false;
|
|
40
|
+
#audioIsComplete = false;
|
|
41
|
+
markTextComplete() {
|
|
42
|
+
this.#textIsComplete = true;
|
|
43
|
+
this.#adjustTimingIfBothFinished();
|
|
44
|
+
}
|
|
45
|
+
markAudioComplete() {
|
|
46
|
+
this.#audioIsComplete = true;
|
|
47
|
+
this.#adjustTimingIfBothFinished();
|
|
48
|
+
}
|
|
49
|
+
#adjustTimingIfBothFinished() {
|
|
50
|
+
if (this.#textIsComplete && this.#audioIsComplete) {
|
|
51
|
+
const actualDuration = this.#totalAudioDuration;
|
|
52
|
+
if (actualDuration > 0 && this.#currentText.length > 0) {
|
|
53
|
+
this.#charsPerSecond = this.#currentText.length / actualDuration;
|
|
54
|
+
}
|
|
59
55
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
56
|
+
}
|
|
57
|
+
#computeSleepInterval() {
|
|
58
|
+
return Math.min(Math.max(1 / this.#charsPerSecond, 0.0625), 0.5);
|
|
59
|
+
}
|
|
60
|
+
async #startPublishingLoop() {
|
|
61
|
+
this.#isRunning = true;
|
|
62
|
+
let sleepInterval = this.#computeSleepInterval();
|
|
63
|
+
let isComplete = false;
|
|
64
|
+
while (this.#isRunning && !isComplete) {
|
|
65
|
+
this.#currentPlayoutTime += sleepInterval;
|
|
66
|
+
this.currentCharacterIndex = Math.floor(this.#currentPlayoutTime * this.#charsPerSecond);
|
|
67
|
+
isComplete = this.#textIsComplete && this.currentCharacterIndex >= this.#currentText.length;
|
|
68
|
+
await this.#publishTranscription(false);
|
|
69
|
+
if (this.#isRunning && !isComplete) {
|
|
70
|
+
sleepInterval = this.#computeSleepInterval();
|
|
71
|
+
await new Promise((resolve) => setTimeout(resolve, sleepInterval * 1e3));
|
|
72
|
+
}
|
|
77
73
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
await this.#room.localParticipant?.publishTranscription({
|
|
81
|
-
participantIdentity: this.#participantIdentity,
|
|
82
|
-
trackSid: this.#trackSid,
|
|
83
|
-
segments: [
|
|
84
|
-
{
|
|
85
|
-
text: textToPublish,
|
|
86
|
-
final: final,
|
|
87
|
-
id: this.#messageId,
|
|
88
|
-
startTime: BigInt(0),
|
|
89
|
-
endTime: BigInt(0),
|
|
90
|
-
language: '',
|
|
91
|
-
},
|
|
92
|
-
],
|
|
93
|
-
});
|
|
74
|
+
if (this.#isRunning) {
|
|
75
|
+
this.close(false);
|
|
94
76
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
77
|
+
}
|
|
78
|
+
async #publishTranscription(final) {
|
|
79
|
+
var _a;
|
|
80
|
+
const textToPublish = this.#currentText.slice(0, this.currentCharacterIndex);
|
|
81
|
+
await ((_a = this.#room.localParticipant) == null ? void 0 : _a.publishTranscription({
|
|
82
|
+
participantIdentity: this.#participantIdentity,
|
|
83
|
+
trackSid: this.#trackSid,
|
|
84
|
+
segments: [
|
|
85
|
+
{
|
|
86
|
+
text: textToPublish,
|
|
87
|
+
final,
|
|
88
|
+
id: this.#messageId,
|
|
89
|
+
startTime: BigInt(0),
|
|
90
|
+
endTime: BigInt(0),
|
|
91
|
+
language: ""
|
|
100
92
|
}
|
|
101
|
-
|
|
93
|
+
]
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
async close(interrupt) {
|
|
97
|
+
this.#isRunning = false;
|
|
98
|
+
if (!interrupt) {
|
|
99
|
+
this.currentCharacterIndex = this.#currentText.length;
|
|
102
100
|
}
|
|
101
|
+
await this.#publishTranscription(true);
|
|
102
|
+
}
|
|
103
103
|
}
|
|
104
|
+
export {
|
|
105
|
+
BasicTranscriptionForwarder
|
|
106
|
+
};
|
|
104
107
|
//# sourceMappingURL=transcription.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/transcription.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { AudioFrame, Room } from '@livekit/rtc-node';\nimport { log } from './log.js';\n\nexport interface TranscriptionForwarder {\n start(): void;\n pushAudio(frame: AudioFrame): void;\n pushText(text: string): void;\n markTextComplete(): void;\n markAudioComplete(): void;\n close(interrupt: boolean): Promise<void>;\n currentCharacterIndex: number;\n text: string;\n}\n\nexport class BasicTranscriptionForwarder implements TranscriptionForwarder {\n #room: Room;\n #participantIdentity: string;\n #trackSid: string;\n #currentText: string = '';\n #totalAudioDuration: number = 0;\n #currentPlayoutTime: number = 0;\n #DEFAULT_CHARS_PER_SECOND = 16;\n #charsPerSecond: number = this.#DEFAULT_CHARS_PER_SECOND;\n #messageId: string;\n #isRunning: boolean = false;\n #logger = log();\n currentCharacterIndex: number = 0;\n\n constructor(room: Room, participantIdentity: string, trackSid: string, messageId: string) {\n this.#room = room;\n this.#participantIdentity = participantIdentity;\n this.#trackSid = trackSid;\n this.#messageId = messageId;\n }\n\n get text(): string {\n return this.#currentText;\n }\n\n start(): void {\n if (!this.#isRunning) {\n this.#isRunning = true;\n this.#startPublishingLoop().catch((error) => {\n this.#logger.error('Error in publishing loop:', error);\n this.#isRunning = false;\n });\n }\n }\n\n pushAudio(frame: AudioFrame): void {\n this.#totalAudioDuration += frame.samplesPerChannel / frame.sampleRate;\n }\n\n pushText(text: string): void {\n this.#currentText += text;\n }\n\n #textIsComplete: boolean = false;\n #audioIsComplete: boolean = false;\n\n markTextComplete(): void {\n this.#textIsComplete = true;\n this.#adjustTimingIfBothFinished();\n }\n\n markAudioComplete(): void {\n this.#audioIsComplete = true;\n this.#adjustTimingIfBothFinished();\n }\n\n #adjustTimingIfBothFinished(): void {\n if (this.#textIsComplete && this.#audioIsComplete) {\n const actualDuration = this.#totalAudioDuration;\n if (actualDuration > 0 && this.#currentText.length > 0) {\n this.#charsPerSecond = this.#currentText.length / actualDuration;\n }\n }\n }\n\n #computeSleepInterval(): number {\n return Math.min(Math.max(1 / this.#charsPerSecond, 0.0625), 0.5);\n }\n\n async #startPublishingLoop(): Promise<void> {\n this.#isRunning = true;\n let sleepInterval = this.#computeSleepInterval();\n let isComplete = false;\n while (this.#isRunning && !isComplete) {\n this.#currentPlayoutTime += sleepInterval;\n this.currentCharacterIndex = Math.floor(this.#currentPlayoutTime * this.#charsPerSecond);\n isComplete = this.#textIsComplete && this.currentCharacterIndex >= this.#currentText.length;\n await this.#publishTranscription(false);\n if (this.#isRunning && !isComplete) {\n sleepInterval = this.#computeSleepInterval();\n await new Promise((resolve) => setTimeout(resolve, sleepInterval * 1000));\n }\n }\n\n if (this.#isRunning) {\n this.close(false);\n }\n }\n\n async #publishTranscription(final: boolean): Promise<void> {\n const textToPublish = this.#currentText.slice(0, this.currentCharacterIndex);\n await this.#room.localParticipant?.publishTranscription({\n participantIdentity: this.#participantIdentity,\n trackSid: this.#trackSid,\n segments: [\n {\n text: textToPublish,\n final: final,\n id: this.#messageId,\n startTime: BigInt(0),\n endTime: BigInt(0),\n language: '',\n },\n ],\n });\n }\n\n async close(interrupt: boolean): Promise<void> {\n this.#isRunning = false;\n\n // Publish whatever we had as final\n if (!interrupt) {\n this.currentCharacterIndex = this.#currentText.length;\n }\n await this.#publishTranscription(true);\n }\n}\n"],"mappings":"AAIA,SAAS,WAAW;AAab,MAAM,4BAA8D;AAAA,EACzE;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAuB;AAAA,EACvB,sBAA8B;AAAA,EAC9B,sBAA8B;AAAA,EAC9B,4BAA4B;AAAA,EAC5B,kBAA0B,KAAK;AAAA,EAC/B;AAAA,EACA,aAAsB;AAAA,EACtB,UAAU,IAAI;AAAA,EACd,wBAAgC;AAAA,EAEhC,YAAY,MAAY,qBAA6B,UAAkB,WAAmB;AACxF,SAAK,QAAQ;AACb,SAAK,uBAAuB;AAC5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