StreamingResponse stops Azure Speech recognition if method is async but not if its synchronous #10791
Unanswered
AngryBacteria
asked this question in
Questions
Replies: 2 comments
-
Hi there, I'm not sure if you could fix your problem but I've post this thread in StackOverflow. |
Beta Was this translation helpful? Give feedback.
0 replies
-
It looks like the trigger function to stop process is non-blocking judging by the name... have you tried making that function synchronous? Maybe I am missing something, but figured I'd share. Didn't see you comment on that in your description. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First Check
Commit to Help
Example Code
Description
I have the following Issue which I am trying to solve for weeks now. I have an endpoint that transcribes a file and sends the results back as a StreamingResponse step by step. It uses the azure speech to text SDK. The issue is that if the client stops the request (disconnects or actively aborts), the speech to text callbacks do not stop. They only stop after the file finished transcribing. This is extremely bad for the performance of the API. This means the function is still sending requests to azure, even if the client does not listen to server events anymore.
I narrowed the issue down to the function
transcribe_with_push_stream
:Making this function async does not make any sense, because there is no await and nothing can be awaited in the library. Or does this not matter and I can safely mark it as async? The problem with that is that the whisper function is not async and cannot be made async. This means one StreamingResponse would be async and the other not.
I am unsure what to do here. I tried everything. I dont think making the
transcribe_with_push_stream
async is a good solution, because it has nothing that can be awaited, why would it make sense to make it async? I tried this solution in the issue but it didnt help.I am extremely grateful for everyone that wants to help me. Here is also the source-code if anyone wants to take a look. It uses the "fix" to make the function async and works.
Operating System
Windows
Operating System Details
No response
FastAPI Version
0.103.2
Pydantic Version
2.4.2
Python Version
3.11.5
Additional Context
This is how the frontend aborts the request
Beta Was this translation helpful? Give feedback.
All reactions