init
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
# An example action script for FrugalVox
|
||||
# Implements three actions: echo test, caller address readback and parameterized beep
|
||||
|
||||
import os, sys # example of using commonly available Python modules
|
||||
from pyVoIP.VoIP import CallState # example of using an installation-specific module
|
||||
from fvx import tts_to_buf, detect_dtmf, audio_buf_len, emptybuf, get_caller_addr, flush_input_audio, playbuf # example of using the FrugalVox kernel module (fvx)
|
||||
|
||||
def run_action(action_id, params, call_obj, user_id, config, clips, calls):
|
||||
if action_id == '32': # echo test: just enter 32#
|
||||
playbuf(tts_to_buf('Entering the echo test, press pound to return', config['tts']), call_obj)
|
||||
flush_input_audio(call_obj)
|
||||
cache_digit = None # in-band digit cache
|
||||
while call_obj.state == CallState.ANSWERED: # main event loop
|
||||
audiobuf = call_obj.read_audio(audio_buf_len, True) # blocking audio buffer read
|
||||
call_obj.write_audio(audiobuf) # echo the audio
|
||||
digit = call_obj.get_dtmf() # get a single out-of-band DTMF digit
|
||||
if digit == '' and audiobuf != emptybuf: # no out-of-band digit, try in-band detection
|
||||
ib_digit = detect_dtmf(audiobuf)
|
||||
if ib_digit != cache_digit:
|
||||
if ib_digit == None: # digit transmission ended
|
||||
digit = cache_digit # save the digit
|
||||
cache_digit = None # reset the cache
|
||||
else: # digit transmission started
|
||||
cache_digit = ib_digit
|
||||
if digit == '#':
|
||||
playbuf(tts_to_buf('Echo test ended', config['tts']), call_obj)
|
||||
return
|
||||
elif action_id == '24': # Caller ID readback: enter 24#
|
||||
playbuf(tts_to_buf('Your caller ID is %s' % get_caller_addr(call_obj), config['tts']), call_obj) # demonstration of the on-the-fly TTS
|
||||
else: # beep command: 22*3# tells to beep 3 times
|
||||
times = 1 # how many times we should beep
|
||||
if len(params) > 0:
|
||||
times = int(params[0])
|
||||
if times > 10: # limit beeps to 10
|
||||
times = 10
|
||||
# send the beeps
|
||||
playbuf((clips['beep']+(emptybuf*10)) * times, call_obj)
|
||||
return
|
||||
Binary file not shown.
@@ -0,0 +1,46 @@
|
||||
---
|
||||
# SIP client configuration for incoming calls
|
||||
sip:
|
||||
host: sip.example.com
|
||||
port: 5060
|
||||
transport: udp # not used for now, UDP is the only option
|
||||
username: 'exampleuser'
|
||||
password: 'examplepass123'
|
||||
rtpPortLow: 10000
|
||||
rtpPortHigh: 20000
|
||||
|
||||
# TTS engine configuration
|
||||
tts:
|
||||
voice: 'us-mbrola-2'
|
||||
rate: 130 # words per minute
|
||||
volume: 70 # from 0 to 200
|
||||
pitch: 60
|
||||
cmd: # command templates, do not modify them unless you're fully changing the engine
|
||||
synth: 'espeak -v %s -a %d -p %d -s %d -w %s "%s"' # parameter order: voice, volume, pitch, rate, filename, text
|
||||
transcode: 'sox %s -r 8000 -b 8 -c 1 -D %s' # parameter order: inputfile, outputfile
|
||||
phrases: # key is the clip name, value is the text
|
||||
passprompt: 'Please enter your pin followed by pound after the beep.'
|
||||
cmd: 'Please enter your command, ending with pound.'
|
||||
invalidpass: 'Invalid pin, bye!'
|
||||
nocmd: 'Command not found.'
|
||||
|
||||
# static audio clips configuration
|
||||
clips:
|
||||
dir: './clips'
|
||||
files: # in addition to the ones generated from phrases
|
||||
beep: 'beep.wav'
|
||||
|
||||
# IVR configuration
|
||||
ivr:
|
||||
auth: true # set to false to disable user PINs and go straight to actions (not recommended)
|
||||
authpromptclips: [passprompt, beep] # sequence of authentication prompt audio clips
|
||||
authfailclips: [invalidpass]
|
||||
cmdfailclips: [nocmd]
|
||||
cmdpromptclips: [cmd]
|
||||
users: # user PINs and supported actions, '*' means all
|
||||
'3105': '*'
|
||||
'3246': ['32']
|
||||
actions: # all registered actions: command => script filename
|
||||
'32': './actions/echobeep.py'
|
||||
'22': './actions/echobeep.py'
|
||||
'24': './actions/echobeep.py'
|
||||
Reference in New Issue
Block a user