-
Notifications
You must be signed in to change notification settings - Fork 14
/
pjsua_wav_phones.sh
executable file
·54 lines (48 loc) · 1.61 KB
/
pjsua_wav_phones.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
#
# Automation of the .wav phones creation.
# 1. Download a set of .wav recordings.
# 2. Convert them using sox.
# 3. Bind them as SIP UAs using pjsua.
# 4. Each pjsua will be opened in a tmux terminal.
# Author: luismartingil
# Year: 2013
#
# Some IPs for the pjsua
IP=`/sbin/ifconfig eth1 | grep 'inet addr:' | cut -d: -f2| cut -d' ' -f1`
BOUND_ADDR=$IP
IP_ADDR=$IP
STUN_SRV=192.168.191.15
TMUX_SRV=main
# The array of 'url desc port i'
# <url> url to download the wav from
# <desc> description of the recording/ua
# <port> port to bind the UA
# <i> counter # Would be better to automate
array=('
http://www.villagegeek.com/downloads/webwavs/dangerousjob.wav,ua1-dangerousjob,5060,1
http://www.villagegeek.com/downloads/webwavs/getdrunk.wav,ua2-getdrunk,5061,2
http://www.villagegeek.com/downloads/webwavs/guitar.wav,ua3-guitar,5062,3
http://www.villagegeek.com/downloads/webwavs/goodcat.wav,ua3-alf_goodcat,5063,4
')
# New tmux session
tmux new-session -d -s $TMUX_SRV -n $TMUX_SRV
# Let's go!
for i in $array
do IFS=",";
set $i
tmp=$2_in.wav
# Getting the .wav
wget -c $1 -O $tmp
# Converting the .wav
sox $tmp --encoding signed-integer --bits 16 -c 1 -r 8000 $2.wav
# Use a proper tmux window to execute the pjsua
tmux new-window -t $TMUX_SRV:$4 -n $2:$3
cmd=(./pjsua --bound-addr=$BOUND_ADDR --ip-addr=$IP_ADDR --stun-srv=$STUN_SRV --auto-answer=200 --local-port=$3 --play-file=$2.wav --null-audio --auto-play)
str="${cmd[@]}"
tmux send-keys -t $TMUX_SRV:$4 $str C-m
done
# Tmux final selection
tmux select-window -t $TMUX_SRV:1
tmux attach-session -t $TMUX_SRV
echo 'phones created!'