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
Release history Release notifications | RSS feed
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bcee6136d253b6afd4ce901827f008af5538ef151e881077dcf31028878f373
|
|
| MD5 |
190919dc63c4db9b0a1da88a03665c6e
|
|
| BLAKE2b-256 |
7e745f08c1abbf1bb5f9b0f6aad3a86721b390343759817fe0c5b9c75b778c1c
|
Provenance
The following attestation bundles were made for botnoi_voice_py-0.1.7.tar.gz:
Publisher:
publish.yml on HakusaiTH/botnoi-voice-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
botnoi_voice_py-0.1.7.tar.gz -
Subject digest:
4bcee6136d253b6afd4ce901827f008af5538ef151e881077dcf31028878f373 - Sigstore transparency entry: 995155317
- Sigstore integration time:
-
Permalink:
HakusaiTH/botnoi-voice-py@12d34eb2a7bbdeee76a70fe0cf156411a7f44065 -
Branch / Tag:
refs/tags/v0.1.7 - Owner: https://github.com/HakusaiTH
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@12d34eb2a7bbdeee76a70fe0cf156411a7f44065 -
Trigger Event:
push
-
Statement type:
File details
Details for the file botnoi_voice_py-0.1.7-py3-none-any.whl.
File metadata
- Download URL: botnoi_voice_py-0.1.7-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f592ebb7b65593f22d50f134ab915dd12355fe81301f323211c79521436abec
|
|
| MD5 |
6fd2c7721e5f6977bf3f9f8deed07fd9
|
|
| BLAKE2b-256 |
70205e009940744b4886222250068a753a8bbba662bb815ad4d72ddd6ae2e5a0
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
botnoi_voice_py-0.1.7-py3-none-any.whl -
Subject digest:
3f592ebb7b65593f22d50f134ab915dd12355fe81301f323211c79521436abec - Sigstore transparency entry: 995155318
- Sigstore integration time:
-
Permalink:
HakusaiTH/botnoi-voice-py@12d34eb2a7bbdeee76a70fe0cf156411a7f44065 -
Branch / Tag:
refs/tags/v0.1.7 - Owner: https://github.com/HakusaiTH
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@12d34eb2a7bbdeee76a70fe0cf156411a7f44065 -
Trigger Event:
push
-
Statement type: