88# cd ~ && git clone git@github.com:jks-prv/kiwiclient.git
99# 3. Install Hamlib cli tools
1010
11+ set -x
1112MY_PATH=` dirname $0 `
1213BUILD_PATH=` echo $MY_PATH /../build_* /src`
1314PATH=${PATH} :${BUILD_PATH} :${HOME} /kiwiclient
@@ -25,24 +26,27 @@ serialPort="/dev/ttyUSB0"
2526rxwavefile=0
2627soundDevice=" plughw:CARD=CODEC,DEV=0"
2728txstats=0
29+ stationid=" "
2830
2931function print_help {
3032 echo
3133 echo " Automated Over The Air (OTA) voice test for FreeDV HF voice modes"
3234 echo
33- echo " usage ./ota_voice_test.sh [options] SpeechFile [kiwi_url]"
35+ echo " usage ./ota_voice_test.sh [options] SpeechWaveFile [kiwi_url]"
3436 echo " or:"
3537 echo " usage ./ota_voice_test.sh -r rxWaveFile"
3638 echo
37- echo " -c dev The sound device (in ALSA format on Linux, CoreAudio for macOS)"
38- echo " -d debug mode; trace script execution"
39- echo " -g SSB (analog) compressor gain"
39+ echo " -c dev The sound device (in ALSA format on Linux, CoreAudio for macOS)"
40+ echo " -d debug mode; trace script execution"
41+ echo " -g SSB (analog) compressor gain"
42+ echo " -i StationIDWaveFile Prepend this file to identify transmission (should be 8KHz mono)"
4043 echo " -m mode 700c|700d|700e"
41- echo " -o model select radio model number ('rigctl -l' to list)"
42- echo " -r Rx wave file mode: Rx process supplied rx wave file"
43- echo " -s port The serial port (or hostname:port) to connect to for TX, default /dev/ttyUSB0"
44- echo " -t Tx only, useful for manually observing SDRs"
45- echo " -x Generate tx.wav file and exit"
44+ echo " -o model select radio model number ('rigctl -l' to list)"
45+ echo " -r Rx wave file mode: Rx process supplied rx wave file"
46+ echo " -s port The serial port (or hostname:port) to control SSB radio,"
47+ echo " default /dev/ttyUSB0"
48+ echo " -t Tx only, useful for manually observing SDRs"
49+ echo " -x Generate tx.wav file and exit"
4650 echo
4751 exit
4852}
@@ -86,7 +90,7 @@ function process_rx {
8690 plot_specgram(s, 8000, 200, 3000); print('spec.jpg', '-djpg'); \
8791 quit" | octave-cli -p ${CODEC2} /octave -qf > /dev/null
8892 # attempt to decode
89- freedv_rx ${mode} ${rx} - -v --highpassthroughgain 2> rx_stats.txt | sox -t .s16 -r 8000 -c 1 - rx_freedv.wav
93+ freedv_rx ${mode} ${rx} - -v --highpassthroughgain 2> rx_stats.txt | sox -t .s16 -r $speechFs -c 1 - rx_freedv.wav
9094 cat rx_stats.txt | tr -s ' ' | cut -f5 -d' ' | awk ' $0==($0+0)' > sync.txt
9195 cat rx_stats.txt | tr -s ' ' | cut -f10 -d' ' | awk ' $0==($0+0)' > snr.txt
9296 # time domain plot of output speech, SNR, and sync
@@ -120,6 +124,11 @@ case $key in
120124 shift
121125 shift
122126 ;;
127+ -i)
128+ stationid=" $2 "
129+ shift
130+ shift
131+ ;;
123132 -o)
124133 model=" $2 "
125134 shift
175184
176185speechfile=" $1 "
177186if [ ! -f $speechfile ]; then
178- echo " Can't find ${speechfile} !"
187+ echo " Can't find input speech wave file: ${speechfile} !"
179188 exit 1
180189fi
181190
191200echo $mode
192201
193202# create compressed analog
203+ speechfile_raw_8k=$( mktemp)
204+ comp_in=$( mktemp)
194205speech_comp=$( mktemp)
195206speech_freedv=$( mktemp)
196- analog_compressor $speechfile $speech_comp $gain
207+ # If 16kHz input files for 2020x, we need an 8kHz version for SSB
208+ sox $speechfile -r 8000 -t .s16 -c 1 $speechfile_raw_8k
209+ if [ -z $stationid ]; then
210+ cp $speechfile_raw_8k $comp_in
211+ else
212+ # append station ID and apply analog compression
213+ stationid_raw_8k=$( mktemp)
214+ sox $stationid -r 8000 -t .s16 -c 1 $stationid_raw_8k
215+ cat $stationid_raw_8k $speechfile_raw_8k > $comp_in
216+ fi
217+ analog_compressor $comp_in $speech_comp $gain
218+
219+ # determine sample rate of input file we require for freedv_tx
220+ speechFs=8000
221+ if [ " $mode " == " 2020" ] || [ " $mode " == " 2020A" ] || [ " $mode $" == " 2020B" ]; then
222+ speechFs=16000
223+ fi
197224
198225# create modulated FreeDV, with compressor enabled
199- freedv_tx $mode $speechfile $speech_freedv --clip 1
226+ sox $speechfile -t .s16 -r $speechFs - | freedv_tx $mode - $speech_freedv --clip 1
200227cat $speech_comp $speech_freedv > tx.raw
201228sox -t .s16 -r 8000 -c 1 tx.raw tx.wav
202229
0 commit comments