fix(tests): iteration 9
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
import { describe, test, expect, beforeAll, afterAll, beforeEach } from "vitest";
|
import { describe, test, expect, beforeAll, afterAll, beforeEach } from "vitest";
|
||||||
import { mkdtempSync, writeFileSync, rmSync, existsSync } from "node:fs";
|
import { mkdtempSync, writeFileSync, rmSync, existsSync } from "node:fs";
|
||||||
|
import { readFile } from "node:fs/promises";
|
||||||
import { tmpdir, homedir } from "node:os";
|
import { tmpdir, homedir } from "node:os";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { execSync } from "node:child_process";
|
import { execSync } from "node:child_process";
|
||||||
import { randomUUID } from "node:crypto";
|
import { randomUUID } from "node:crypto";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
createDaemonTestContext,
|
createDaemonTestContext,
|
||||||
@@ -22,6 +24,16 @@ const openaiApiKey = process.env.OPENAI_API_KEY ?? null;
|
|||||||
const localModelsDir =
|
const localModelsDir =
|
||||||
process.env.PASEO_LOCAL_MODELS_DIR ??
|
process.env.PASEO_LOCAL_MODELS_DIR ??
|
||||||
path.join(homedir(), ".paseo", "models", "local-speech");
|
path.join(homedir(), ".paseo", "models", "local-speech");
|
||||||
|
const testFileDir = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
const appE2eFixturesDir = path.resolve(testFileDir, "../../../app/e2e/fixtures");
|
||||||
|
|
||||||
|
function fixturePath(fileName: string): string {
|
||||||
|
return path.join(appE2eFixturesDir, fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function readFixture(fileName: string): Promise<Buffer> {
|
||||||
|
return readFile(fixturePath(fileName));
|
||||||
|
}
|
||||||
|
|
||||||
function hasSherpaZipformerModels(modelsDir: string): boolean {
|
function hasSherpaZipformerModels(modelsDir: string): boolean {
|
||||||
return (
|
return (
|
||||||
@@ -828,15 +840,7 @@ describe("daemon client E2E", () => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const fixturePath = path.resolve(
|
const wav = await readFixture("recording.wav");
|
||||||
process.cwd(),
|
|
||||||
"..",
|
|
||||||
"app",
|
|
||||||
"e2e",
|
|
||||||
"fixtures",
|
|
||||||
"recording.wav"
|
|
||||||
);
|
|
||||||
const wav = await import("node:fs/promises").then((fs) => fs.readFile(fixturePath));
|
|
||||||
await ctx.client.sendVoiceAudioChunk(wav.toString("base64"), "audio/wav", true);
|
await ctx.client.sendVoiceAudioChunk(wav.toString("base64"), "audio/wav", true);
|
||||||
await transcriptSeen;
|
await transcriptSeen;
|
||||||
await new Promise((resolve) => setTimeout(resolve, 1500));
|
await new Promise((resolve) => setTimeout(resolve, 1500));
|
||||||
@@ -898,15 +902,7 @@ describe("daemon client E2E", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const fixturePath = path.resolve(
|
const wav = await readFixture("recording.wav");
|
||||||
process.cwd(),
|
|
||||||
"..",
|
|
||||||
"app",
|
|
||||||
"e2e",
|
|
||||||
"fixtures",
|
|
||||||
"recording.wav"
|
|
||||||
);
|
|
||||||
const wav = await import("node:fs/promises").then((fs) => fs.readFile(fixturePath));
|
|
||||||
const { sampleRate, pcm16 } = parsePcm16MonoWav(wav);
|
const { sampleRate, pcm16 } = parsePcm16MonoWav(wav);
|
||||||
expect(sampleRate).toBe(16000);
|
expect(sampleRate).toBe(16000);
|
||||||
const format = "audio/pcm;rate=16000;bits=16";
|
const format = "audio/pcm;rate=16000;bits=16";
|
||||||
@@ -1010,15 +1006,7 @@ describe("daemon client E2E", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const fixturePath = path.resolve(
|
const wav = await readFixture("recording.wav");
|
||||||
process.cwd(),
|
|
||||||
"..",
|
|
||||||
"app",
|
|
||||||
"e2e",
|
|
||||||
"fixtures",
|
|
||||||
"recording.wav"
|
|
||||||
);
|
|
||||||
const wav = await import("node:fs/promises").then((fs) => fs.readFile(fixturePath));
|
|
||||||
const { sampleRate, pcm16 } = parsePcm16MonoWav(wav);
|
const { sampleRate, pcm16 } = parsePcm16MonoWav(wav);
|
||||||
expect(sampleRate).toBe(16000);
|
expect(sampleRate).toBe(16000);
|
||||||
|
|
||||||
@@ -1067,15 +1055,7 @@ describe("daemon client E2E", () => {
|
|||||||
speechTest(
|
speechTest(
|
||||||
"streams dictation PCM and returns final transcript",
|
"streams dictation PCM and returns final transcript",
|
||||||
async () => {
|
async () => {
|
||||||
const fixturePath = path.resolve(
|
const wav = await readFixture("recording.wav");
|
||||||
process.cwd(),
|
|
||||||
"..",
|
|
||||||
"app",
|
|
||||||
"e2e",
|
|
||||||
"fixtures",
|
|
||||||
"recording.wav"
|
|
||||||
);
|
|
||||||
const wav = await import("node:fs/promises").then((fs) => fs.readFile(fixturePath));
|
|
||||||
const { sampleRate, pcm16 } = parsePcm16MonoWav(wav);
|
const { sampleRate, pcm16 } = parsePcm16MonoWav(wav);
|
||||||
expect(sampleRate).toBe(16000);
|
expect(sampleRate).toBe(16000);
|
||||||
const dictationId = `dict-${Date.now()}`;
|
const dictationId = `dict-${Date.now()}`;
|
||||||
@@ -1103,31 +1083,13 @@ describe("daemon client E2E", () => {
|
|||||||
speechTest(
|
speechTest(
|
||||||
"realtime dictation transcript is similar to baseline fixture",
|
"realtime dictation transcript is similar to baseline fixture",
|
||||||
async () => {
|
async () => {
|
||||||
const fixturePath = path.resolve(
|
const wav = await readFixture("recording.wav");
|
||||||
process.cwd(),
|
|
||||||
"..",
|
|
||||||
"app",
|
|
||||||
"e2e",
|
|
||||||
"fixtures",
|
|
||||||
"recording.wav"
|
|
||||||
);
|
|
||||||
const wav = await import("node:fs/promises").then((fs) => fs.readFile(fixturePath));
|
|
||||||
const { sampleRate, pcm16 } = parsePcm16MonoWav(wav);
|
const { sampleRate, pcm16 } = parsePcm16MonoWav(wav);
|
||||||
expect(sampleRate).toBe(16000);
|
expect(sampleRate).toBe(16000);
|
||||||
const dictationId = `dict-baseline-${Date.now()}`;
|
const dictationId = `dict-baseline-${Date.now()}`;
|
||||||
const format = "audio/pcm;rate=16000;bits=16";
|
const format = "audio/pcm;rate=16000;bits=16";
|
||||||
|
|
||||||
const baselinePath = path.resolve(
|
const baseline = (await readFile(fixturePath("recording.baseline.txt"), "utf-8")).trim();
|
||||||
process.cwd(),
|
|
||||||
"..",
|
|
||||||
"app",
|
|
||||||
"e2e",
|
|
||||||
"fixtures",
|
|
||||||
"recording.baseline.txt"
|
|
||||||
);
|
|
||||||
const baseline = await import("node:fs/promises")
|
|
||||||
.then((fs) => fs.readFile(baselinePath, "utf-8"))
|
|
||||||
.then((text) => text.trim());
|
|
||||||
|
|
||||||
await ctx.client.startDictationStream(dictationId, format);
|
await ctx.client.startDictationStream(dictationId, format);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user