如何将音频文件与PHP结合? [关闭]

I want to create a basic speech software, where the PHP program combines a few ready-made sounds (such as the, cat, sat, on, the, mat), and then allows the user to download the finished file (which then, following from the above example, would say the cat sat on the mat).

A few options I have considered:

  • Some kind of PHP or PEAR library (not PEAR if possible please)
  • Reading using a binary-safe reading function from all the audio files, then combining them manually

Are there any I have missed? Or have I not covered the correct option yet?

If you really need to do this using native PHP, then you're probably out of luck.

I don't know about your exact need, but the I would second the idea to use a dedicated library, such as SoX, driven by your PHP code through exec().

Also, supposing you are writing a web application, expect the processing time to be long enough that you will have to manage running async sound generation.

Use SoX, it works fine:

$ sox read.wav the.wav internet.wav read-the-internet.mp3

You might need the libsox-fmt-all package to have support for your file types.