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

Signed-off-by: zh Wang <rekind133@outlook.com>
This commit is contained in:
zh Wang 2025-05-01 00:51:05 +08:00 committed by GitHub
parent 0b7e701dd4
commit d586ddc691
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -46,11 +46,15 @@ async def stream_openai_response():
"model": "openai/whisper-large-v3",
}
url = openai_api_base + "/audio/transcriptions"
headers = {"Authorization": f"Bearer {openai_api_key}"}
print("transcription result:", end=' ')
async with httpx.AsyncClient() as client:
with open(str(winning_call), "rb") as f:
async with client.stream('POST', url, files={'file': f},
data=data) as response:
async with client.stream('POST',
url,
files={'file': f},
data=data,
headers=headers) as response:
async for line in response.aiter_lines():
# Each line is a JSON object prefixed with 'data: '
if line: