Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we stream multiple inputs and use complex filter? #860

Open
ne-api opened this issue Oct 26, 2024 · 0 comments
Open

Can we stream multiple inputs and use complex filter? #860

ne-api opened this issue Oct 26, 2024 · 0 comments

Comments

@ne-api
Copy link

ne-api commented Oct 26, 2024

I have a code that is written in Typescript that takes in two streams of audio and combines them into one. Below is the TypeScript Code. Can anyone help how this can be done in python using this package?

   `const leftStream = await getKvsStream(`gprc-${callId}-AGENT`);
    const rightStream = await getKvsStream(`gprc-${callId}-CUSTOMER`);

    logger.info(`############ Begin piping KVS streams for callId ${callId}`);

    const ffmpegProcess = spawn('ffmpeg', [
        '-y', // Overwrite output files without asking
        '-re', // Read input at native frame rate
        '-f', 'matroska', '-i', 'pipe:3', // Input stream from pipe 3 (left stream)
        '-re', // Read input at native frame rate
        '-f', 'matroska', '-i', 'pipe:4', // Input stream from pipe 4 (right stream)
        '-filter_complex', '[0:a][1:a]join=inputs=2:channel_layout=stereo[a]', // Combine streams into separate tracks
        '-map', '[a]', // Map the combined audio to the output
        '-c:a', 'pcm_s16le', // Audio codec
        '-ar', '8000',
        '-f', 's16le', // Output format as PCM RAW
        'pipe:1' // Output stream to pipe
    ], {
        stdio: ['pipe', 'pipe', 'pipe', 'pipe', 'pipe'] // Create extra pipes
    });

    leftStream.pipe(ffmpegProcess.stdio[3] as Writable);
    rightStream.pipe(ffmpegProcess.stdio[4] as Writable);

    const transcribeStream = new PassThrough();
    const combinedStream = new PassThrough();
            
    ffmpegProcess.stdout.pipe(combinedStream);

    combinedStream.pipe(transcribeStream);

    transcribe.transcribeCombinedAudioStream(transcribeStream, callId, 8000)`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant