Closed bradleybernard closed 1 year ago
Hi @bradleybernard
I was not able to reproduce the issue. I've used the Laravel Storage facade (with a local disk instead of S3, but I think this should not matter):
$response = $client->audio()->transcribe([
'model' => 'whisper-1',
'file' => Storage::disk('local')->readStream('audio.mp3'),
'response_format' => 'text',
]);
Hey @gehrisandro, I tried again today and it seems to work with the right read flags to support S3. Closing now, thanks!
@bradleybernard What flag did you used? I have the same issue.
Run at this same problem, for those stuck with this problem, just add the following inside s3
configuration inside config/filesystems.php
:
[
'disks' => [
's3' => [
'stream_reads' => true
]
]
]
You can read more about it here: https://www.linkedin.com/pulse/solving-laravel-s3-streaming-streamreads-bryan-trudel-pxgic
Hey folks, I'm storing voice note files (.m4a) in Amazon S3 buckets. I then pass that S3 file stream to the
transcribe
function, which takes infile
in the parameters array, however it does not work as I'd want it to, throwing an exception.Taking a step back, all code examples I've seen are usually using
fopen
to create a stream resource to a file on the local filesystem like so:I'm trying to modify the
file
value above to use a file stream directly from S3 (remote). I saw the Laravel Storage facade (https://laravel.com/api/6.x/Illuminate/Support/Facades/Storage.html#method_readStream) has areadStream
method, so I tried using that by:But that throws an exception on OpenAI's end:
I'm wondering how I can stream the audio file contents from Amazon S3, directly into the OpenAI client for
transcribe
? I saw this article doing it in Node.js: https://dev.to/antondosov/pipe-a-file-stream-from-aws-s3-to-openai-whisper-in-nodejs-3bkb so I'm guessing this should be technically possible in PHP, although look different of course.Please let me know if I missed anything, I would love some help here! Thanks for this awesome library! 🙌