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 and invoices in TND only. The SDK does not hardcode any price: it reads the same live price list the website and the meter use.

from tapra.pricing import fetch_tapra_prices, estimate_cost_tnd

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_micro_tnd returns the exact integer amount the meter charges, including the per-request minimum for text products.

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 zeineb -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.7

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.7
File Size Uploaded Provenance Actions
tapra-0.1.7.tar.gz 80.6 kB With provenance Details for tapra-0.1.7.tar.gz

Built distribution (wheel)

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

Total release size: 201.6 kB

Release files / tapra-0.1.7.tar.gz

Download URL tapra-0.1.7.tar.gz
Size 80.6 kB
Tags Source
SHA-256 checksum
How to use checksums
52a78b9379bc68d5fcaed53716b9ad83c07c04da552f904d91140c2f231c0ba7
BLAKE2b-256 checksum
How to use checksums
cd97aa1565492bcf566b3f3f59e8a995db6beadd84b296f2e9da44ef27c7749f
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 Nov 3, 2026.

Transparency log

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

Download URL tapra-0.1.7-py3-none-any.whl
Size 121.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3241944566a42869ea766db623ae36c15166599c762f220361248ab6543ec18b
BLAKE2b-256 checksum
How to use checksums
421383974b17de34c519c3dbf30d67e2c76ca5e238d657de9653b459e5c7b8c5
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 Nov 3, 2026.

Transparency log

Security for tapra 0.1.7

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.7.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 Nov 3, 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