Skip to content

armgit / clipy

Public Imported from GitHub
0

The AI-native screen recorder. Record your screen and talk; the people you share it with and your AI agents both get it.

Merge pull request #959

Claude4aeeffe79e04
diff --cc packages/transcribe/test/providers.test.ts
index 4946532,4d360e9..fb9230b
--- a/packages/transcribe/test/providers.test.ts
+++ b/packages/transcribe/test/providers.test.ts
@@@ -559,15 -552,66 +559,75 @@@ describe("deepgram", () =>
expect(r.segments.map(({ words: _words, ...segment }) => segment)).toEqual([{ startMs: 200, endMs: 2700, text: "まずGitHub Actionsを開く。" }]);
});
+ it("keeps the transcript when detected_language is null", async () => {
+ server = await fakeServer((_req, res) =>
+ json(res, { results: { channels: [{ detected_language: null }], utterances: [{ start: 0, end: 1, transcript: "ok" }] } }),
+ );
+ const r = await transcribeDeepgram(await audioInput(2), { apiKey: KEY, baseUrl: server.url });
+ expect(r.segments).toEqual([{ startMs: 0, endMs: 1000, text: "ok" }]);
+ expect(r.language).toBeUndefined();
+ });
+
+ it("joins Japanese word pieces in utterances, which every request asks for", async () => {
+ const words = [
+ { word: "まず", punctuated_word: "まず", start: 0.2, end: 0.6 },
+ { word: "github", punctuated_word: "GitHub", start: 0.6, end: 1.2 },
+ { word: "actions", punctuated_word: "Actions", start: 1.2, end: 1.9 },
+ { word: "を", punctuated_word: "を", start: 1.9, end: 2.1 },
+ { word: "開き", punctuated_word: "開き", start: 2.1, end: 2.7 },
+ { word: "ます", punctuated_word: "ます。", start: 2.7, end: 3.4 },
+ ];
+ const transcript = "まず GitHub Actions を 開き ます。";
+ server = await fakeServer((_req, res) =>
+ json(res, {
+ results: {
+ channels: [{ detected_language: "ja", alternatives: [{ transcript, words }] }],
+ utterances: [{ start: 0.2, end: 3.4, transcript, words }],
+ },
+ }),
+ );
+ const r = await transcribeDeepgram(await audioInput(4), { apiKey: KEY, baseUrl: server.url });
+ expect(r.segments).toEqual([
+ {
+ startMs: 200,
+ endMs: 3400,
+ text: "まずGitHub Actionsを開きます。",
+ words: [
+ { startMs: 200, endMs: 600, text: "まず" },
+ { startMs: 600, endMs: 1200, text: "GitHub" },
+ { startMs: 1200, endMs: 1900, text: "Actions" },
+ { startMs: 1900, endMs: 2100, text: "を" },
+ { startMs: 2100, endMs: 2700, text: "開き" },
+ { startMs: 2700, endMs: 3400, text: "ます。" },
+ ],
+ },
+ ]);
+ });
+
+ it("keeps the spacing an utterance transcript adds between Chinese and Latin text", async () => {
+ const transcript = "打开 GitHub CLI。";
+ const words = ["打", "开", "Git", "Hub", "CLI。"].map((word, i) => ({ word, start: i / 5, end: (i + 1) / 5 }));
+ server = await fakeServer((_req, res) =>
+ json(res, { results: { channels: [{ detected_language: "zh-CN" }], utterances: [{ start: 0, end: 1, transcript, words }] } }),
+ );
+ const r = await transcribeDeepgram(await audioInput(1), { apiKey: KEY, baseUrl: server.url });
+ expect(r.segments.map((s) => s.text)).toEqual([transcript]);
+ });
+
+ it("uses the configured unspaced language for utterances", async () => {
+ const words = [
+ { word: "次", punctuated_word: "次", start: 0.1, end: 0.4 },
+ { word: "に", punctuated_word: "に", start: 0.4, end: 0.6 },
+ { word: "進み", punctuated_word: "進み", start: 0.6, end: 1.0 },
+ { word: "ます", punctuated_word: "ます。", start: 1.0, end: 1.4 },
+ ];
+ server = await fakeServer((_req, res) =>
+ json(res, { results: { channels: [{}], utterances: [{ start: 0.1, end: 1.4, transcript: "次 に 進み ます。", words }] } }),
+ );
+ const r = await transcribeDeepgram(await audioInput(2), { apiKey: KEY, baseUrl: server.url, language: "ja" });
+ expect(r.segments.map((s) => s.text)).toEqual(["次に進みます。"]);
+ });
+
it("reports HTTP errors safely", async () => {
server = await fakeServer((_req, res) => json(res, { err_msg: SECRET_TEXT }, 402));
await expectSafeError(transcribeDeepgram(await audioInput(1), { apiKey: KEY, baseUrl: server.url }), "deepgram", 402);