import { describe, expect, it } from "vitest"; import type { SpeechProviderPlugin } from "../plugins/types.js"; import { parseTtsDirectives } from "./directives.js"; import type {
SpeechDirectiveTokenParseContext,
SpeechDirectiveTokenParseResult,
SpeechModelOverridePolicy,
} from "./provider-types.js";
describe("parseTtsDirectives provider-aware routing", () => {
it("does not resolve providers when text has no directives", () => { const failProvider = {
get id() { thrownew Error("provider should not be read without directives");
},
get autoSelectOrder() { thrownew Error("provider order should not be read without directives");
},
} as unknown as SpeechProviderPlugin;
const result = parseTtsDirectives("hello without TTS markup", fullPolicy, {
providers: [failProvider, failProvider],
});
it("routes to the preferred provider when no provider token is declared", () => { const result = parseTtsDirectives("[[tts:speed=1.5]]", fullPolicy, {
providers: [elevenlabs, minimax],
preferredProviderId: "minimax",
});
it("falls back to autoSelectOrder when no provider hint is available", () => { const result = parseTtsDirectives("[[tts:speed=1.5]]", fullPolicy, {
providers: [elevenlabs, minimax],
});
it("falls through when the preferred provider does not handle the key", () => { const result = parseTtsDirectives("[[tts:provider=minimax style=0.4]]", fullPolicy, {
providers: [elevenlabs, minimax],
});
it("accepts bare tts tags as a tagged-mode trigger", () => { const result = parseTtsDirectives("[[tts]] read this aloud", fullPolicy, {
providers: [elevenlabs, minimax],
});
expect(result.hasDirective).toBe(true);
expect(result.cleanedText).toBe(" read this aloud");
expect(result.ttsText).toBeUndefined();
});
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.