Open sscotti opened 1 year ago
I'm in the exact same position - looking for code where I can download from a remote S3 public url (.wav) file and convert to mp3 - I have just tested and confirmed a command like this works:
ffmpeg -i input.wav -codec:a libmp3lame -qscale:a 4 -ar 22050 -ac 1 output.mp3
Just need to be able to convert using the wrapper.
I started looking an OpenAI with the LaravelOpenAI package:
use OpenAI\Laravel\Facades\OpenAI;
On my front-end I am creating .webm audio files, and they are getting sent to the backend. I installed the ffmpeg library into my Docker container with PHP and I now want to use FFMpeg to convert that to an .mp3 file to send to Whisper.
That part seems to be working.
Converts the file and saves it. It works because the audio file plays.
I think the OpenAI package expects the 'file' to be a UploadedFile type. So I need a way to either convert to an .mp3 just in the script without saving the file, or I need to read the saved file from Disk, but as an UploadedFile.
I would prefer to just bypass having to save it to disk and then read it back again.
I am not all that familiar with Laravel yet, but seem like there should be a way to do that. I'll still have to test it, but should work with and API KEY.
dd($file) is: (not sure if I need to change the .wav extension.
This does work if I just read the saved file, using this client: https://github.com/openai-php/client