On Mon, Jun 05, 2023 at 08:40:20AM -0400, Swelan Auguste wrote:
> I am using whisper within a Django application and based on the audio file
> I am trying to transcribe nginx would give me a request timeout error page
> but the code still executes in the background and does transcribe.
>
> Additionally, If I run the code without nginx with the Django development
> server, it works each time and even with Jupyter Notebook or pure Python
> code.
>
> My question is, how can I stop the nginx timeout error or get the app to
> delay or wait til the transcription is done?
>
>
https://github.com/swelanauguste/youtube-transcribe
>
> Grateful for any assistance
Hey Swelan, a typical solution for a long running task like transcription is to rename your url to something like '.../transcription-request', the when a user does a POST to that that URL, create a "request" record in the database, and return a 201 with the id of the created request .
Then, in a background task, look for any pending transcription requests and handle them.
The user can then poll '.../transcription-request/[id]' for the status of that transcription request. A GET should return on of the following statuses: "in progress", "failed" or "completed".
For background task processing in Django, use either:
1. a custom Django management command periodically run via cron (simpler but not super robust)
2. A task queue/runner like Celery (
https://docs.celeryq.dev/en/stable/django/first-steps-with-django.html) (robust but more complicated)