Python SDK for Whissle API.
Project description
Whissle API Python Package
whissle is a Python package that provides easy access to the Whissle API for Speech-to-Text (STT), Machine Translation, and Text Summarization functionalities, with both synchronous and asynchronous client support.
Features
- 🎙️ Speech-to-Text (STT) with multiple model support and customization options
- 🌍 Machine Translation across various languages
- 📝 Text Summarization using LLM models
- ⚡ Both synchronous and asynchronous clients
- 🔄 Automatic response parsing to Pydantic models
Installation
Install Whissle using pip:
pip install whissle
For local development:
pip install -e .
Authentication
Provide your authentication token in one of two ways:
- Direct initialization:
from whissle import WhissleClient
client = WhissleClient(auth_token="your_auth_token_here")
- Environment variable:
export WHISSLE_AUTH_TOKEN=your_auth_token_here
Client Options
Synchronous Client
Use the sync client for straightforward, sequential operations:
from whissle import WhissleClient
client = WhissleClient().sync_client
# List ASR models
models = client.list_asr_models()
# Speech to text
response = client.speech_to_text(
audio_file_path="audio.wav",
model_name="en-US-0.6b",
timestamps=True,
boosted_lm_words=["specific", "terms"],
boosted_lm_score=80
)
# Translation
translation = client.machine_translation(
text="Hello, world!",
source_language="en",
target_language="es"
)
# Summarization
summary = client.llm_text_summarizer(
content="Long text here...",
model_name="openai",
instruction="Provide a brief summary"
)
Asynchronous Client
Use the async client for concurrent operations and non-blocking I/O:
import asyncio
from whissle import WhissleClient
async def main():
client = WhissleClient().async_client
# List ASR models
models = await client.list_asr_models()
# Speech to text
response = await client.speech_to_text(
audio_file_path="audio.wav",
model_name="en-US-0.6b",
timestamps=True
)
# Translation
translation = await client.machine_translation(
text="Hello, world!",
source_language="en",
target_language="es"
)
# Summarization
summary = await client.llm_text_summarizer(
content="Long text here...",
model_name="openai",
instruction="Provide a brief summary"
)
asyncio.run(main())
API Methods
List ASR Models
models = client.list_asr_models() # or await client.list_asr_models()
Speech-to-Text
response = client.speech_to_text(
audio_file_path="path/to/audio.wav",
model_name="en-US-0.6b",
timestamps=False, # Optional: Include word timestamps
boosted_lm_words=["specific", "terms"], # Optional: Boost specific words
boosted_lm_score=80 # Optional: Boosting score
)
Machine Translation
translation = client.machine_translation(
text="Hello, world!",
source_language="en",
target_language="es"
)
Text Summarization
summary = client.llm_text_summarizer(
content="Your long text here...",
model_name="openai",
instruction="Provide a brief summary"
)
Configuration
WHISSLE_AUTH_TOKEN: Authentication tokenWHISSLE_SERVER_URL: Optional custom server URL (defaults to https://api.whissle.ai/v1)
Error Handling
The library provides consistent error handling for both sync and async clients:
from whissle import HttpError
try:
# Whissle API calls
except HttpError as e:
print(f"API Error: {e.status_code} - {e.message}")
Dependencies
- Python 3.8+
- httpx: For HTTP requests (both sync and async)
- pydantic: For response modeling
Type Hints
All methods include proper type hints for better IDE support:
ASRModel: ASR model informationSTTResponse: Speech-to-text responseMTResposne: Machine translation responseLLMSummarizerResponse: Text summarization response
Examples
For more detailed examples, check out the examples/ directory:
examples/sync/: Synchronous client examplesexamples/async/: Asynchronous client examples
Contributing
Contributions are welcome! Please submit pull requests or open issues on our GitHub repository.
Contact
For support or inquiries, contact: nsanda@whissle.ai
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 whissle-0.0.1.tar.gz.
File metadata
- Download URL: whissle-0.0.1.tar.gz
- Upload date:
- Size: 46.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ebcd7ac498e82e6a9f588c15ae2d214bdf90b823fd0c460dd777c3ca08229a5
|
|
| MD5 |
556f0d1c4fb5a774d7f43129c6f999b8
|
|
| BLAKE2b-256 |
c557e7b0d802337ae80811dc74840b9f2438f7ed0947d337cc54c6dd20791038
|
File details
Details for the file whissle-0.0.1-py3-none-any.whl.
File metadata
- Download URL: whissle-0.0.1-py3-none-any.whl
- Upload date:
- Size: 36.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3634d799a707f55641525475e243c5faa0b42e78c09fc6dd70ab5e9461dc7a95
|
|
| MD5 |
4c991cfd31426a7485e80645e49fc449
|
|
| BLAKE2b-256 |
237ce97360ffbbe87668d473c04d0be113ff522197f2eb188c9e1035306ca74e
|