This commit is contained in:
Timothy Jaeryang Baek
2026-02-15 17:55:59 -06:00
parent e1b3e7252c
commit 319d3e8856
2 changed files with 24 additions and 22 deletions
+8 -7
View File
@@ -639,13 +639,14 @@ def transcription_handler(request, file_path, metadata, user=None):
if user and ENABLE_FORWARD_USER_INFO_HEADERS: if user and ENABLE_FORWARD_USER_INFO_HEADERS:
headers = include_user_info_headers(headers, user) headers = include_user_info_headers(headers, user)
r = requests.post( with open(file_path, "rb") as audio_file:
url=f"{request.app.state.config.STT_OPENAI_API_BASE_URL}/audio/transcriptions", r = requests.post(
headers=headers, url=f"{request.app.state.config.STT_OPENAI_API_BASE_URL}/audio/transcriptions",
files={"file": (filename, open(file_path, "rb"))}, headers=headers,
data=payload, files={"file": (filename, audio_file)},
timeout=AIOHTTP_CLIENT_TIMEOUT, data=payload,
) timeout=AIOHTTP_CLIENT_TIMEOUT,
)
if r.status_code == 200: if r.status_code == 200:
# Successful transcription # Successful transcription
+16 -15
View File
@@ -228,22 +228,23 @@ async def upload_pipeline(
headers = {"Authorization": f"Bearer {key}"} headers = {"Authorization": f"Bearer {key}"}
async with aiohttp.ClientSession(trust_env=True) as session: async with aiohttp.ClientSession(trust_env=True) as session:
form_data = aiohttp.FormData() with open(file_path, "rb") as f:
form_data.add_field( form_data = aiohttp.FormData()
"file", form_data.add_field(
open(file_path, "rb"), "file",
filename=filename, f,
content_type="application/octet-stream", filename=filename,
) content_type="application/octet-stream",
)
async with session.post( async with session.post(
f"{url}/pipelines/upload", f"{url}/pipelines/upload",
headers=headers, headers=headers,
data=form_data, data=form_data,
ssl=AIOHTTP_CLIENT_SESSION_SSL, ssl=AIOHTTP_CLIENT_SESSION_SSL,
) as response: ) as response:
response.raise_for_status() response.raise_for_status()
data = await response.json() data = await response.json()
return {**data} return {**data}
except Exception as e: except Exception as e: