-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
502 Bad Gateway Error When Using Whisper.php in Laravel with Herd #7
Comments
From the logs, we can confirm that the model loaded successfully, so we can rule that out as the cause of the issue. My best guess is that the problem lies with the
To check if this is the issue, set the Once confirmed, you can adjust the In the future, I plan to store the sampled data in a C array or tensor instead of a PHP array to reduce the memory usage and improve performance. Let me know if this solves the issue or if you need further assistance. |
I already tried increasing the PHP memory_limit to -1 as suggested, but unfortunately, it made no difference. The audio file I’m testing is very small (approximately 5 seconds), so I am not sure memory exhaustion is the cause here. Additionally, the request fails very quickly, within 300ms, which seems too short for a memory-related issue to occur. This makes me suspect that the process might be exiting prematurely, possibly due to an unexpected crash or another error that isn’t being logged. |
Oh. I see. So does the |
I can confirm the issue lies within the transcribe method. I dumped the output of the readAudio function, it completes successfully and I can see the generated array without any problems. |
Okay. Just took a second look at the logs and realized that the transcribe method did run, just up to a point before it failed. Hold on |
Alright, I’ll dig into this further, but I suspect the issue is related to Laravel Herd. I tested the same endpoint using php artisan serve, and it worked perfectly as expected. This suggests that something in Herd’s configuration might be prematurely terminating the process or aborting the request. I’ll continue debugging and investigate Herd’s behavior in more detail. I’ll report back with any findings or results. |
I have a very similar setup—Apple Silicon M1, PHP 8.3 (via Herd), and Laravel 11—and I just tested it using artisan serve, and it worked perfectly. Thanks for mentioning the Herd stuff, cos I was already wondering what else. I'll continue testing on my end as well |
Hey. I wanted to drop an update for you. So I’ve tracked down the issue, though I’m still working on a proper solution. It turns out the problem is related to Metal on Apple Silicon Macs. Even though Metal isn’t actively used unless you pass the When running through One workaround that I’ve tested is recompiling I’ll keep you posted as I figure out more! |
Thanks for the update! That explanation makes a lot of sense, and I really appreciate you looking into this. As a temporary workaround, I’ve been using the following snippet to get things working in Herd with Laravel Concurrency. While I know it’s not the ideal solution, it does the job for now. I opted to use concurrency with a single callback instead of defer, as I need to wait for the result: [$result] = Concurrency::run([
function() use ($responseFormat, $file) {
Whisper::setLogger(Log::getLogger());
$whisper = Whisper::fromPretrained('large-v3', baseDir: storage_path('app/models'));
$audio = readAudio(storage_path('app/private/' . $file));
$segmentsJson = [];
return $whisper->transcribe($audio, 4);
}
]); This approach is far from perfect, but it’s working for me at the moment. Thanks again for your efforts! |
Hi! First of all, thank you for the amazing work on this package!
I am integrating Whisper.php into my Laravel project to implement a transcription API endpoint. However, I am encountering a strange issue that results in a 502 Bad Gateway error when processing requests.
Debugging Steps Taken
[error] 77725#32945537: *3 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: *****.test, request: "POST /api/v1/audio/transcriptions HTTP/1.1",
Logs and Code
Whisper.php Logs:
Current Implementation Code:
I also tried increasing php memory limits with no luck.
Environment Details:
The text was updated successfully, but these errors were encountered: