@@ -301,4 +301,51 @@ describe("gateway talk.config", () => {
301301 globalThis . fetch = originalFetch ;
302302 }
303303 } ) ;
304+
305+ it ( "resolves talk voice aliases case-insensitively and forwards output format" , async ( ) => {
306+ const { writeConfigFile } = await import ( "../config/config.js" ) ;
307+ await writeConfigFile ( {
308+ talk : {
309+ provider : "elevenlabs" ,
310+ providers : {
311+ elevenlabs : {
312+ apiKey : "elevenlabs-talk-key" , // pragma: allowlist secret
313+ voiceId : "voice-default" ,
314+ voiceAliases : {
315+ Clawd : "EXAVITQu4vr4xnSDxMaL" ,
316+ } ,
317+ } ,
318+ } ,
319+ } ,
320+ } ) ;
321+
322+ const originalFetch = globalThis . fetch ;
323+ let fetchUrl : string | undefined ;
324+ const fetchMock = vi . fn ( async ( input : RequestInfo | URL ) => {
325+ fetchUrl = typeof input === "string" ? input : input instanceof URL ? input . href : input . url ;
326+ return new Response ( new Uint8Array ( [ 4 , 5 , 6 ] ) , { status : 200 } ) ;
327+ } ) ;
328+ globalThis . fetch = fetchMock as typeof fetch ;
329+
330+ try {
331+ await withServer ( async ( ws ) => {
332+ await connectOperator ( ws , [ "operator.read" , "operator.write" ] ) ;
333+ const res = await fetchTalkSpeak ( ws , {
334+ text : "Hello from talk mode." ,
335+ voiceId : "clawd" ,
336+ outputFormat : "pcm_44100" ,
337+ } ) ;
338+ expect ( res . ok ) . toBe ( true ) ;
339+ expect ( res . payload ?. provider ) . toBe ( "elevenlabs" ) ;
340+ expect ( res . payload ?. outputFormat ) . toBe ( "pcm_44100" ) ;
341+ expect ( res . payload ?. audioBase64 ) . toBe ( Buffer . from ( [ 4 , 5 , 6 ] ) . toString ( "base64" ) ) ;
342+ } ) ;
343+
344+ expect ( fetchMock ) . toHaveBeenCalled ( ) ;
345+ expect ( fetchUrl ) . toContain ( "/v1/text-to-speech/EXAVITQu4vr4xnSDxMaL" ) ;
346+ expect ( fetchUrl ) . toContain ( "output_format=pcm_44100" ) ;
347+ } finally {
348+ globalThis . fetch = originalFetch ;
349+ }
350+ } ) ;
304351} ) ;
0 commit comments