openai-php / client

⚡️ OpenAI PHP is a supercharged community-maintained PHP API client that allows you to interact with OpenAI API.
MIT License
4.98k stars 519 forks source link

[Bug]: Error: First argument to "Http\Message\MultipartStream\MultipartStreamBuilder::createStream()" must be a string, resource or StreamInterface. #466

Closed bestmytest closed 1 week ago

bestmytest commented 3 months ago

Description

$response = $client->audio()->transcribe([
    'model' => 'whisper-1',
    'file' => fopen('audio.mp3', 'r'),
    'response_format' => 'verbose_json',
    'timestamp_granularities' => ['segment', 'word']
]);

This fails wit the following error: Error: First argument to "Http\Message\MultipartStream\MultipartStreamBuilder::createStream()" must be a string, resource or StreamInterface.

Debugging Http\Message\MultipartStream\MultipartStreamBuilder::createStream() shows $resourse from private function createStream($resource) is set to an array of array([0]=> 'segment', [1]=>'word')

removing

 'response_format' => 'verbose_json',
    'timestamp_granularities' => ['segment', 'word']

fixes the error and the transcription works correctly.

Steps To Reproduce

$response = $client->audio()->transcribe([
    'model' => 'whisper-1',
    'file' => fopen('audio.mp3', 'r'),
    'response_format' => 'verbose_json',
    'timestamp_granularities' => ['segment', 'word']
]);

Just use the above like is shown in the example from the transcription read me file.

OpenAI PHP Client Version

v0.7.3

PHP Version

8.1.29

Notes

No response

dennissvu commented 1 month ago

+1

gehrisandro commented 1 week ago

You are using an old version. Please upgrade.