30 lines
810 B
Python
30 lines
810 B
Python
import asyncio
|
|
import httpx
|
|
import os
|
|
import base64
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
SARVAM_API_KEY = os.getenv("SARVAM_API_KEY", "")
|
|
|
|
async def test():
|
|
with open("test.wav", "rb") as f:
|
|
audio_data = f.read()
|
|
|
|
async with httpx.AsyncClient(timeout=60) as client:
|
|
submit_resp = await client.post(
|
|
"https://api.sarvam.ai/speech-to-text",
|
|
headers={"api-subscription-key": SARVAM_API_KEY},
|
|
files={"file": ("test.wav", audio_data, "audio/wav")},
|
|
data={
|
|
"model": "saaras:v4",
|
|
"mode": "codemix",
|
|
"with_timestamps": "true",
|
|
"with_diarization": "true",
|
|
}
|
|
)
|
|
print(submit_resp.status_code)
|
|
print(submit_resp.json())
|
|
|
|
asyncio.run(test())
|