Unverified Commit d586ddc6 authored by zh Wang's avatar zh Wang Committed by GitHub
Browse files

[BugFix] Fix authorization of openai_transcription_client.py (#17321)


Signed-off-by: default avatarzh Wang <rekind133@outlook.com>
parent 0b7e701d
...@@ -46,11 +46,15 @@ async def stream_openai_response(): ...@@ -46,11 +46,15 @@ async def stream_openai_response():
"model": "openai/whisper-large-v3", "model": "openai/whisper-large-v3",
} }
url = openai_api_base + "/audio/transcriptions" url = openai_api_base + "/audio/transcriptions"
headers = {"Authorization": f"Bearer {openai_api_key}"}
print("transcription result:", end=' ') print("transcription result:", end=' ')
async with httpx.AsyncClient() as client: async with httpx.AsyncClient() as client:
with open(str(winning_call), "rb") as f: with open(str(winning_call), "rb") as f:
async with client.stream('POST', url, files={'file': f}, async with client.stream('POST',
data=data) as response: url,
files={'file': f},
data=data,
headers=headers) as response:
async for line in response.aiter_lines(): async for line in response.aiter_lines():
# Each line is a JSON object prefixed with 'data: ' # Each line is a JSON object prefixed with 'data: '
if line: if line:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment