How i got Stereo Audio working in Freepbx

I wanted to share a how-to / story on something I’ve been working on lately.

Why would you want to do this?
For my use case, we have a 3rd party integration that needs the ability to separate who was talking, when. and I just plain like having one person per ear, because that’s my preference.

So… Heres me trying to document a not-overly-vague way to do this, as I have struggled with the documentation recently.

  1. (Background stuff, not for you)
  • I had to submit an improvement to the Freepbx CallRecording module to get this working. its currently in a Pull Request, and likely to be merged by the time you read this.
  1. Create a script that handles your transcription.
    for this use case, I wanted to keep BOTH a stereo audio file, AND a mono audio file, because reasons.

note that the sox tool has -M mix (stereo) from 2 sources, and -m merge (mono).

/usr/bin/mix-stereo.sh

#!/bin/bash

SOX="/usr/bin/sox"
RM="/bin/rm"

IN="${1}recv_$2.wav"
OUT="${1}trans_$2.wav"
//todo: update this
MIXDESTINATION="${1}stereo_$2.wav"
//todo: update this
MERGEDESTINATION="${1}mono_$2.wav"

$SOX -M $IN $OUT $MIXDESTINATION && $SOX -m $IN $OUT $MERGEDESTINATION && $RM $IN $OUT
  1. add something like the following to/etc/asterisk/globals_custom.conf
SS=$
MIXMON_DIR=/var/spool/asterisk/monitor/
MONITOR_REC_OPTION=br(${SS}{MIXMON_DIR}${SS}{YEAR}/${SS}{MONTH}/${SS}{DAY}/recv_${SS}{CALLFILENAME}.${SS}{MON_FMT})t(${SS}{MIXMON_DIR}${SS}{YEAR}/${SS}{MONTH}/${SS}{DAY}/trans_${SS}{CALLFILENAME}.${SS}{MON_FMT})
MIXMON_POST=/usr/bin/mix-stereo.sh ${SS}{MIXMON_DIR}${SS}{YEAR}/${SS}{MONTH}/${SS}{DAY}/ ${SS}{CALLFILENAME}
  1. throw in a >fwconsole reload for good measure

and enjoy!

if this doesn’t work for you, you likely don’t (yet) have the updated version of the callrecording module I worked on. the current (as of Nov 2021) version doesn’t like you passing in variables like {YEAR}…

2 Likes

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.