|
| 1 | +# StepFun plugin for LiveKit Agents |
| 2 | + |
| 3 | +Support for [StepFun](https://platform.stepfun.ai/docs) speech recognition, |
| 4 | +speech synthesis, and OpenAI-compatible chat models. |
| 5 | + |
| 6 | +## Installation |
| 7 | + |
| 8 | +```bash |
| 9 | +pip install livekit-plugins-stepfun |
| 10 | +# Include the OpenAI-compatible chat client: |
| 11 | +pip install 'livekit-plugins-stepfun[llm]' |
| 12 | +``` |
| 13 | + |
| 14 | +## Configuration |
| 15 | + |
| 16 | +Set `STEPFUN_API_KEY`, or pass `api_key=` to the constructors. StepFun runs two |
| 17 | +regional clusters with separate endpoints and separate credentials: |
| 18 | + |
| 19 | +| Cluster | Endpoint | Value | |
| 20 | +| --- | --- | --- | |
| 21 | +| Global (default) | `api.stepfun.ai` | `"global"` | |
| 22 | +| Mainland China | `api.stepfun.com` | `"china"` | |
| 23 | + |
| 24 | +Select the cluster with `STEPFUN_CLUSTER` or `cluster=`. The two clusters use |
| 25 | +separate endpoints and separate credentials, so a key from one will not work on |
| 26 | +the other. |
| 27 | + |
| 28 | +- `stepfun.STT()` streams recognition with server endpointing. |
| 29 | + `recognize()` uses the batch route; `use_streaming=False` selects batch |
| 30 | + recognition for sessions and requires local VAD through `stt.StreamAdapter`. |
| 31 | + Streaming input is intended for paced conversational audio, not file uploads; |
| 32 | + use `recognize()` for recorded audio. At end of input, server-VAD streams send |
| 33 | + endpointing silence and then a best-effort `input_audio_buffer.commit` (the |
| 34 | + gateway currently ignores it with server VAD, but it will finalize the last |
| 35 | + segment once commits are forwarded), and keep receiving: while a turn is pending this waits up |
| 36 | + to `conn_options.timeout` and fails on expiry, otherwise it ends after a short |
| 37 | + quiet period. The API has no acknowledgement that trailing silence was |
| 38 | + processed, so completion is best-effort: it succeeds only after a final was |
| 39 | + delivered, and otherwise reports that completion cannot be confirmed once a |
| 40 | + bounded interval elapses. A turn first reported later than the quiet period is |
| 41 | + not recovered. `aclose()` cancels without waiting. |
| 42 | + Failures after consuming audio are non-retryable because a fresh session |
| 43 | + cannot recover that input. `aclose()` cancels the stream without draining it. |
| 44 | +- `stepfun.TTS()` supports streaming and one-shot synthesis. Discover voice IDs |
| 45 | + using `await tts.list_voices()`. One-shot synthesis streams PCM over SSE, so |
| 46 | + audio starts arriving before the whole request is synthesized; inputs longer |
| 47 | + than 1,000 characters are split into sequential requests and emitted as one |
| 48 | + audio segment. Each request has an idle-read timeout plus a total deadline |
| 49 | + that scales with its text length. |
| 50 | +- `stepfun.LLM()` uses the optional OpenAI plugin for chat and tool calling. |
| 51 | + |
| 52 | +Pass `language="zh"` for Chinese; the speech services default to English. |
| 53 | +Streaming recognition defaults to `stepaudio-2.5-asr-stream`, batch recognition |
| 54 | +to `stepaudio-3-asr-max`, synthesis to `stepaudio-3-tts`, and chat to |
| 55 | +`step-3.7-flash`. Custom model IDs are accepted. |
0 commit comments