refac
This commit is contained in:
1 parent
e1b3e7252c
commit
319d3e8856
2 files changed
+4
-2
No files matched your search
@@ -639,10 +639,11 @@ 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)
|
||||||
|
|
||||||
|
with open(file_path, "rb") as audio_file:
|
||||||
r = requests.post(
|
r = requests.post(
|
||||||
url=f"{request.app.state.config.STT_OPENAI_API_BASE_URL}/audio/transcriptions",
|
url=f"{request.app.state.config.STT_OPENAI_API_BASE_URL}/audio/transcriptions",
|
||||||
headers=headers,
|
headers=headers,
|
||||||
files={"file": (filename, open(file_path, "rb"))},
|
files={"file": (filename, audio_file)},
|
||||||
data=payload,
|
data=payload,
|
||||||
timeout=AIOHTTP_CLIENT_TIMEOUT,
|
timeout=AIOHTTP_CLIENT_TIMEOUT,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -228,10 +228,11 @@ 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:
|
||||||
|
with open(file_path, "rb") as f:
|
||||||
form_data = aiohttp.FormData()
|
form_data = aiohttp.FormData()
|
||||||
form_data.add_field(
|
form_data.add_field(
|
||||||
"file",
|
"file",
|
||||||
open(file_path, "rb"),
|
f,
|
||||||
filename=filename,
|
filename=filename,
|
||||||
content_type="application/octet-stream",
|
content_type="application/octet-stream",
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in new issue
Block a user