iotype — Python SDK
pip install iotype # HTTP only
pip install "iotype[realtime]" # + streaming ASR
from iotype import Iotype
io = Iotype() # reads IOTYPE_TOKEN; or Iotype("your-token")
Synchronous
io.translate("سلام دنیا", "fa", "en") # -> "Hello world"
io.synthesize("سلام دنیا", speaker="tanaz") # -> "https://.../x.mp3"
io.transcribe_instant("note.mp3") # -> "..."
Asynchronous — OCR and long transcription
These endpoints return a handle, not a result. Pass wait=True and the SDK polls for you.
text = io.ocr("contract.pdf", summarize=True, wait=True)
text = io.transcribe("meeting.mp3", source_lang="fa", wait=True)
Without wait, you get a File and drive the loop yourself:
file = io.ocr("contract.pdf")
print(file.uuid) # store this — it survives a restart
text = io.wait_for(file.uuid, process_type="ocr", timeout=1800)
Inspect state at any time:
file = io.track(uuid)
file.done # every process finished?
file.results() # {"ocr": "...", "summarize": "..."}
file.result("summarize") # one process, matched by type
Backoff is 5s doubling to a 60s ceiling. On timeout you get ProcessingTimeout carrying the uuid — the job is still running server-side, so resume rather than re-upload.
Realtime ASR
connect() completes the handshake and blocks until the server authorizes, so sample_rate is known before you open a microphone.
import threading
with io.realtime(model="io-fa") as session:
print(session.sample_rate) # e.g. 44100 — the server decides, resample to it
print(session.frame_size) # samples per 20 ms frame
threading.Thread(target=feed_audio, args=(session,), daemon=True).start()
committed = ""
for event in session:
if event["type"] == "partial":
print(committed + event["text"], end="\r") # interim — do not persist
elif event["text"].strip():
committed += event["text"].strip() + " " # settled — persist this
sample_rate is not a constant. The server tells you what it wants and you resample to match; hardcoding a rate produces silently wrong transcripts. iotype.realtime.resample_linear() handles the conversion, float32_to_pcm16() the encoding.
Audio is PCM 16-bit, mono, little-endian, raw binary, 20 ms per frame.
Call end_of_stream() before closing — it sends {"eof":1} and flushes the decoder. Closing without it loses the last utterance. run() does this for you.
From a browser or mobile app, mint a Flash Token server-side and pass token_type="flash_token". Never ship your access token to a client.
A complete browser implementation of this protocol lives in examples/browser-asr/.
Errors
from iotype import AuthenticationError, ProcessingTimeout, IotypeError
try:
io.translate("...", "fa", "en")
except AuthenticationError:
... # missing/malformed/expired token, OR exhausted balance
except ProcessingTimeout as e:
... # e.uuid is still processing server-side
except IotypeError:
... # catch-all
Transient failures (429, 5xx, network) are retried automatically with backoff. Failed requests are not billed.
Built on the iotype API — Persian, English and Arabic speech recognition, OCR, translation and text-to-speech.
- Get an API token · API token packages
- realtime ASR API reference · OCR API reference
- Full guides: English · فارسی · OpenAPI spec
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file iotype_ai-1.0.0.tar.gz.
File metadata
- Download URL: iotype_ai-1.0.0.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e456dfbd1f196682f41c37dda20770ae106f925598e33367c90e26c12d81af0d
|
|
| MD5 |
fa2415d778255e25012ae7bddfd5ef6f
|
|
| BLAKE2b-256 |
29f12ab9b324bd40d229bbe2d1422e44d023d0e1c3a8c8822ab4b0d4760fb17a
|
File details
Details for the file iotype_ai-1.0.0-py3-none-any.whl.
File metadata
- Download URL: iotype_ai-1.0.0-py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e2db2fba3b318f5eef52acff8866457cf17fc24fb3c60b6c055095eb4446dbd
|
|
| MD5 |
06161c1bd0c128be85585f6fbe23bdde
|
|
| BLAKE2b-256 |
a08d0710956385f2509504b48dbb0ae05206bcd896c308d550d729c4499b35c0
|