MCPcopy Index your code
hub / github.com/MiniMax-AI/cli / pipeAudioStream

Function pipeAudioStream

src/utils/audio-stream.ts:7–29  ·  view source on GitHub ↗
(response: Response)

Source from the content-addressed store, hash-verified

5}
6
7export async function pipeAudioStream(response: Response): Promise<void> {
8 process.stdout.on('error', (err: NodeJS.ErrnoException) => {
9 if (err.code === 'EPIPE') process.exit(0);
10 throw err;
11 });
12
13 for await (const event of parseSSE(response)) {
14 if (!event.data || event.data === '[DONE]') break;
15
16 let parsed: SseAudioPayload;
17 try { parsed = JSON.parse(event.data); } catch { continue; }
18
19 if (parsed.data?.status === 2) continue;
20
21 const hex = parsed.data?.audio;
22 if (!hex) continue;
23
24 const chunk = Buffer.from(hex, 'hex');
25 if (!process.stdout.write(chunk)) {
26 await new Promise<void>(r => process.stdout.once('drain', r));
27 }
28 }
29}

Callers 3

runFunction · 0.90
runFunction · 0.90
runFunction · 0.90

Calls 1

parseSSEFunction · 0.90

Tested by

no test coverage detected