[asterisk-dev] [feature] Support for relative paths for all "say" functions

Nicolas Chapleau nicchap at hotmail.com
Fri Aug 21 08:58:23 CDT 2009


I am trying to add relative path support for digits/letters/phonetics for all "say" functions that are located in say.c. There are many ways to do this and I'm trying to choose the least obstructive as far as I can tell. I'd like some input if possible:
 
*** Reasoning ***
 
normal voice files using playback (background, ...) can have a prefix added to the language 
 
ie. playback(welcome), playback(path1/welcome), playback(sub1/path1/welcome) ...
 
whereas "say" functions can't => SayNumber(1000)
 
this limits us to a single voice under a specific language for any digits/letters and phonetics (what I call VOCAB files). We need to able to use multiple voices under an existing language for digits/letters amd phonetics. For example:
 
Consider the following sound file directory structure:

(English)
sounds/digits
sounds/letters
sounds/phonetics
sounds/customer1
sounds/customer2
sounds/customer3
sounds/customer1/digits
sounds/customer1/letters
sounds/customer1/phonetics

(French)
sounds/fr/digits
sounds/fr/letters
sounds/fr/phonetics
sounds/fr/customer1
sounds/fr/customer2
sounds/fr/customer3
sounds/fr/customer1/digits
sounds/fr/customer1/letters
sounds/fr/customer1/phonetics

there is no way to use the files under customer1 when using any of the "say" functions, as they are hard coded to look in the root language path.
 
*** Implementation ***
 
Method 1 (what I would prefer):
One way to add this would be to add an element in the ast_chan structure, but I do not want to do this as I feel that it is too obstructive, unless the API has previsions for this.
 
Method 2:
Add the ability to pass in a relative path in each "say" function, but again this changes the way existing functions are called, and also requires a change to each "say" function (to obstructive). 
 
Method 3 (what I chose):
Add an optional CHANNEL variable and use it to prefix the path in ast_say_streamfile. By using this method, I only need to change 1 function (ast_say_streamfile) which is called in ALL "say" functions, as well as add 2 functions that checks/builds the filename with the prefix. This method only applies to functions in say.c and does not affect existing syntax.
 
*** How it works ***
 
Add a channel variable called VOCAB_RELATIVE_PATH to enable this feature (simply call the dialplan Set function to enable it). If this variable exists, then the relative path defined by it is used, otherwise it defaults to it's usual location. If the file is not found under the relative path, it also defaults to it's usual location. 
 
example using sound file structure above:
 
exten => 111,1,Answer()
; play 1234 using the default digits path
exten => 111,n,SayNumber(1234)
 
; set a relative digits path to customer1
exten => 111,n,Set(VOCAB_RELATIVE_PATH=customer1)
exten => 111,n,SayNumber(1234)
 
; set an invalid relative path, which will result in digits played from it's default location
exten => 111,n,Set(VOCAB_RELATIVE_PATH=customer2)
exten => 111,n,say_number(1234)
 
Testing: All functions have been tested and work. We actually use it on all out boxes and it is working well. I tested the following scenarios for english and french languages (any language applies):

- No VOCAB_RELATIVE_PATH
- invalid VOCAB_RELATIVE_PATH
- valid VOCAB_RELATIVE_PATH - missing files
- valid VOCAB_RELATIVE_PATH - files present

Other notes: 

- Does not affect files used in other modules, such as voicemail and meetme. 
- see https://issues.asterisk.org/view.php?id=14749 for patch and notes
 
Any (constructive) input or thoughts would be great!
 
NicChap.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-dev/attachments/20090821/50c6aa9a/attachment.htm 


More information about the asterisk-dev mailing list