Docs/Guides/Python client
Python client
Sync and async wrappers around the REST API plus a context-manager stream helper.
Install
shell
pip install varmirSupports Python 3.9+. Stubs ship in the wheel.
Batch
batch.py
from varmir import Varmir
client = Varmir(api_key=os.environ["VARMIR_KEY"])
res = client.transcribe(
audio=open("sample.wav", "rb"),
translate_to="uk",
)
print(res.text)
print(res.translation.text)Streaming
The streaming helper is iterable: server-sent events come out in order, you process them with a regular for loop.
stream.py
with client.stream( sample_rate=16000, translate_to="uk") as sess:
for chunk in mic.read(20):
sess.send(chunk)
for evt in sess:
if evt.type =="final":
print(evt.text)