Skip to main content

Python client for Botnoi Voice TTS API

Project description

botnoi-tts

Python client for the Botnoi Voice Text-to-Speech API.

  • ✅ Zero dependencies (stdlib only)
  • ✅ Python 3.8+
  • ✅ Type hints throughout
  • ✅ Simple .save() helper to download audio

Installation

pip install botnoi-tts

Quick Start

from botnoi_tts import BotnoiTTS

client = BotnoiTTS(token="YOUR_BOTNOI_TOKEN")

# Generate audio
response = client.generate(
    text="สวัสดีครับ",
    speaker="1",
    language="th",
)

print(response.audio_url)   # URL to the audio file
response.save("hello.mp3")  # download & save locally

API Reference

BotnoiTTS(token, timeout=30)

Parameter Type Description
token str Your Botnoi API token
timeout int Request timeout in seconds (default 30)

client.generate(text, *, speaker, volume, speed, media_type, language, save_file)

Parameter Type Default Description
text str Text to synthesise
speaker str "1" Speaker ID
volume float 1.0 0.0 – 2.0
speed float 1.0 0.5 – 2.0
media_type str "mp3" "mp3", "wav", "ogg"
language str "th" "th" or "en"
save_file bool True Persist file on Botnoi servers

Returns an AudioResponse object.


AudioResponse

Attribute Type Description
audio_url str Direct URL to the generated audio
media_type str Format of the audio file
text str Input text that was synthesised
speaker str Speaker ID used
raw dict Full raw API response

.save(path) -> str

Downloads the audio and saves it to path. Returns the absolute file path.

response.save("output")        # saves as output.mp3
response.save("output.wav")    # saves as output.wav

Aliases

client.synthesize("สวัสดี")  # same as generate()
client.tts("สวัสดี")         # short alias

Error Handling

from botnoi_tts import BotnoiTTS, BotnoiAuthError, BotnoiAPIError

client = BotnoiTTS(token="...")

try:
    response = client.generate("สวัสดีครับ")
except BotnoiAuthError:
    print("Invalid token")
except BotnoiAPIError as e:
    print(f"API error {e.status_code}: {e}")
Exception When raised
BotnoiAuthError Token is invalid or missing
BotnoiAPIError Non-200 HTTP response or connection error

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

botnoi_voice_py-0.1.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

botnoi_voice_py-0.1.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file botnoi_voice_py-0.1.0.tar.gz.

File metadata

  • Download URL: botnoi_voice_py-0.1.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for botnoi_voice_py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 378becbce233887a063923858dadcb08c70535e5e737849dd5c964a67d3e7592
MD5 21570245a0fc8ca8d13698738db617f0
BLAKE2b-256 6e687e67cab84dc7e590e9f50f19bff249203ba165f8f2cc11cb20beab7535a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for botnoi_voice_py-0.1.0.tar.gz:

Publisher: publish.yml on HakusaiTH/botnoi-voice-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file botnoi_voice_py-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for botnoi_voice_py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5c0ef852a652afee53e6272e25ec2da23c73f22ab049836eff1915bea517ac1b
MD5 448055c3238800c2f599de1dbbfe1b65
BLAKE2b-256 ab9661e805790f423b3f6ce8198c4359250e4d8fffa4b074efcf31b084402808

See more details on using hashes here.

Provenance

The following attestation bundles were made for botnoi_voice_py-0.1.0-py3-none-any.whl:

Publisher: publish.yml on HakusaiTH/botnoi-voice-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page