Re: How to test for the existance of an audio file
David Sugar <[email protected]> Fri, 02 May 2008 15:20:54 -0400
| Newsgroups | gmane.comp.gnu.bayonne.devel |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format. --------------020108010604030108020609 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Bayonne distinguishes between paths that resolve to a voice library and are presumed to be static/unchanging (and can be on a read-only filesystem), and those that reference modifiable file space (usually in /var/lib/bayonne/xxx/) and does name manipulations based on this. Also -file uses a simpler form and probably requires the extension. Hence, for what you want to do, I think you want a file space and a partial path: .dir myworkspace ... if -file myworkspace/xxx.au then play myworkspace/xxx.au else play missing_message endif Using "play.one myworkspace/xxx.au missing_message" should also accomplish this effect, since it plays only "one" of those as found... Tony White wrote: > David, > > I've tried your suggestion - but no joy (yet!). I'm using bayonne1, > so I looked at file.cpp (in ccscript2 source) and found tests > 'exists', 'file', and 'dir' (with exists and file being essentially > the same) - but I'm not a c++ expert ;) > > So, I have 'use file' at the top of the script, and within the script i have: > > set %1 "file_to_play" > . > . > . > if -file %1 > then > play %1 > else > play missing_message > endif > > but I always get the missing_message.au playing. %1 contains the name > of the file to play, without the .au suffix > > I am assuming that the same conditions apply as with 'play' - so that > the default extension is .au, and the various possible locations for > the file are searched (although, to avoid path problems confusing the > issue, both file_to_play.au, and missing_message.au are in > /usr/local/share/bayonne/UsEngM > > What am I doing wrong? > > Tony > > > 2008/5/1 David Sugar <[email protected]>: >> Yes there is. With "if -file xxx" or "do -file xxx" in a loop, "case >> -file", etc. There is a -file and -dir option for conditional tests. With >> Bayonne and ccscript2 these were installed as a separate dso with "use >> file", with bayonne2 they are built-ins. Check server/runtime.cpp >> "addConditional" for full list.... >> >> >> >> Tony White wrote: >> >>> Thanks David, >>> >>> So there is no way, other than jumping into a TGI script, to test for >>> an audio (or other) file's existance, so that a decision can be made >>> if a file is not present? Do you think it feasible that an external >>> TGI script is run after every keypress as a caller makes choices? Or >>> is it better to run one TGI script at the start of the call, to >>> populate an array with ALL possible files' presence or absence? The >>> files may run into the tens of thousands! so it would be a VERY big >>> array - and would be at least four-dimensional. And as the system is >>> dynamic, files may appear, or disappear from one call to the next. >>> >>> Tony >>> >>> 2008/5/1 David Sugar <[email protected]>: >>> >>>> There is a "play.one" option, that plays the first file that is found, >> and >>>> only one, out of a list. There is a "play.any" I think, that plays any >> that >>>> can be found and skips any not found in a list. The default is to abort >> if >>>> not found. >>>> >>>> >>>> >>>> Tony White wrote: >>>> >>>> >>>>> Hi David and all, >>>>> >>>>> In bayonne script, if I list several files to play eg. >>>>> >>>>> play %1 %2 %3 ...... >>>>> >>>>> ...where %1, %2, %3 etc. variables have been set to file1.au, >>>>> file2.au, file3.au ..... >>>>> >>>>> so long as all three files exist on disk, then all is well. BUT if, >>>>> for example, file1.au doesn't exist, then the play will abort - >>>>> without playing the rest of the files. >>>>> >>>>> The files are dynamically generated outside the bayonne environment - >>>>> and may sometimes be missing. So I am stuck on how to test within a >>>>> script that a file exists before attempting to play it - and indeed to >>>>> substitute a 'default' file instead. >>>>> >>>>> The only way i can see is to jump out into a TGI - but is there >>>>> already a way to test this? And if not, maybe this would be a >>>>> possible test to include in the next version? >>>>> >>>>> Oh - and before I get the suggestion: >>>>> play %1 >>>>> play %2 >>>>> play %3 >>>>> .... >>>>> >>>>> yes, that works insofar as playing all files, even if one is missing >>>>> - but there is a 'step' delay between each 'play' statement - which I >>>>> want to avoid... and there seems to be no way to see if a file is >>>>> missing so as to be able to substitute a 'default' file instead. >>>>> >>>>> Thanks, >>>>> >>>>> >>> >>> >>> > > > --------------020108010604030108020609 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Bayonne-devel mailing list [email protected] http://lists.gnu.org/mailman/listinfo/bayonne-devel --------------020108010604030108020609--