Skip to main content

Tapra Python SDK

Official Python client for the Tapra API: Tunisian Arabic / French / English code-switching transcription, speech, translation, and Arabizi ↔ Arabic conversion.

pip install "tapra[realtime]"   # drop [realtime] if you only use the REST endpoints
from tapra import Tapra

client = Tapra()  # https://api.tapra.tn; api_key defaults to TAPRA_API_KEY

with open("meeting.m4a", "rb") as audio:
    transcript = client.transcriptions.create(file=audio, timestamps="word")
print(transcript.text)

client.script.convert(text="3lech 7abit l9anoun?", direction="ZI2AR")
# Translations are currently offline (the endpoint returns an error until Tapra-Translate is back).
for event in client.translations.create_stream(input="عندي برشا خدمة", target="French"):
    print(event.type, event.delta)

Pass base_url= to target another host, such as a local model host.

Async: AsyncTapra has the same methods. Errors raise typed exceptions (PaymentRequiredError for HTTP 402, UnauthorizedError, …) whose .body.error holds type and message. Pass idempotency_key= to retry metered requests safely, and use client.<resource>.with_raw_response.<method>() to read x-tapra-cost-tnd.

Realtime transcription

from tapra import connect_realtime

async with connect_realtime(language="ar-AR") as session:  # wss://api.tapra.tn
    for chunk in pcm_chunks:            # mono pcm_s16le, 16 kHz
        await session.send_audio(chunk)
    final = await session.stop()
print(final.text, final.usage)

Prices

Tapra charges in TND. The SDK does not hardcode any price or dollar amount: it reads the same live price list the website and the meter use.

from tapra.pricing import fetch_tapra_prices, estimate_cost_tnd, estimate_cost_usd

prices = fetch_tapra_prices()  # GET https://www.tapra.tn/api/pricing, no key needed

estimate_cost_tnd(prices, "tts", 1200)  # 0.24 TND — 1,200 characters
estimate_cost_usd(prices, "tts", 1200)  # ≈ $0.08, at the rate the list was fetched with

estimate_cost_micro_tnd returns the exact integer amount the meter charges, including the per-request minimum for text products. The endpoint also returns tndPerUsd and the date of the published rate, so a UI can show which rate it used.

Development

src/tapra/ is generated by Fern from openapi/tapra-api.json; do not edit it by hand. src/tapra/realtime.py and src/tapra/pricing.py are hand-written (kept by .fernignore). Tests: sdks/tests/python.

Command line

Installing the SDK also installs the tapra command (pip install "tapra[realtime]" adds tapra stream). Same commands as the npm package's:

tapra auth login                               # checks the key, then saves it
tapra transcribe call.mp3                      # Derja + French + English, speakers labelled
tapra transcribe video.mp4 --format srt -o subs.srt   # any audio/video; long files are split (needs ffmpeg)
tapra stream --partials                        # live from the microphone (ffmpeg), Ctrl+C to stop
tapra speak "حبيت نتلقاو demain" --voice amal -o hello.wav
tapra flip "3lech 7abit l9anoun?"               # -> علاش حبيت القانون؟
tapra translate "chnowa el jaw?" --to French
tapra balance                                  # also: models, voices, pricing, languages, health

In a terminal, paid commands show the estimated cost and your balance and ask first (-y skips, --max-cost 0.5 sets a limit). They print the exact cost and balance on stderr when done; --json prints the full response and --dry-run shows the request without sending it. Exit codes: 0 ok, 1 error, 2 bad usage, 3 missing or invalid key, 4 balance too low. Full reference: https://www.tapra.tn/cli

Metadata

Release files for tapra 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tapra 0.1.4
File Size Uploaded Provenance Actions
tapra-0.1.4.tar.gz 79.0 kB With provenance Details for tapra-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tapra 0.1.4
File Interpreter ABI Platform Actions
tapra-0.1.4-py3-none-any.whl Python 3 none any Details for tapra-0.1.4-py3-none-any.whl

Total release size: 198.6 kB

Release files / tapra-0.1.4.tar.gz

Download URL tapra-0.1.4.tar.gz
Size 79.0 kB
Tags Source
SHA-256 checksum
How to use checksums
75a50323bd037ca60db7825231fc4ab80482b70334f55b884a73a5f78bca9617
BLAKE2b-256 checksum
How to use checksums
8f4ca595433544ebb97a938fdbae5fd4f40c7bb40fbcda08dd5ba033be34b598
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Release files / tapra-0.1.4-py3-none-any.whl

Download URL tapra-0.1.4-py3-none-any.whl
Size 119.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7c541a841d90c8cb405bc44f73ae71bc64257f0eb994d9a1e36109492a583818
BLAKE2b-256 checksum
How to use checksums
ea3b16d1aadca7d91b1555cc5d5c8d3f8f48ff6b6a9df5c316b195612c5d036c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Security for tapra 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for tapra-0.1.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page