Skip to main content

pipecat-duplexjev

Audio end-of-turn detection for Pipecat, powered by DuplexJev. It listens to how the user speaks, not only what they say, and tells your bot whether the user is finished, still talking, just backchanneling ("mm-hmm") or asking you to wait. The same request can also return emotion, laughter / breathing / coughs / sighs and barge-in at no extra cost.

  • Four turn states, not a yes/no. A backchannel or a "hold on" is not a reason to start talking.
  • Hears beyond the transcript. Every answer is read from the audio as one constrained token of a speech LLM. Nothing is decoded and no STT is needed for the decision.
  • More than turns, same forward pass. Ask for emotion, non-verbal sounds or your own multiple-choice questions. They come back in last_answers with the turn decision.
  • ~55 ms on the server for a turn decision with DuplexJev-4B-Para on one GPU.
  • Chinese and English.
  • On the CoDeTT turn-taking benchmark (English, zero-shot), DuplexJev-32B-Turn scores 70.0, against 51.4 for Smart Turn v3. See the paper and the project page.

Tested with pipecat-ai 1.12.0. Maintained by Adventists.ai (AI降临派).

Install

pip install pipecat-duplexjev

Use

Drop it in wherever Pipecat takes a turn analyzer (Pipecat >= 1.0):

from pipecat.processors.aggregators.llm_response_universal import LLMContextAggregatorPair, LLMUserAggregatorParams
from pipecat.turns.user_stop import TurnAnalyzerUserTurnStopStrategy
from pipecat.turns.user_turn_strategies import UserTurnStrategies
from pipecat_duplexjev import DuplexJevTurnAnalyzer

turn = DuplexJevTurnAnalyzer(
    url="http://localhost:8420",          # your own gateway; omit to use the free hosted trial API
    extra_questions=["emotion", "sound"],
    on_answers=lambda a: print({k: v["answer"] for k, v in a.items()}),
)

aggregators = LLMContextAggregatorPair(context, user_params=LLMUserAggregatorParams(
    vad_analyzer=SileroVADAnalyzer(),
    user_turn_strategies=UserTurnStrategies(stop=[TurnAnalyzerUserTurnStopStrategy(turn_analyzer=turn)]),
))

Give it the assistant's last message (new in 0.3.0). Turn-taking is clearly better when the model knows what the bot had just said (a question invites a short answer; "ok" after a question ends the turn). Put the tracker after your LLM service:

from pipecat_duplexjev import DuplexJevContextTracker

pipeline = Pipeline([transport.input(), stt, aggregators.user(), llm,
                     DuplexJevContextTracker(turn),       # tells the analyzer what the bot is saying
                     tts, transport.output(), aggregators.assistant()])

or call turn.set_assistant_said(text) yourself. It needs a gateway from duplexjev>=0.6. On LiveKit eot-bench (English, DuplexJev-32B-Para v1.2) this cuts false cut-offs at a 300 ms budget from 23.5% to 19.7%.

A complete snippet is in examples/wiring.py. examples/live_check.py feeds real clips through the analyzer, frame by frame, the way a transport does:

ex4.wav: COMPLETE   p(finished)=1.00  turn='finished, the assistant can reply'   emotion=neutral  server 59.6 ms
ex3.wav: INCOMPLETE p(finished)=0.11  turn='not finished, still talking'          emotion=sad      server 53.2 ms
ex5.wav: INCOMPLETE p(finished)=0.28  turn='hesitating or asking to wait'         emotion=angry    server 56.0 ms

The default URL is our free trial API. It is rate limited (30 requests per minute) and served from mainland China, so the network round trip from elsewhere can be over a second. For a live bot, serve the model next to your agent. DuplexJev-4B-Para needs about 10 GB of GPU memory; for the best turn-taking use DuplexJev-32B-Para (v1.2, one 80 GB GPU):

pip install "vllm[audio]>=0.29" duplexjev-vllm "duplexjev[server]>=0.6"
vllm serve adventists-ai/DuplexJev-4B-Para --max-model-len 4096 --port 8000 &
duplexjev gateway --vllm http://localhost:8000/v1 --port 8420

Then pass url="http://localhost:8420".

Options

argument default
url hosted trial API base URL of a duplexjev gateway
api_key None bearer key, if your gateway requires one
lang "en" "en" or "zh": wording of the questions (the model hears both languages either way)
threshold 0.5 probability of "finished" from which the turn is complete
extra_questions [] "emotion", "sound", "barge_in", or dicts {"id", "text", "options"}
on_answers None callback with every answer dict
timeout params.stop_secs HTTP timeout; on timeout Pipecat treats the turn as complete
params SmartTurnParams() Pipecat's usual stop_secs, pre_speech_ms, max_duration_secs

If the gateway can't be reached, the analyzer logs the error and reports "not finished", so Pipecat falls back to its silence timeout and the conversation never blocks.

License

The plugin code is BSD-2-Clause. DuplexJev model weights are CC BY-NC 4.0 (non-commercial); see the model cards. For commercial use, contact jiejin@adventists.ai.

Metadata

Release files for pipecat-duplexjev 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pipecat-duplexjev 0.3.0
File Size Uploaded
pipecat_duplexjev-0.3.0.tar.gz 9.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pipecat-duplexjev 0.3.0
File Interpreter ABI Platform
pipecat_duplexjev-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.0 kB

Release files / pipecat_duplexjev-0.3.0.tar.gz

Download URL pipecat_duplexjev-0.3.0.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
5a0d51c7b438aee24b8eb55fd786885acb78abc2b3493e7f2fd1fd3d35e06c53
BLAKE2b-256 checksum
How to use checksums
c317bfafb4ab5df9f656b8804993d8b4e131f325aa18c917b8c61a18425b0ebd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

Release files / pipecat_duplexjev-0.3.0-py3-none-any.whl

Download URL pipecat_duplexjev-0.3.0-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d02c4259b3ec6e76383aae5890fb23fab0d84486b4881551d8cea5e70dbadc4d
BLAKE2b-256 checksum
How to use checksums
73d08e21d27645c6527c9594a94482973a6e3f18068f82fcbad8bc96a0a0a56b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

Release history Release notifications | RSS feed

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page