To use this API, you need to establish a WebSocket connection and send audio data in real-time. The server processes the audio data and returns results based on the configured models and settings.
- A WebSocket client library (e.g.,
websocketsfor Python,wsfor Node.js). - Valid API credentials.
Currently the API is in alpha testing phase and credentials will be assigned per request basis.
For more information please contact support at support@althea.health
Upon connection, send an initial setup packet containing the session configuration and API credentials.
{"api_key": "your_api_key","api_secret": "your_api_secret","model": {"provider": "althea","model_name": "General_large","language": "en"},"audio_format": {"frame_rate": 16000,"sample_width": 2,"number_of_channels": 1},"setup": {"transcription": true,"tag": true,"intermediate": false,"turn_yield": true,"vad": true}}
To establish a WebSocket connection, use the following URL format:
ws://<host>:<port>
Replace <host> and <port> with the values provided by the API service.
After establishing the connection and sending the initial setup packet, you can start sending audio data in chunks. The audio data should be in the format specified in the initial setup packet.\
Detects voice activity in the audio stream.
Send audio data in chunks.
{"type": "vad","timestamp": "2023-10-01T12:00:00Z","status": "success","data": [{"start": 0.0,"end": 1.0}]}
Tags the audio with voice labels.
Send audio data in chunks.
{"type": "voice_tag","timestamp": "2023-10-01T12:00:00Z","delay": 0.5,"status": "success","data": {"voice_tag": "speech","score": 0.95}}
Transcribes the audio data.
Send audio data in chunks.
{"type": "transcription","timestamp": "2023-10-01T12:00:00Z","delay": 1.0,"status": "success","data": {"transcription": "Hello, how can I help you?"}}
Predicts whether to yield the turn in a conversation.
Send audio data in chunks.
{"type": "turn_yield","timestamp": "2023-10-01T12:00:00Z","delay": 1.5,"status": "success","data": {"turn_yield": true,"score": 0.85}}
If an error occurs, the server will send an error message with details.
{"error": "Invalid API credentials"}
import asyncioimport websocketsimport jsonasync def main():uri = "ws://localhost:8000"async with websockets.connect(uri) as websocket:setup_packet = {"api_key": "your_api_key","api_secret": "your_api_secret","model": {"provider": "althea","model_name": "General_large","language": "en"},"audio_format": {"frame_rate": 16000,"sample_width": 2,"number_of_channels": 1},"setup": {"transcription": True,"tag": True,"intermediate": False,"turn_yield": True,"vad": True}}await websocket.send(json.dumps(setup_packet))while True:message = await websocket.recv()print(f"Received: {message}")asyncio.run(main())
const WebSocket = require('ws');const ws = new WebSocket('ws://localhost:8000');ws.on('open', function open() {const setupPacket = {api_key: 'your_api_key',api_secret: 'your_api_secret',model: {provider: 'althea',model_name: 'General_large',language: 'en',},audio_format: {frame_rate: 16000,sample_width: 2,number_of_channels: 1,},setup: {transcription: true,tag: true,intermediate: false,turn_yield: true,vad: true,},};ws.send(JSON.stringify(setupPacket));});ws.on('message', function incoming(data) {console.log(`Received: ${data}`);});
This example demonstrates how to establish a WebSocket connection, send the initial setup packet, and receive responses from the server.
This API provides robust real-time voice processing capabilities, including transcription, voice tagging, and turn-yield prediction. By following the configuration and usage guidelines, you can integrate these features into your applications seamlessly. For any further questions or support, please refer to the official documentation or contact our support team.