Skip to main content

Python client for Botnoi Voice TTS API

Project description

botnoi-voice-py

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-voice-py

Quick Start

from botnoi_tts import BotnoiTTS

client = BotnoiTTS(token="YOUR_BOTNOI_TOKEN")

# v1
response = client.v1("สวัสดีครับ", speaker="1")
print(response.audio_url)
response.save("output_v1.mp3")

# v2
response = client.v2("สวัสดีครับ", speaker="3")
print(response.audio_url)
response.save("output_v2.mp3")

API Reference

BotnoiTTS(token, timeout=30)

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

client.v1(text, ...) / client.v2(text, ...)

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

ความแตกต่างระหว่าง v1 และ v2:

v1 v2
Endpoint /v1/generate_audio /v1/generate_audio_v2
Speaker support รุ่นเก่า รุ่นใหม่ รองรับ speaker มากกว่า

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
version str API version used — "v1" or "v2"
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

Error Handling

from botnoi_tts import BotnoiTTS, BotnoiAuthError, BotnoiAPIError

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

try:
    response = client.v2("สวัสดีครับ", speaker="3")
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.7.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.7-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: botnoi_voice_py-0.1.7.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.7.tar.gz
Algorithm Hash digest
SHA256 4bcee6136d253b6afd4ce901827f008af5538ef151e881077dcf31028878f373
MD5 190919dc63c4db9b0a1da88a03665c6e
BLAKE2b-256 7e745f08c1abbf1bb5f9b0f6aad3a86721b390343759817fe0c5b9c75b778c1c

See more details on using hashes here.

Provenance

The following attestation bundles were made for botnoi_voice_py-0.1.7.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.7-py3-none-any.whl.

File metadata

File hashes

Hashes for botnoi_voice_py-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 3f592ebb7b65593f22d50f134ab915dd12355fe81301f323211c79521436abec
MD5 6fd2c7721e5f6977bf3f9f8deed07fd9
BLAKE2b-256 70205e009940744b4886222250068a753a8bbba662bb815ad4d72ddd6ae2e5a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for botnoi_voice_py-0.1.7-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