Acefone WebSocket frame serializer for Pipecat for hosting agents on telephony
Project description
Pipecat Acefone / Smartflo Telephony Serializer
Host your Pipecat voice agents on the Acefone and Smartflo (Tata Tele Business) bi-directional audio streaming stack.
AcefoneFrameSerializer converts between Pipecat frames and the Acefone/Smartflo
Media Streams WebSocket protocol, enabling real-time, two-way audio over a single
WebSocket connection so you can serve an agent on an Indian phone number.
Maintainer: Himanshu Gunwant
Installation
pip install pipecat-acefone
Or via uv, add it to your pyproject.toml:
[project]
name = "your-project"
version = "0.1.0"
dependencies = [
"pipecat-acefone",
"another-package"
]
uv sync
Prerequisites
- An Acefone or Smartflo (Tata Tele Business) account with a phone number.
- Bi-directional audio streaming enabled on that number, pointed at your WebSocket endpoint (see the protocol docs under Protocol).
- Python 3.11+.
Usage
Construct the serializer with AcefoneFrameSerializer.InputParams and pass it to
your Pipecat WebSocket transport:
from pipecat_acefone.serializer import AcefoneFrameSerializer, AcefoneMediaFormat
from pipecat.audio.vad.silero import SileroVADAnalyzer
from pipecat.transports.websocket.fastapi import (
FastAPIWebsocketTransport,
FastAPIWebsocketParams,
)
serializer = AcefoneFrameSerializer(
AcefoneFrameSerializer.InputParams(
# Required: the Media Stream SID for the call.
stream_sid=stream_id,
# Required only when auto_hang_up is enabled.
call_sid=call_id,
# Terminate the call via a WebSocket "end" event on EndFrame/CancelFrame.
auto_hang_up=True,
# Wire format: ULAW (default, 8kHz G.711 μ-law) or PCM (16-bit slin16).
media_format=AcefoneMediaFormat.ULAW,
acefone_sample_rate=8000,
)
)
transport = FastAPIWebsocketTransport(
websocket=websocket_client,
params=FastAPIWebsocketParams(
audio_out_enabled=True,
add_wav_header=True,
vad_audio_passthrough=True,
serializer=serializer,
audio_out_sample_rate=8000,
),
)
See bot.py for a complete working example including STT/LLM/TTS
services, event handlers, and transport setup.
Configuration
All configuration is passed through AcefoneFrameSerializer.InputParams:
| Parameter | Type | Default | Description |
|---|---|---|---|
media_format |
AcefoneMediaFormat |
ULAW |
Wire audio format. ULAW = 8kHz G.711 μ-law; PCM = 16-bit linear PCM (slin16). |
acefone_sample_rate |
int |
8000 |
Sample rate used by Acefone/Smartflo, in Hz. |
sample_rate |
int |
0 |
Pipeline input rate override. 0 takes the rate from the StartFrame during setup. |
stream_sid |
str |
required | Media Stream SID for the call. |
call_sid |
str | None |
None |
Associated Call SID. Required when auto_hang_up is enabled. |
auto_hang_up |
bool |
False |
Emit a WebSocket end event to terminate the call on the first EndFrame/CancelFrame. |
Regardless of the wire media_format, inbound audio is normalized to PCM
InputAudioRawFrame for the pipeline, and outbound audio is converted back to the
configured wire format.
Features
- Audio streaming —
mediaevents in both directions, with automatic μ-law ⇄ PCM conversion and resampling between the pipeline andacefone_sample_rate. - Configurable wire format — 8kHz μ-law (default) or 16-bit linear PCM.
- DTMF input — inbound
dtmfevents becomeInputDTMFFramekeypad entries. - Interruptions —
InterruptionFrameemits aclearevent to flush queued audio on the provider side. - Auto hang-up — when enabled, terminates the call over the same WebSocket via
an
endevent instead of a separate REST call.
Running the Example
-
Start ngrok to tunnel the local server:
ngrok http 7860
-
Point your Acefone/Smartflo number's bi-directional audio streaming at your ngrok WebSocket endpoint (e.g.
wss://foo.bar.ngrok-free.dev/ws). See the Protocol docs for the dashboard/API configuration. -
Install dependencies:
uv sync -
Set up your environment:
cp .env.example .env
-
Run the bot:
uv run bot.py --transport acefone --proxy your_ngrok_url
The bot creates a WebSocket that accepts connections from your Acefone/Smartflo number. Once it's running, call the number to interact with the agent.
Protocol
Reference docs for the wire protocol and events:
- Acefone: https://docs.acefone.in/docs/bi-directional-audio-streaming-integration-document
- Smartflo: https://docs.smartflo.tatatelebusiness.com/docs/bi-directional-audio-streaming-integration-document
Compatibility
- Tested with Pipecat v1.5.0
- Python 3.11+
License
BSD-2-Clause — see LICENSE.
Support
- Protocol docs: see Protocol above for message formats.
- Pipecat Discord: https://discord.gg/pipecat (
#community-integrations) - Issues: https://github.com/monster-anshu/pipecat-acefone/issues
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 pipecat_acefone-0.1.2.tar.gz.
File metadata
- Download URL: pipecat_acefone-0.1.2.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c7d7f4a263566a469926349d7bfce5b1e62e450806d0cd598ab8490dbffb499
|
|
| MD5 |
3267b1bd84e0e6ce6f2ac0f8fcbe3d47
|
|
| BLAKE2b-256 |
dd4dad59d23ea6c69997507269399a8cfb4c413b1b65e533a1b7c7d08e0d54b5
|
File details
Details for the file pipecat_acefone-0.1.2-py3-none-any.whl.
File metadata
- Download URL: pipecat_acefone-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95b0407dcb9540d548bdb2d320a7194b8ae5da6cad1dcec42f6a7adcbc0b3c84
|
|
| MD5 |
0f880cb6b41c2cba85e6cba1023be8bd
|
|
| BLAKE2b-256 |
5d474015cc611108127d30e3fe119d1bdc887489360f85ef19df651b166ea6fc
|