jptaylor commited on
Commit
e09dd34
·
verified ·
1 Parent(s): 084a090

Add streaming-turn-v0.7 (experimental): v0.6 plus bc_cue, a cue for the bot to backchannel mid-turn

Browse files
README.md CHANGED
@@ -14,17 +14,18 @@ tags:
14
 
15
  # Streaming Turn
16
 
17
- Streaming, audio-only turn-taking model for [Pipecat](https://github.com/pipecat-ai/pipecat) voice agents. On every 40 ms of user audio it gives the probability that the user's turn is over, and whether speech over the bot is a backchannel or a floor-take. v0.6 adds a cue, while the user is still speaking, that their turn is about to end. It never sees a transcript.
18
 
19
- - 4.0M parameters (4.2M for v0.6): log-mel, causal conv encoder, GRU. 16 kHz mono in, 25 frames a second out.
20
  - 0.37 ms per 40 ms chunk on one Apple M-series core (ONNX Runtime).
21
- - English only. Experimental: little live testing, v0.5 has not yet been compared with v0.4 live, and nobody has yet heard a bot act on v0.6's new output.
22
 
23
  ## Versions
24
 
25
  | Folder | End the turn when |
26
  |---|---|
27
- | `streaming-turn-v0.6` (latest, experimental) | as v0.5: `eot` ≥ 0.6, or `eot_late` ≥ 0.4 |
 
28
  | `streaming-turn-v0.5` | `eot` ≥ 0.6, or `eot_late` ≥ 0.4 |
29
  | `streaming-turn-v0.4` | `eot` ≥ 0.5, or `eot_late` ≥ 0.4 |
30
  | `streaming-turn-v0.2` | `eot` ≥ 0.5, or 0.8 s after the last sound if `eot` reached 0.3 |
@@ -33,7 +34,9 @@ v0.4 adds `eot_late`, a second end-of-turn output for a user who has gone quiet.
33
 
34
  v0.6 is v0.5 with one more output, `eot_soon`: while the user is still speaking, the probability that their turn ends within 240 ms and within 480 ms. An app can use it to start a lead-in ("ok, so...") or to get a reply ready before the stop. It comes from a small head (a GRU of 96 units) trained on v0.5's frozen network, so every other output is v0.5's, bit for bit, and an agent ends turns exactly as it does on v0.5. It has one more state tensor to feed back, `cue_state`.
35
 
36
- Each folder holds `streaming-turn-fp32.onnx` (the streaming model), `model.json` (tensor names, chunk size, class lists) and a `.pt` file (PyTorch config and weights).
 
 
37
 
38
  ## Use with Pipecat
39
 
@@ -55,7 +58,7 @@ from pipecat.turns.user_turn_strategies import UserTurnStrategies
55
 
56
  from agent.turn_analyzers import StreamingTurnAnalyzer, StreamingTurnParams
57
 
58
- VERSION = "streaming-turn-v0.5" # "streaming-turn-v0.6" takes the same settings and adds eot_soon
59
  repo = snapshot_download("jptaylor/streaming-turn", allow_patterns=f"{VERSION}/*")
60
  analyzer = StreamingTurnAnalyzer(
61
  Path(repo) / VERSION,
@@ -90,13 +93,14 @@ One frame per 40 ms chunk.
90
  | Output | |
91
  |---|---|
92
  | `eot` | probability that the user's turn is over |
93
- | `eot_late` | the same, for a user who has gone quiet (v0.4 and v0.5) |
94
  | `intent` | continuer, assessment, negative, floor_take, non_speech. Backchannel = continuer + assessment; floor-take = negative + floor_take |
95
  | `leadin` | none, acknowledgement, hesitation, marker, reaction (barely beats guessing) |
96
- | `eot_soon` | v0.6 only: probability that the user's turn ends within 240 ms and within 480 ms. Read it while the user is speaking and the bot is silent |
97
- | `vad`, `vap` | auxiliary: voice activity now, and both speakers' activity over the next 2 s |
 
98
 
99
- Inputs: `chunk` (640 samples, float32) and `bot_state` (is the bot speaking, and for how long), plus the streaming state tensors named in `model.json` (v0.6 has one more, `cue_state`, and its state outputs come after `eot_soon`: read them by name).
100
 
101
  ## Results
102
 
@@ -129,10 +133,30 @@ Experimental. The cue is given when the 240 ms output of `eot_soon` reaches 0.30
129
  - It is a cleaner early signal than `eot` at 0.3, not an early one: about a quarter of a second ahead of a VAD's report of the stop.
130
  - When two people talk it is wrong more often than right. In six recorded sessions of a person talking to a bot, 13 of its 14 cues came before a turn end, covering 13 of 28 turn ends. That is the only evidence on bot sessions, and it is small.
131
  - It adds no accuracy over an output v0.5 already has: turn end against pause before the stop, AUC 0.81, where the best `vap` bin scores 0.82. What it adds is one calibrated number.
132
- - A second cue, for when the bot should backchannel, was trained and left out: it scored no better than `vap`.
133
 
134
  The model card in the code repository has the full results: [models/streaming-turn-v0.6](https://github.com/jptaylor/streaming-turn/tree/main/models/streaming-turn-v0.6).
135
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  ## Limitations
137
 
138
  - The held-out conversations are from a corpus the model trained on (different conversations).
@@ -140,9 +164,10 @@ The model card in the code repository has the full results: [models/streaming-tu
140
  - v0.5 is one of three runs, chosen on held-out data. A second seed of the same recipe scored about two points lower on the measure that chose it.
141
  - A finished sentence it takes for an unfinished one waits for the 3 s timeout.
142
  - v0.6's `eot_soon` is experimental: nobody has heard a bot act on it, it gives more false starts than hits when two people talk, and on Open Yap it gives a false start on more pauses (4.3%) than v0.5 cuts in on in the same replay (at most 3.7%).
 
143
  - Half of the end-of-turn targets on Smart Turn clips are Smart Turn v3.2's own predictions, so it is not independent of v3.2.
144
  - Trained on human-to-human conversation and single-speaker clips, with simulated echo, and for v0.5 on synthetic speech. Phone codecs are untested.
145
 
146
  ## Training data
147
 
148
- [Open Yap 1K](https://theagenticdatacompany.com/open-yap-1k) v1.0, [otoSpeech-full-duplex-280h](https://huggingface.co/datasets/otoearth/otoSpeech-full-duplex-280h) (CC BY 4.0), the English part of the [Smart Turn v3.2 training data](https://huggingface.co/datasets/pipecat-ai/smart-turn-data-v3.2-train) (CC BY 4.0), and 600 synthetic hard negatives. v0.5 adds 1,355 synthetic agent sessions, with the user's speech from ElevenLabs v4 and the bot's from Deepgram Aura-2. A frozen [Whisper base.en](https://huggingface.co/openai/whisper-base.en) encoder was the distillation target, and Smart Turn v3.2 gave soft end-of-turn labels. v0.6's head was trained on the same data with v0.5's weights frozen: no new audio. No training data is included here.
 
14
 
15
  # Streaming Turn
16
 
17
+ Streaming, audio-only turn-taking model for [Pipecat](https://github.com/pipecat-ai/pipecat) voice agents. On every 40 ms of user audio it gives the probability that the user's turn is over, and whether speech over the bot is a backchannel or a floor-take. v0.6 adds a cue, while the user is still speaking, that their turn is about to end, and v0.7 a cue for the bot to backchannel while the user is mid-turn. It never sees a transcript.
18
 
19
+ - 4.0M parameters (4.2M for v0.6 and v0.7): log-mel, causal conv encoder, GRU. 16 kHz mono in, 25 frames a second out.
20
  - 0.37 ms per 40 ms chunk on one Apple M-series core (ONNX Runtime).
21
+ - English only. Experimental: little live testing, v0.5 has not yet been compared with v0.4 live, and nobody has yet heard a bot act on the outputs v0.6 and v0.7 add.
22
 
23
  ## Versions
24
 
25
  | Folder | End the turn when |
26
  |---|---|
27
+ | `streaming-turn-v0.7` (latest, experimental) | as v0.5: `eot` ≥ 0.6, or `eot_late` ≥ 0.4 |
28
+ | `streaming-turn-v0.6` (experimental) | as v0.5: `eot` ≥ 0.6, or `eot_late` ≥ 0.4 |
29
  | `streaming-turn-v0.5` | `eot` ≥ 0.6, or `eot_late` ≥ 0.4 |
30
  | `streaming-turn-v0.4` | `eot` ≥ 0.5, or `eot_late` ≥ 0.4 |
31
  | `streaming-turn-v0.2` | `eot` ≥ 0.5, or 0.8 s after the last sound if `eot` reached 0.3 |
 
34
 
35
  v0.6 is v0.5 with one more output, `eot_soon`: while the user is still speaking, the probability that their turn ends within 240 ms and within 480 ms. An app can use it to start a lead-in ("ok, so...") or to get a reply ready before the stop. It comes from a small head (a GRU of 96 units) trained on v0.5's frozen network, so every other output is v0.5's, bit for bit, and an agent ends turns exactly as it does on v0.5. It has one more state tensor to feed back, `cue_state`.
36
 
37
+ v0.7 is v0.6 with one more output, `bc_cue`: while the user is speaking, the probability that a listener would start a backchannel ("mm-hmm", "right") within half a second. Read through a check that the user is mid-turn and a budget of a few a minute, it says when a bot could backchannel. It comes from the same head as `eot_soon`, with no new training, so every other output is v0.6's, bit for bit, and an agent that ignores it behaves exactly as it does on v0.6. The model gives the moment: it does not make the audio or choose the words.
38
+
39
+ Each folder holds `streaming-turn-fp32.onnx` (the streaming model), `model.json` (tensor names, chunk size, class lists) and a `.pt` file (PyTorch config and weights). v0.7's `.pt` file is the same file as v0.6's, which already held the new output's weights.
40
 
41
  ## Use with Pipecat
42
 
 
58
 
59
  from agent.turn_analyzers import StreamingTurnAnalyzer, StreamingTurnParams
60
 
61
+ VERSION = "streaming-turn-v0.5" # "-v0.6" and "-v0.7" take the same settings and add the cue outputs
62
  repo = snapshot_download("jptaylor/streaming-turn", allow_patterns=f"{VERSION}/*")
63
  analyzer = StreamingTurnAnalyzer(
64
  Path(repo) / VERSION,
 
93
  | Output | |
94
  |---|---|
95
  | `eot` | probability that the user's turn is over |
96
+ | `eot_late` | the same, for a user who has gone quiet (v0.4 and later) |
97
  | `intent` | continuer, assessment, negative, floor_take, non_speech. Backchannel = continuer + assessment; floor-take = negative + floor_take |
98
  | `leadin` | none, acknowledgement, hesitation, marker, reaction (barely beats guessing) |
99
+ | `bc_cue` | v0.7 only: probability that a listener would start a backchannel within half a second. Read it while the user holds the floor and the bot is silent, and with the mid-turn check below |
100
+ | `eot_soon` | v0.6 and v0.7: probability that the user's turn ends within 240 ms and within 480 ms. Read it while the user is speaking and the bot is silent |
101
+ | `vad`, `vap` | auxiliary: voice activity now, and both speakers' activity over the next 2 s. The third value of `vap`, the user speaking 0.6 to 1.2 s from now, is v0.7's mid-turn check |
102
 
103
+ Inputs: `chunk` (640 samples, float32) and `bot_state` (is the bot speaking, and for how long), plus the streaming state tensors named in `model.json`. v0.6 and v0.7 have one more, `cue_state`. In v0.7 `bc_cue` comes before `eot_soon`, so `eot_soon` and the state outputs sit one place later than in v0.6: read outputs by name.
104
 
105
  ## Results
106
 
 
133
  - It is a cleaner early signal than `eot` at 0.3, not an early one: about a quarter of a second ahead of a VAD's report of the stop.
134
  - When two people talk it is wrong more often than right. In six recorded sessions of a person talking to a bot, 13 of its 14 cues came before a turn end, covering 13 of 28 turn ends. That is the only evidence on bot sessions, and it is small.
135
  - It adds no accuracy over an output v0.5 already has: turn end against pause before the stop, AUC 0.81, where the best `vap` bin scores 0.82. What it adds is one calibrated number.
136
+ - A second cue, for when the bot should backchannel, was trained and left out of v0.6: it scored no better than `vap`. v0.7 has it, with the check that makes it usable.
137
 
138
  The model card in the code repository has the full results: [models/streaming-turn-v0.6](https://github.com/jptaylor/streaming-turn/tree/main/models/streaming-turn-v0.6).
139
 
140
+ ### v0.7's cue for the bot to backchannel
141
+
142
+ Experimental, and nobody has heard it: nothing here plays a backchannel. The cue is given when `bc_cue` reaches 0.45 for two frames and the model is at least 92% sure the user is still speaking a second from now (the third value of `vap`), no faster than four a minute and never more than two close together. That is `sturn.cues.CueTracker` in the code repository, with `CueParams(bc_threshold=0.45, bc_mid_turn=0.92, bc_max_per_minute=4)`. The setting was chosen on half of the held-out conversations. The other half was read three times, because two faults were found in the per-minute budget after a read; the thresholds did not change. The last read:
143
+
144
+ | Held-out conversations | Open Yap | otoSpeech |
145
+ |---|---|---|
146
+ | What real listeners did: backchannels a minute of the user's floor / share at a turn end | 2.58 / 0.9% | 1.84 / 2.5% |
147
+ | Cues a minute of the user's floor | 2.45 | 1.99 |
148
+ | Cues that land as the turn ends or after it | 0.6% (16 of 2,745) | 0.9% (5 of 587) |
149
+ | A real listener's backchannel within half a second of the cue / times random placement | 12.4% / 9.7 | 9.7% / 7.7 |
150
+ | `bc_cue` at 0.5 with no check: cues a minute / share at a turn end / a listener within half a second | 3.52 / 5.8% / 11.6% | 2.44 / 9.3% / 8.5% |
151
+
152
+ - By itself the cue is not usable: 6% to 9% of its cues land as the user's turn ends, where a reply is due and not an "mm-hmm". The mid-turn check removes them, at about the rate real listeners backchannel.
153
+ - It adds no accuracy over `vap`: 1.02 times its average precision. What v0.7 adds is the output and the rule for reading it.
154
+ - The check keeps cues away from phrase ends too, where a backchannel sounds most natural. Most cues fall while the user is speaking: 72% on Open Yap and 89% on otoSpeech.
155
+ - It needs a long turn. In six recorded sessions of a person talking to a bot it never fires: no stretch of the user's speech there is longer than 4.2 s.
156
+ - A backchannel the bot plays is not bot speech to the model: do not report it through `bot_state`.
157
+
158
+ The model card in the code repository has the full results: [models/streaming-turn-v0.7](https://github.com/jptaylor/streaming-turn/tree/main/models/streaming-turn-v0.7).
159
+
160
  ## Limitations
161
 
162
  - The held-out conversations are from a corpus the model trained on (different conversations).
 
164
  - v0.5 is one of three runs, chosen on held-out data. A second seed of the same recipe scored about two points lower on the measure that chose it.
165
  - A finished sentence it takes for an unfinished one waits for the 3 s timeout.
166
  - v0.6's `eot_soon` is experimental: nobody has heard a bot act on it, it gives more false starts than hits when two people talk, and on Open Yap it gives a false start on more pauses (4.3%) than v0.5 cuts in on in the same replay (at most 3.7%).
167
+ - v0.7's `bc_cue` is experimental: nobody has heard a bot backchannel on it, a real listener's backchannel is near about one cue in nine, and in short question-and-answer turns it does not fire. The bot's own "mm-hmm" in a pause can move the model (planted at -20 dB, it turned 2 of 53 pauses into cut-ins on v0.5): play it through echo cancellation, or only while the user is speaking.
168
  - Half of the end-of-turn targets on Smart Turn clips are Smart Turn v3.2's own predictions, so it is not independent of v3.2.
169
  - Trained on human-to-human conversation and single-speaker clips, with simulated echo, and for v0.5 on synthetic speech. Phone codecs are untested.
170
 
171
  ## Training data
172
 
173
+ [Open Yap 1K](https://theagenticdatacompany.com/open-yap-1k) v1.0, [otoSpeech-full-duplex-280h](https://huggingface.co/datasets/otoearth/otoSpeech-full-duplex-280h) (CC BY 4.0), the English part of the [Smart Turn v3.2 training data](https://huggingface.co/datasets/pipecat-ai/smart-turn-data-v3.2-train) (CC BY 4.0), and 600 synthetic hard negatives. v0.5 adds 1,355 synthetic agent sessions, with the user's speech from ElevenLabs v4 and the bot's from Deepgram Aura-2. A frozen [Whisper base.en](https://huggingface.co/openai/whisper-base.en) encoder was the distillation target, and Smart Turn v3.2 gave soft end-of-turn labels. v0.6's head was trained on the same data with v0.5's weights frozen: no new audio. v0.7 has no new training: `bc_cue` is an output of v0.6's head, learned from the moments the other speaker in a real conversation backchannelled. No training data is included here.
streaming-turn-v0.7/model.json ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "chunk_samples": 640,
3
+ "frames_per_chunk": 1,
4
+ "frame_secs": 0.04,
5
+ "outputs": [
6
+ "eot",
7
+ "intent",
8
+ "leadin",
9
+ "vad",
10
+ "vap",
11
+ "eot_late",
12
+ "bc_cue",
13
+ "eot_soon"
14
+ ],
15
+ "state_names": [
16
+ "audio_cache",
17
+ "stem1_cache",
18
+ "stem2_cache",
19
+ "block0_cache",
20
+ "block1_cache",
21
+ "block2_cache",
22
+ "block3_cache",
23
+ "block4_cache",
24
+ "block5_cache",
25
+ "gru_state",
26
+ "cue_state"
27
+ ],
28
+ "intent_classes": [
29
+ "continuer",
30
+ "assessment",
31
+ "negative",
32
+ "floor_take",
33
+ "non_speech"
34
+ ],
35
+ "leadin_classes": [
36
+ "none",
37
+ "acknowledgement",
38
+ "hesitation",
39
+ "marker",
40
+ "reaction"
41
+ ],
42
+ "config": {
43
+ "features": {
44
+ "sample_rate": 16000,
45
+ "n_fft": 512,
46
+ "win_length": 400,
47
+ "hop_length": 160,
48
+ "n_mels": 80,
49
+ "f_min": 20.0,
50
+ "f_max": 7600.0,
51
+ "log_eps": 1e-06
52
+ },
53
+ "d_model": 256,
54
+ "stem_kernel": 5,
55
+ "stem_stride": 4,
56
+ "enc_kernel": 5,
57
+ "enc_dilations": [
58
+ 1,
59
+ 2,
60
+ 4,
61
+ 8,
62
+ 1,
63
+ 2
64
+ ],
65
+ "gru_hidden": 448,
66
+ "gru_layers": 2,
67
+ "bot_state_dim": 8,
68
+ "n_intent": 5,
69
+ "n_vap_bins": 8,
70
+ "dropout": 0.2,
71
+ "stem_mid": 128,
72
+ "n_leadin": 5,
73
+ "teacher_dim": 512,
74
+ "sent_head": false,
75
+ "enc_norm": true,
76
+ "late_head": true,
77
+ "late_detach": false,
78
+ "cue_head": "gru",
79
+ "cue_hidden": 96,
80
+ "cue_input": "trunk+encoder"
81
+ },
82
+ "eot_soon_secs": [
83
+ 0.24,
84
+ 0.48
85
+ ],
86
+ "base_model": "streaming-turn-v0.5"
87
+ }
streaming-turn-v0.7/streaming-turn-fp32.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:821140348c2f1f69e8ae06090beab53e22d1d6363645746e37a3863feb66bf83
3
+ size 17800276
streaming-turn-v0.7/streaming-turn-v0.7.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9f3ce4519ac4f22d3941173c224d9a49aef165c230efda8448322dd521fc9b0a
3
+ size 18716492