Automatic mixing from audio and XML files


(please, be indulgent for my English)

I would like to use Audacity as a kind of black box callable by command line from another program (Java, PHP, etc.). . Below are the explanations:

In one hand, I have a set of audio files (Wav mainly, but also MP3) corresponding to phrases uttered by persons (characters) and to a mood music. On the other hand, I have XML files describing the actions of the persons (when they talk, how long, what are the corresponding WAV files, etc.).
My problem is that I would like to use Audacity to create an application that needs to run in command-line mode (required) and in interactive mode (optional) to create sound files resulting from the mixing of character’s phrases and mood music relying on the information supplied by the XML code. Basically, Audacity would be seen as a black box to which I give XML files, Wav, and MP3 input, and that gives me MP3s or WAV output.

Remarks very important:

  • The mix must ensure that when a character speaks, the volume of the music decreases (if possible not too brutal), and this volume should resume its original value when the person has finished talking. The change in volume will be customizable (for instance changed suddenly or gradually, etc.). This parameter is in the XML file.
  • The input files are not necessarily all in the same format (Wav, MP3) and with the same characteristics (8/16 bits, 22/44Khz, etc.), the application must be able to manage them. In addition, the format of output sound files should be configurable (parameter in the command line, or at worst in the XML).
  • The input files may have different sound levels; It is imperative that I can choose the loudness of the output file. Similarly, it is imperative that I can choose the rate of decline in volume for the mixes (for example 30%, etc.).

Have somebody already done that with Audacity (or another application)? Could you tell me how? Is it possible to “drive” Audacity like this, and if yes, how?
In short, any good idea and information is welcome.

Thank you in advance for your help that will be very important to me.