mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 01:14:33 +00:00
fix: honor zero-valued voice-call STT settings
Landed from contributor PR #39196 by @scoootscooob. Co-authored-by: scoootscooob <zhentongfan@gmail.com>
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { RealtimeSTTConfig } from "./stt-openai-realtime.js";
|
||||
import { OpenAIRealtimeSTTProvider } from "./stt-openai-realtime.js";
|
||||
|
||||
type ProviderInternals = OpenAIRealtimeSTTProvider & {
|
||||
vadThreshold: number;
|
||||
silenceDurationMs: number;
|
||||
};
|
||||
|
||||
function createProvider(config: RealtimeSTTConfig): ProviderInternals {
|
||||
return new OpenAIRealtimeSTTProvider(config) as ProviderInternals;
|
||||
}
|
||||
|
||||
describe("OpenAIRealtimeSTTProvider constructor defaults", () => {
|
||||
it("uses vadThreshold: 0 when explicitly configured (max sensitivity)", () => {
|
||||
const provider = createProvider({
|
||||
apiKey: "sk-test",
|
||||
vadThreshold: 0,
|
||||
});
|
||||
expect(provider.vadThreshold).toBe(0);
|
||||
});
|
||||
|
||||
it("uses silenceDurationMs: 0 when explicitly configured", () => {
|
||||
const provider = createProvider({
|
||||
apiKey: "sk-test",
|
||||
silenceDurationMs: 0,
|
||||
});
|
||||
expect(provider.silenceDurationMs).toBe(0);
|
||||
});
|
||||
|
||||
it("falls back to defaults when values are undefined", () => {
|
||||
const provider = createProvider({
|
||||
apiKey: "sk-test",
|
||||
});
|
||||
expect(provider.vadThreshold).toBe(0.5);
|
||||
expect(provider.silenceDurationMs).toBe(800);
|
||||
});
|
||||
});
|
||||
@@ -62,8 +62,8 @@ export class OpenAIRealtimeSTTProvider {
|
||||
}
|
||||
this.apiKey = config.apiKey;
|
||||
this.model = config.model || "gpt-4o-transcribe";
|
||||
this.silenceDurationMs = config.silenceDurationMs || 800;
|
||||
this.vadThreshold = config.vadThreshold || 0.5;
|
||||
this.silenceDurationMs = config.silenceDurationMs ?? 800;
|
||||
this.vadThreshold = config.vadThreshold ?? 0.5;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user