For Amazon Connect live audio streams, is agent track always 2, and customer track always 1?

51 views Asked by At

Following Amazon's example for reading live audio chunks out of Amazon Connect, I have logic like this:

    @RequiredArgsConstructor
    public enum TrackName {
        // Track #s: (1) for "customer" or "inbound"; (2) for "agent" or "outbound".
        AUDIO_FROM_CUSTOMER("AUDIO_FROM_CUSTOMER", 1),
        AUDIO_TO_CUSTOMER("AUDIO_TO_CUSTOMER", 2);

        @Getter
        private final String name;

        @Getter final long trackNum;
    }

    ...

    public static AudioChunkTrack getByteBufferFromStream(StreamingMkvReader streamingMkvReader,
                                                          FragmentMetadataVisitor fragmentVisitor,
                                                          KVSContactTagProcessor tagProcessor) throws MkvElementVisitException {
        while (streamingMkvReader.mightHaveNext()) {
            Optional<MkvElement> mkvElementOptional = streamingMkvReader.nextIfAvailable();
            if (mkvElementOptional.isPresent()) {
                if (tagProcessor.shouldStopProcessing()) {
                    return new AudioChunkTrack(ByteBuffer.allocate(0), null, -1);
                }
                MkvElement mkvElement = mkvElementOptional.get();
                mkvElement.accept(fragmentVisitor);
                log.trace("processing element {}", mkvElement.getElementMetaData().getTypeInfo());
                if (MkvTypeInfos.SIMPLEBLOCK.equals(mkvElement.getElementMetaData().getTypeInfo())) {
                    MkvDataElement dataElement = (MkvDataElement) mkvElement;
                    @SuppressWarnings("unchecked")
                    Frame frame = ((MkvValue<Frame>) dataElement.getValueCopy()).getVal();
                    ByteBuffer audioBuffer = frame.getFrameData();

                    long trackNumber = frame.getTrackNumber();
                    MkvTrackMetadata metadata = fragmentVisitor.getMkvTrackMetadata(trackNumber);
                    return new AudioChunkTrack(audioBuffer, metadata.getTrackName(), trackNumber);
                }
            }
        }

        return new AudioChunkTrack(ByteBuffer.allocate(0), null, -1);
    }

Here, trackNumber is always 1 (with metadata tag AUDIO_FROM_CUSTOMER) or 2 (with metadata tag AUDIO_TO_CUSTOMER).

Can I assume that track #2 is for the Agent channel, and track #1 the Customer channel (ie, the caller)?

I am seeing some results that suggest this assumption may not always be true. If it is not true, is there some way in Amazon Connect that I can hardwire the alignment of track # with Agent/Customer label?

1

There are 1 answers

1
gamliela On

Not sure about track numbers, but agent is always recorded on the right channel. From the docs:

The agent audio is stored in the right channel. All incoming audio, including the customer and anyone conferenced in, is stored in the left channel.