mavleo96 Claude Opus 5.5 commited on
Commit
0dd0f72
·
1 Parent(s): 4ed7d22

One GENERATE.md, Seamless cap 2, per-source outputs

Browse files

- GENERATE.md (repo root) replaces the per-source docs: dataset plan (source
amounts per split, expected rows, basis), output format, shared processing,
SpokenWOZ and Seamless details
- Seamless: at most 2 incomplete points per turn (seeded random), all splits
- shard numbers continue across sources within a split; dropped/, stats/,
report/ and temp parts are per source; reports filter on data_source

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

GENERATE.md ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Generating the end-of-turn (EoT) dataset
2
+
3
+ Every VAD `speech_stop` of a speaker in a two-person conversation is one example: that speaker's audio from the start of
4
+ their current turn up to the moment the stop fires, labelled **`complete`** (the other person takes the floor next) or
5
+ **`incomplete`** (the speaker pauses and goes on). Sources: **SpokenWOZ** (phone calls) and **Seamless Interaction,
6
+ naturalistic** (in-person conversations).
7
+
8
+ Plan agreed 2026-10-24. Numbers marked **est.** are scaled from sample builds (see "Basis"); replace them with actuals
9
+ after the full build.
10
+
11
+ ---
12
+
13
+ ## 1. Quick commands
14
+
15
+ ```bash
16
+ source /venv/turn-data/bin/activate
17
+ pytest tests
18
+
19
+ # --- SpokenWOZ ---
20
+ python -m scripts.spokenwoz.download_text # once: data.json files -> tmp/spokenwoz/text/
21
+ # train first: validation/test reuse its shift. --limit takes the first N dialogues by id (61% of each split)
22
+ python -m scripts.spokenwoz.build --split train --vad-sr 16000 --out . --limit 2560 --correct-offset --workers 48
23
+ python -m scripts.spokenwoz.build --split validation --vad-sr 16000 --out . --limit 305 --workers 48
24
+ python -m scripts.spokenwoz.build --split test --vad-sr 16000 --out . --limit 610 --workers 48
25
+ for s in train validation test; do python -m scripts.spokenwoz.report --root . --split $s; done
26
+
27
+ # --- Seamless (naturalistic) ---
28
+ python -m scripts.seamless.download --split train --batches $(seq -f %04g 0 24) # audio + transcripts only, no video
29
+ python -m scripts.seamless.download --split validation
30
+ python -m scripts.seamless.download --split test
31
+ for s in train validation test; do
32
+ python -m scripts.seamless.build --split $s --vad-sr 16000 --out . --workers 48
33
+ python -m scripts.seamless.report --root . --split $s
34
+ done
35
+
36
+ # --- small sample for review (any source) ---
37
+ python -m scripts.spokenwoz.build --split train --vad-sr 16000 --out runs/sample --limit 20 --correct-offset
38
+ python -m scripts.seamless.build --split validation --vad-sr 16000 --out runs/sample --limit 50
39
+ ```
40
+
41
+ - **Order matters: SpokenWOZ first, then Seamless.** Shard numbers continue across sources within a split
42
+ (SpokenWOZ `train-00000…`, Seamless picks up at the next number).
43
+ - Each build processes the whole split from scratch (no resume); per-item files in `_parts_{source}_{split}/` are
44
+ deleted after the merge.
45
+ - To rebuild one source of a split: delete that split's shards (`data/{split}-*.parquet`) and rebuild both sources in order.
46
+
47
+ ---
48
+
49
+ ## 2. Dataset plan
50
+
51
+ Goal: **~300k train rows, about half phone (SpokenWOZ) and half in-person (Seamless), labels ~50/50**, with validation
52
+ and test built the same way.
53
+
54
+ ### How much of each source
55
+
56
+ | source | split | taken | of available | selection |
57
+ |---|---|---|---|---|
58
+ | SpokenWOZ | train | **2,560 dialogues** | 4,197 (61%) | first 2,560 by id (`--limit 2560`) |
59
+ | SpokenWOZ | validation | **305 dialogues** | 500 official dev list (61%) | first 305 by id (`--limit 305`) |
60
+ | SpokenWOZ | test | **610 dialogues** | 1,000 (61%) | first 610 by id (`--limit 610`) |
61
+ | Seamless naturalistic | train | **6,185 conversations** | 45,239 (14%) | train batches **0000–0024** (1,079 tars, 681 people) |
62
+ | Seamless naturalistic | validation | **748 conversations** | all of `dev` (batches 0–2, 190 tars) | all |
63
+ | Seamless naturalistic | test | **823 conversations** | all of `test` (batches 0–3, 270 tars) | all |
64
+
65
+ - No overlap between splits: SpokenWOZ uses its official splits; Seamless splits have disjoint people (checked on `filelist.csv`).
66
+ - SpokenWOZ: 3 calls with swapped-looking channels are always skipped (MUL2348, SNG1001, SNG0605).
67
+ - SpokenWOZ ids sort `MUL…` before `SNG…`, so the first-N subsets are all multi-domain calls. Accepted: the domain
68
+ mix doesn't matter for end-of-turn detection.
69
+ - Seamless `improvised` (actor-led) is not used.
70
+
71
+ ### Expected rows (est.)
72
+
73
+ | split | SpokenWOZ (complete / incomplete) | Seamless (complete / incomplete) | **total** | complete share | size |
74
+ |---|---|---|---|---|---|
75
+ | train | ~152k (89k / 62k) | ~150k (60k / 90k) | **~302k** | ~49% | ~20.5 GB |
76
+ | validation | ~18k (11k / 7k) | ~18k (7k / 11k) | **~36k** | ~49% | ~2.5 GB |
77
+ | test | ~36k (21k / 15k) | ~20k (8k / 12k) | **~56k** | ~52% | ~3.6 GB |
78
+ | **total** | ~206k | ~188k | **~394k** | | **~27 GB** |
79
+
80
+ Test is ~64/36 SpokenWOZ/Seamless because SpokenWOZ's official test split is twice its validation split.
81
+
82
+ ### Basis for the estimates
83
+
84
+ | | SpokenWOZ | Seamless |
85
+ |---|---|---|
86
+ | measured on | all 500 validation calls (16 kHz VAD, 25 dB gate) | dev batch 0 (249 conversations, 13.9 h, cap 2) |
87
+ | rows per dialogue / conversation | 59.2 | 24.3 |
88
+ | complete share | 58.9% | 39.9% |
89
+ | size per row (16 kHz FLAC) | 51 KB | 85 KB (longer clips) |
90
+ | per person (Seamless) | | 4.9 complete, 7.3 incomplete per conversation |
91
+
92
+ Rows per conversation may differ ±20% on other batches; add or drop Seamless train batches to hit ~150k.
93
+
94
+ ### Cost
95
+
96
+ - Seamless: ~25 train batches + dev + test ≈ **400 GB of network** (48 kHz audio + transcripts only, no video),
97
+ ~30 GB raw 16 kHz FLAC in `tmp/seamless/raw/`.
98
+ - SpokenWOZ: train/validation audio already in the HF cache (~45 GB prepared); test audio ~2 GB on first build.
99
+
100
+ ---
101
+
102
+ ## 3. Output
103
+
104
+ One schema for every source (`scripts/utils.py` `FEATURES`), audio fixed at **16 kHz**:
105
+
106
+ | column | |
107
+ |---|---|
108
+ | `id` | `{source}_{conversation}_{channel}_{k:03d}`, e.g. `spokenwoz_MUL0003_0_007`, `seamless_V00_S0080_I00000135_0_002`; k counts all VAD stops on that channel, so ids stay stable when label rules change |
109
+ | `audio` | FLAC, 16 kHz mono |
110
+ | `data_source` | `spokenwoz` / `seamless` |
111
+ | `original_data_id` | SpokenWOZ dialogue (`MUL0003`) / Seamless conversation `V_S_I` |
112
+ | `channel` | SpokenWOZ: 0 = user, 1 = system. Seamless: 0 / 1 = the two participants sorted by `P` id |
113
+ | `timestamp_start`, `timestamp_end` | clip span in the conversation (s); end = the moment the VAD stop fires |
114
+ | `label` | `incomplete` / `complete` (ClassLabel) |
115
+ | `meta` | JSON string with source-specific extras (see §6, §7) |
116
+
117
+ ```
118
+ data/{split}-XXXXX.parquet the dataset; numbering continues across sources (rows carry data_source)
119
+ dropped/{source}/{split}.parquet dropped points / turns with the reason (no audio)
120
+ stats/{source}/{split}_*.parquet, _meta.json per-conversation info, exact settings used (SpokenWOZ train_meta = shift)
121
+ report/{source}/{split}/ data_report.md, PNGs, listen/ (review WAVs with 2 s after the stop: never training)
122
+ ```
123
+
124
+ The repo README's `configs:` block maps `data/{split}-*.parquet` to the splits, so
125
+ `load_dataset("mavleo96/turn-detection-data")` loads only the shards. A local build without that README:
126
+ `load_dataset("parquet", data_files={"train": "runs/sample/data/train-*.parquet"})`.
127
+
128
+ ---
129
+
130
+ ## 4. Shared processing (every source)
131
+
132
+ Code: `scripts/vad.py` (VAD) and `scripts/utils.py` (schema, clip bounds, turn start, writing/merging).
133
+
134
+ 1. **Audio** at 16 kHz mono per speaker.
135
+ 2. **VAD** (`scripts/vad.py`, **must match the demo/server**): Silero at 16 kHz in 32 ms frames, run causally.
136
+ - speech starts after 200 ms ≥ 0.7, stops after 200 ms < 0.55 → **a stop fires 224 ms (7 frames) after speech end**
137
+ - loudness gate: a frame > **25 dB** below the speaker's own running level (p90 of confident frames, past 60 s) is silence
138
+ 3. **Clip**: the speaker's own audio from turn start − 0.3 s to exactly the stop's fire time (nothing after: it would leak
139
+ the label), **at most the last 30 s**. The turn start walks back over the speaker's segments and resets when the other
140
+ has a real (≥ 1 s) segment, the other takes the floor in the annotations, or the previous stop was complete.
141
+ 4. Live serving must keep ≥ 0.6 s of audio before a declared speech start to reproduce the 0.3 s pre-roll.
142
+
143
+ Why these VAD settings: compared on all 500 SpokenWOZ validation calls (8 / 16 kHz × gate 15 / 25 / off),
144
+ 16 kHz + 25 dB keeps ~10% more points, misses 71% fewer short turns ("yes", "okay") and drops 78% fewer
145
+ quiet-ending turns than 8 kHz + 15 dB; bleed stays ~0.2%.
146
+
147
+ ---
148
+
149
+ ## 5. Labels in one line per source
150
+
151
+ - **SpokenWOZ**: the speaker's annotated turns from `data.json` (last stop in a turn = complete).
152
+ - **Seamless**: both participants' word timestamps (who speaks next; backchannels don't count).
153
+
154
+ ---
155
+
156
+ ## 6. SpokenWOZ
157
+
158
+ **Source**
159
+
160
+ | | audio | text |
161
+ |---|---|---|
162
+ | train + validation | `ssz1111/SpokenWOZ-Train-Audio` (HF splits overlap, indexed by dialogue id) | `ssz1111/SpokenWOZ-Train-Text` |
163
+ | test | `ssz1111/SpokenWOZ-Test-Audio-Fixed` | `ssz1111/SpokenWOZ-Test-Text-Fixed` |
164
+
165
+ - 5,700 dialogues, ~249 h: train 4,200 (182 h), validation 500 (22.5 h, official `valListFile.json`), test 1,000 (43.9 h).
166
+ Split by dialogue (no speaker ids).
167
+ - Audio 8 kHz stereo, never downmixed, **upsampled to 16 kHz on load**. Channel 0 = user, 1 = system in every call
168
+ (loudness check on all 5,700; the 3 swapped-looking calls are skipped).
169
+ - `data.json`: only turn boundaries are used (word times inside a turn are interpolated); speaker = `tag`, `ChannelId` ignored.
170
+ - Licence CC BY-NC 4.0.
171
+
172
+ **Pipeline** (`scripts/spokenwoz/build.py`, two stages per dialogue)
173
+
174
+ 1. VAD on both channels.
175
+ 2. Annotation shift: annotated turn ends are ~0.38 s late vs the audio (starts ~0.6 s early). `--correct-offset` (train)
176
+ shifts turn **ends** by train's median offset; validation/test reuse it from `stats/train_meta.json`.
177
+ 3. **Rule B (label)**: each stop goes to the speaker's nearest annotated turn (±0.5 s). Last stop in a turn = complete,
178
+ earlier ones = incomplete. If the last stop is > 0.5 s from the annotated end, the whole turn is dropped (`end_mismatch`);
179
+ stops in no turn → `outside_turn`; turns without a stop are logged (`no_vad_stop`).
180
+ 4. **Rule A (cross-check, in meta only)**: who speaks next from audio. ~7% disagreement, ~90% of it short replies rule A
181
+ treats as backchannels — rule B is the label.
182
+ 5. Clip (§4).
183
+
184
+ `meta`: role, rule B turn info, rule A label + gaps, turn start + run break reason, speech start/end, annotated turn,
185
+ transcript text, the other's next words, bleed flag.
186
+
187
+ ---
188
+
189
+ ## 7. Seamless Interaction (naturalistic)
190
+
191
+ **Source**
192
+
193
+ - HF `facebook/seamless-interaction`, naturalistic only: train 45,239 / dev 748 / test 823 conversations
194
+ (`assets/filelist.csv` in Meta's GitHub repo; copy in `tmp/seamless/meta/`). Splits have disjoint people.
195
+ - Tars hold video, pose, audio and transcript per participant (25.6 TB in total). `download.py` reads only the tar headers
196
+ and the `wav`/`json` members with `HfFileSystem` range reads, so video is never downloaded; `huggingface_hub` waits out
197
+ the Hub's rate limit. Stored as 16 kHz 24-bit FLAC + transcript json in `tmp/seamless/raw/{split}/`.
198
+ - One file per participant, `V<vendor>_S<session>_I<interaction>_P<participant>`; the two people of a conversation share
199
+ `V_S_I`. Only complete pairs are kept. 48 kHz mono, speaker-bleed denoised, 2–5 min per conversation.
200
+ - Transcript: segments with **real word timestamps** (+ alignment score). Meta's VAD is not used.
201
+ - Licence CC BY-NC 4.0.
202
+
203
+ **Pipeline** (`scripts/seamless/build.py`, one stage per conversation)
204
+
205
+ 1. VAD per participant; participants with < 5% speech give no examples (they still count as "the other").
206
+ 2. **Who takes the floor**: the other's transcript segments, except backchannels — ≤ 3 words that are all reaction words
207
+ (mm, hmm, mhm, uh-huh, yeah, yes, right, okay, oh, wow, alright, sure, really, ha, …), or any ≤ 3-word reply after
208
+ which the speaker talks again within 1 s.
209
+ 3. **Label** each stop of speaker S: S's next word before the other takes the floor → `incomplete`; the other first →
210
+ `complete`. Dropped: no word of S ends within 0.5 s of the stop (`no_word`), the other is mid-utterance (`overlap`),
211
+ nobody speaks within 3 s (`long_gap`), both start within 0.2 s (`collision`).
212
+ 4. **Cap**: at most **2 incomplete points per turn**, chosen at random (seeded per conversation and channel), in every
213
+ split; the rest are dropped as `turn_cap`. All complete points stay. (Story prompts make one person talk for minutes,
214
+ giving many near-duplicate pauses: without the cap only 16.5% of points are complete.)
215
+ 5. Clip (§4).
216
+
217
+ `meta`: participant id, gaps to the next own / other speech, distance from the stop to the nearest word end (median 55 ms),
218
+ turn start + run break reason, speech start/end, the clip's words, the other's next words, speech share.
219
+
220
+ ---
221
+
222
+ ## 8. After the full build
223
+
224
+ - Replace the **est.** numbers in §2 with actuals (rows, complete share, sizes per source and split).
scripts/seamless/GENERATE.md DELETED
@@ -1,64 +0,0 @@
1
- # Seamless Interaction (naturalistic) → EoT dataset
2
-
3
- Every VAD `speech_stop` of either participant in a two-person conversation is one example: that person's audio from the start of their current turn up to the moment the stop fires, labelled `complete` (the other person takes the floor next) or `incomplete` (they go on themselves).
4
-
5
- ## Quick commands
6
-
7
- ```bash
8
- source /venv/turn-data/bin/activate
9
-
10
- # audio + transcripts only (no video) -> tmp/seamless/raw/{split}/
11
- python -m scripts.seamless.download --split validation # all dev batches
12
- python -m scripts.seamless.download --split train --batches 0000 0001 # pick train batches (~12 h of conversation each)
13
-
14
- # sample run for review
15
- python -m scripts.seamless.build --split validation --vad-sr 16000 --out runs/seamless --limit 50
16
- python -m scripts.seamless.report --root runs/seamless --split validation
17
-
18
- pytest tests
19
- ```
20
-
21
- Each build processes the whole split from scratch; temporary files in `_parts_{split}/` are deleted after the merge.
22
- Rebuilding a split does not remove its old shards: delete `data/{split}-*.parquet` first.
23
-
24
- ## Source
25
-
26
- - HF `facebook/seamless-interaction`, **naturalistic** only (ordinary people, prompted conversations). Splits: validation = `dev`, test = `test`, train = chosen `train` batches.
27
- - Tars hold video, pose, audio and transcript per participant. `download.py` uses `HfFileSystem` to read only the tar headers and the `wav` / `json` members (range reads), so video is never downloaded. `huggingface_hub` waits out the Hub's rate limit by itself.
28
- - One file per participant, named `V<vendor>_S<session>_I<interaction>_P<participant>`; the two people of a conversation share `V_S_I` and sit in different tars of the same batch. Only complete pairs are kept.
29
- - Audio: 48 kHz mono float WAV, speaker-bleed denoised; stored as 16 kHz 24-bit FLAC (`tmp/seamless/raw`, ~2 GB per batch).
30
- - Transcript: segments with **real word timestamps** (+ alignment score). Meta's VAD is not used.
31
- - Licence CC BY-NC 4.0.
32
-
33
- ## Pipeline (per conversation)
34
-
35
- 1. **VAD** (`scripts/vad.py`, same as every source): Silero at `--vad-sr 16000`, 25 dB loudness gate. Stop fires 224 ms after speech end.
36
- 2. **Skip** participants with < 5% speech (they still count as "the other").
37
- 3. **Label** each stop of speaker S from both participants' words:
38
- - S's next word comes before the other takes the floor → `incomplete`; the other takes the floor first → `complete`.
39
- - A transcript segment of ≤ 2 words from mm / mhm / mm-hmm / uh-huh / yeah / right is a **backchannel**, not taking the floor.
40
- - Dropped: no word of S ends within 0.5 s of the stop (`no_word`), the other is mid-utterance (`overlap`), nobody speaks within 3 s (`long_gap`), both start within 0.2 s (`collision`).
41
- 4. **Clip**: S's own audio (16 kHz), from turn start − 0.3 s to exactly `fire_time`, at most the last 30 s. Turn start resets when the other has a real segment, takes the floor in the transcript, or S's previous stop was complete.
42
-
43
- ## Output
44
-
45
- Same schema as every source (`scripts/utils.py` `FEATURES`): `id, audio, data_source, original_data_id, channel, timestamp_start, timestamp_end, label, meta`, audio at 16 kHz for every source.
46
-
47
- | column | |
48
- |---|---|
49
- | `id` | `seamless_{V_S_I}_{channel}_{k:03d}`, k counts all VAD stops of that participant |
50
- | `audio` | FLAC, 16 kHz mono |
51
- | `original_data_id` | conversation `V_S_I` |
52
- | `channel` | 0 / 1 = the two participants sorted by `P` id (`meta.participant` has the id) |
53
- | `meta` | JSON: participant, gaps to next own / other speech, word offset at the stop, turn start + run break, text, other's words, speech share |
54
-
55
- ```
56
- data/{split}-XXXXX.parquet dropped/{split}.parquet stats/{split}_conversations.parquet, _meta.json report/{split}/
57
- ```
58
-
59
- ## Known (dev batch 0000: 249 conversations, 13.8 h)
60
-
61
- - 14.4k points, **21% complete**: story-telling prompts → one person talks for minutes, the other listens.
62
- - Clips long: median 9.4 s, 16% hit the 30 s cap; ~1.8 GB per 14 h of conversation.
63
- - 48 of 498 participants (10%) barely speak and are skipped.
64
- - VAD stops sit a median 55 ms from the nearest word end (real alignments).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
scripts/seamless/build.py CHANGED
@@ -7,7 +7,7 @@ incomplete (they go on themselves). Labels come from both participants' word tim
7
  python -m scripts.seamless.download --split validation # audio + transcripts -> tmp/seamless/raw/
8
  python -m scripts.seamless.build --split validation --vad-sr 16000 --out <root> [--limit N] [--workers K]
9
 
10
- Per conversation (files in <root>/_parts_{split}/, deleted after the merge) -> output under <root>:
11
  data/{split}-XXXXX.parquet same schema as every source (scripts/utils.py FEATURES)
12
  dropped/{split}.parquet dropped points with the reason (no audio)
13
  stats/{split}_conversations.parquet, _meta.json per-conversation info, settings used
@@ -16,10 +16,12 @@ import argparse
16
  import json
17
  import re
18
  import shutil
 
19
  from dataclasses import dataclass
20
  from multiprocessing import Pool
21
  from pathlib import Path
22
 
 
23
  import pandas as pd
24
  import soundfile as sf
25
  import torch
@@ -52,6 +54,8 @@ class Config:
52
  max_clip_s: float = 30.0 # clips keep at most the last 30 s before fire_time
53
  other_words_s: float = 3.0 # window for the other speaker's words in meta (review only)
54
  listen_tail_s: float = 2.0 # audio after fire_time in listening exports (humans only, never training)
 
 
55
  rows_per_shard: int = 10000
56
  seed: int = 0
57
 
@@ -120,6 +124,16 @@ def label_stop(seg: Segment, own_words: list[tuple], floor: list[tuple], cfg: Co
120
  "word_end_offset_s": near}
121
 
122
 
 
 
 
 
 
 
 
 
 
 
123
  # ======================================================================== per conversation
124
 
125
  def label_conversation(job) -> None:
@@ -140,10 +154,14 @@ def label_conversation(job) -> None:
140
  labels = [label_stop(seg, words[ch], floor, CFG) for seg in own]
141
  complete = [b["label"] == "complete" for b in labels]
142
  other_turn_starts = [s for s, _ in floor]
 
 
 
 
143
 
144
  # One point per VAD stop of this participant; j counts all stops, so ids stay stable when rules change.
145
  for j, (seg, b) in enumerate(zip(own, labels)):
146
- start, run_break = turn_start(own, j, other, other_turn_starts, complete, CFG.real_seg_s)
147
  s0, s1 = bounds(start, seg.fire, CFG.sr, CFG.preroll_s, CFG.max_clip_s)
148
  meta = {
149
  "participant": keys[ch].rsplit("_", 1)[1], **{k: v for k, v in b.items() if k not in ("label", "drop_reason")},
@@ -177,8 +195,8 @@ def main():
177
  args = p.parse_args()
178
 
179
  out, split, vad = args.out, args.split, VadConfig(sr=args.vad_sr)
180
- parts = out / f"_parts_{split}"
181
- for d in (parts, out / "data", out / "dropped", out / "stats"):
182
  d.mkdir(parents=True, exist_ok=True)
183
 
184
  # Conversations = V_S_I with both participants downloaded; participants sorted -> channel 0 / 1.
@@ -194,13 +212,13 @@ def main():
194
  for _ in tqdm(pool.imap_unordered(label_conversation, jobs), total=len(jobs), desc="label"):
195
  pass
196
 
197
- table, dropped = merge_parts(parts, ids, out, split, CFG.rows_per_shard)
198
- stats = [json.loads((parts / f"{c}.json").read_text()) for c in ids]
199
  pd.DataFrame([{"conversation": c, "duration": s["duration"], "speech_share_0": s["speech_share"][0],
200
  "speech_share_1": s["speech_share"][1], "participant_0": s["participants"][0], "participant_1": s["participants"][1]}
201
- for c, s in zip(ids, stats)]).to_parquet(out / "stats" / f"{split}_conversations.parquet")
202
  meta = {"n_conversations": len(ids), "config": vars(CFG), "vad": vars(vad)}
203
- (out / "stats" / f"{split}_meta.json").write_text(json.dumps(meta, indent=1))
204
  shutil.rmtree(parts)
205
  print(f"{split}: {len(table)} rows, {len(dropped)} dropped, {len(ids)} conversations")
206
 
 
7
  python -m scripts.seamless.download --split validation # audio + transcripts -> tmp/seamless/raw/
8
  python -m scripts.seamless.build --split validation --vad-sr 16000 --out <root> [--limit N] [--workers K]
9
 
10
+ Per conversation (files in <root>/_parts_{source}_{split}/, deleted after the merge) -> output under <root>:
11
  data/{split}-XXXXX.parquet same schema as every source (scripts/utils.py FEATURES)
12
  dropped/{split}.parquet dropped points with the reason (no audio)
13
  stats/{split}_conversations.parquet, _meta.json per-conversation info, settings used
 
16
  import json
17
  import re
18
  import shutil
19
+ import zlib
20
  from dataclasses import dataclass
21
  from multiprocessing import Pool
22
  from pathlib import Path
23
 
24
+ import numpy as np
25
  import pandas as pd
26
  import soundfile as sf
27
  import torch
 
54
  max_clip_s: float = 30.0 # clips keep at most the last 30 s before fire_time
55
  other_words_s: float = 3.0 # window for the other speaker's words in meta (review only)
56
  listen_tail_s: float = 2.0 # audio after fire_time in listening exports (humans only, never training)
57
+ # Long monologues give many near-duplicate incomplete points; keep a random few per turn (complete ones all stay).
58
+ max_incomplete_per_turn: int = 2
59
  rows_per_shard: int = 10000
60
  seed: int = 0
61
 
 
124
  "word_end_offset_s": near}
125
 
126
 
127
+ def cap_incomplete(labels: list[dict], turn_starts: list[float], cap: int, rng: np.random.Generator) -> set[int]:
128
+ """Indices of incomplete points to drop so each turn (same turn start) keeps at most `cap`, chosen at random."""
129
+ by_turn = {}
130
+ for j, (b, start) in enumerate(zip(labels, turn_starts)):
131
+ if b["label"] == "incomplete":
132
+ by_turn.setdefault(start, []).append(j)
133
+ keep = {j for js in by_turn.values() for j in rng.permutation(js)[:cap]}
134
+ return {j for js in by_turn.values() for j in js} - keep
135
+
136
+
137
  # ======================================================================== per conversation
138
 
139
  def label_conversation(job) -> None:
 
154
  labels = [label_stop(seg, words[ch], floor, CFG) for seg in own]
155
  complete = [b["label"] == "complete" for b in labels]
156
  other_turn_starts = [s for s, _ in floor]
157
+ starts = [turn_start(own, j, other, other_turn_starts, complete, CFG.real_seg_s) for j in range(len(own))]
158
+ rng = np.random.default_rng([CFG.seed, zlib.crc32(f"{conv}_{ch}".encode())]) # same choice on every rebuild
159
+ for j in cap_incomplete(labels, [s for s, _ in starts], CFG.max_incomplete_per_turn, rng):
160
+ labels[j] = {**labels[j], "label": None, "drop_reason": "turn_cap"}
161
 
162
  # One point per VAD stop of this participant; j counts all stops, so ids stay stable when rules change.
163
  for j, (seg, b) in enumerate(zip(own, labels)):
164
+ start, run_break = starts[j]
165
  s0, s1 = bounds(start, seg.fire, CFG.sr, CFG.preroll_s, CFG.max_clip_s)
166
  meta = {
167
  "participant": keys[ch].rsplit("_", 1)[1], **{k: v for k, v in b.items() if k not in ("label", "drop_reason")},
 
195
  args = p.parse_args()
196
 
197
  out, split, vad = args.out, args.split, VadConfig(sr=args.vad_sr)
198
+ parts, stats = out / f"_parts_{CFG.data_source}_{split}", out / "stats" / CFG.data_source
199
+ for d in (parts, out / "data", out / "dropped" / CFG.data_source, stats):
200
  d.mkdir(parents=True, exist_ok=True)
201
 
202
  # Conversations = V_S_I with both participants downloaded; participants sorted -> channel 0 / 1.
 
212
  for _ in tqdm(pool.imap_unordered(label_conversation, jobs), total=len(jobs), desc="label"):
213
  pass
214
 
215
+ table, dropped = merge_parts(parts, ids, out, split, CFG.data_source, CFG.rows_per_shard)
216
+ conv_stats = [json.loads((parts / f"{c}.json").read_text()) for c in ids]
217
  pd.DataFrame([{"conversation": c, "duration": s["duration"], "speech_share_0": s["speech_share"][0],
218
  "speech_share_1": s["speech_share"][1], "participant_0": s["participants"][0], "participant_1": s["participants"][1]}
219
+ for c, s in zip(ids, conv_stats)]).to_parquet(stats / f"{split}_conversations.parquet")
220
  meta = {"n_conversations": len(ids), "config": vars(CFG), "vad": vars(vad)}
221
+ (stats / f"{split}_meta.json").write_text(json.dumps(meta, indent=1))
222
  shutil.rmtree(parts)
223
  print(f"{split}: {len(table)} rows, {len(dropped)} dropped, {len(ids)} conversations")
224
 
scripts/seamless/report.py CHANGED
@@ -24,15 +24,16 @@ N_LISTEN = 10
24
 
25
  def load(root: Path, split: str):
26
  files = sorted((root / "data").glob(f"{split}-*.parquet"))
27
- t = pq.ParquetDataset(files).read(columns=["id", "original_data_id", "channel", "timestamp_start", "timestamp_end", "label", "meta"]).to_pandas()
 
28
  kept = pd.concat([t.drop(columns=["label", "meta"]), pd.DataFrame([json.loads(m) for m in t.meta])], axis=1)
29
  kept["label"] = t.label.map({0: "incomplete", 1: "complete"})
30
- dropped = pd.read_parquet(root / "dropped" / f"{split}.parquet")
31
  for df in (kept, dropped): # derived from the columns (not stored in meta)
32
  df["fire_time"] = df.timestamp_end
33
  df["clip_duration_s"] = df.timestamp_end - df.timestamp_start
34
- convs = pd.read_parquet(root / "stats" / f"{split}_conversations.parquet")
35
- meta = json.loads((root / "stats" / f"{split}_meta.json").read_text())
36
  return kept, dropped, convs, meta
37
 
38
 
@@ -128,7 +129,7 @@ def main():
128
  args = p.parse_args()
129
 
130
  cfg = Config()
131
- out = args.root / "report" / args.split
132
  out.mkdir(parents=True, exist_ok=True)
133
  kept, dropped, convs, meta = load(args.root, args.split)
134
  found = issues(kept, dropped, cfg)
 
24
 
25
  def load(root: Path, split: str):
26
  files = sorted((root / "data").glob(f"{split}-*.parquet"))
27
+ t = pq.ParquetDataset(files).read(columns=["id", "data_source", "original_data_id", "channel", "timestamp_start", "timestamp_end", "label", "meta"]).to_pandas()
28
+ t = t[t.data_source == "seamless"].drop(columns="data_source").reset_index(drop=True) # shards hold every source
29
  kept = pd.concat([t.drop(columns=["label", "meta"]), pd.DataFrame([json.loads(m) for m in t.meta])], axis=1)
30
  kept["label"] = t.label.map({0: "incomplete", 1: "complete"})
31
+ dropped = pd.read_parquet(root / "dropped" / "seamless" / f"{split}.parquet")
32
  for df in (kept, dropped): # derived from the columns (not stored in meta)
33
  df["fire_time"] = df.timestamp_end
34
  df["clip_duration_s"] = df.timestamp_end - df.timestamp_start
35
+ convs = pd.read_parquet(root / "stats" / "seamless" / f"{split}_conversations.parquet")
36
+ meta = json.loads((root / "stats" / "seamless" / f"{split}_meta.json").read_text())
37
  return kept, dropped, convs, meta
38
 
39
 
 
129
  args = p.parse_args()
130
 
131
  cfg = Config()
132
+ out = args.root / "report" / "seamless" / args.split
133
  out.mkdir(parents=True, exist_ok=True)
134
  kept, dropped, convs, meta = load(args.root, args.split)
135
  found = issues(kept, dropped, cfg)
scripts/spokenwoz/GENERATE.md DELETED
@@ -1,77 +0,0 @@
1
- # SpokenWOZ → EoT dataset
2
-
3
- Every VAD `speech_stop` on either channel of a call is one example: the speaker's audio from the start of their current turn up to the moment the stop fires, labelled `complete` (turn ended) or `incomplete` (they paused and went on).
4
-
5
- ## Quick commands
6
-
7
- ```bash
8
- source /venv/turn-data/bin/activate
9
-
10
- python -m scripts.spokenwoz.download_text # once: data.json files -> tmp/spokenwoz/text/
11
-
12
- # sample run for review
13
- python -m scripts.spokenwoz.build --split train --vad-sr 16000 --out runs/sample20 --limit 20 --correct-offset
14
- python -m scripts.spokenwoz.report --root runs/sample20
15
-
16
- # full build (dataset root = repo root); train first: validation/test reuse its shift
17
- for s in train validation test; do
18
- python -m scripts.spokenwoz.build --split $s --vad-sr 16000 --out . --workers 32 --correct-offset
19
- python -m scripts.spokenwoz.report --root . --split $s
20
- done
21
-
22
- pytest tests
23
- ```
24
-
25
- Each build processes the whole split from scratch (no resume); temporary per-dialogue files in `_parts_{split}/` are deleted after the merge.
26
- Rebuilding a split does not remove its old shards: delete `data/{split}-*.parquet` first.
27
-
28
- ## Sources
29
-
30
- | | audio | text |
31
- |---|---|---|
32
- | train + validation | `ssz1111/SpokenWOZ-Train-Audio` (HF splits overlap, indexed by dialogue id) | `ssz1111/SpokenWOZ-Train-Text` |
33
- | test | `ssz1111/SpokenWOZ-Test-Audio-Fixed` | `ssz1111/SpokenWOZ-Test-Text-Fixed` |
34
-
35
- - Validation = the official 500-id `valListFile.json`; train = the other 4,200. Split by dialogue (no speaker ids).
36
- - Audio: 8 kHz, 2 channels, never downmixed; upsampled to 16 kHz on load (VAD, clips and output all 16 kHz). Channel 0 = user, channel 1 = system, fixed (loudness check on all 5,700 calls); 3 calls that look swapped are skipped (`Config.skip_dialogues`: MUL2348, SNG1001, SNG0605).
37
- - `data.json`: only turn boundaries are used (word times inside a turn are interpolated). `ChannelId` is ignored; speaker = `tag`.
38
- - Licence CC BY-NC 4.0.
39
-
40
- ## Pipeline
41
-
42
- 1. **VAD** (`scripts/vad.py`, shared with demo/server): Silero at `--vad-sr 16000`, 32 ms frames, start ≥ 0.7 for 200 ms, stop < 0.55 for 200 ms, loudness gate 25 dB below the speaker's own running level (p90 of confident frames, 60 s, causal). **Stop fires 224 ms (7 frames) after speech end.**
43
- 2. **Rule B (label)**: each stop goes to the speaker's nearest annotated turn (±0.5 s). Last stop in a turn = complete, earlier = incomplete. Last stop > 0.5 s from the annotated end → whole turn dropped (`end_mismatch`). Stops in no turn → `outside_turn`.
44
- 3. **Rule A (cross-check, in meta)**: who speaks next (other's segments < 1 s ignored as backchannels).
45
- 4. **Clip**: speaker's own channel, from turn start − 0.3 s to exactly `fire_time` (no audio after: label leak), at most the last 30 s. Turn start breaks on the other's real segment, the other's annotated turn, or the previous complete stop.
46
-
47
- ## Output
48
-
49
- ```
50
- data/{split}-XXXXX.parquet the dataset (shards numbered in order)
51
- dropped/{split}.parquet dropped points / turns + reason
52
- stats/{split}_*.parquet, _meta.json per-dialogue info, offsets, exact settings used
53
- report/{split}/data_report.md, listen/ stats, issues to review, review WAVs (+2 s after fire, never training)
54
- ```
55
-
56
- The repo README's `configs:` block maps `data/{split}-*.parquet` to the splits, so `load_dataset("mavleo96/turn-detection-data")`
57
- loads only the shards (dropped/, stats/, report/ are ignored). A local sample without that README:
58
- `load_dataset("parquet", data_files={"train": "runs/sample20/data/train-*.parquet"})`.
59
-
60
- | column | |
61
- |---|---|
62
- | `id` | `spokenwoz_{dialogue}_{channel}_{k:03d}`, e.g. `spokenwoz_MUL0003_0_007`; k counts all VAD stops on that channel (stable ids) |
63
- | `audio` | FLAC, 16 kHz mono (upsampled from 8 kHz phone audio: no content above 4 kHz) |
64
- | `data_source` | `spokenwoz` |
65
- | `original_data_id` | e.g. `MUL0003` |
66
- | `channel` | 0 / 1 |
67
- | `timestamp_start`, `timestamp_end` | clip span in the call (s); end = fire_time |
68
- | `label` | `incomplete` / `complete` |
69
- | `meta` | JSON: role, rule A label, gaps, run break, annotated turn, text, … |
70
-
71
- ## Known issues (20-dialogue sample)
72
-
73
- - Annotations end ~0.38 s late and start ~0.6 s early vs VAD. `--correct-offset` (train) shifts only turn **ends** by the median offset (cuts `end_mismatch` drops ~⅓); validation/test reuse train's shift from `stats/train_meta.json`.
74
- - VAD settings chosen on all 500 validation calls (8k/16k × gate 15/25/off): 16 kHz + 25 dB gate keeps ~10% more points, misses 71% fewer turns (mostly short "yes"/"okay") and drops 78% fewer quiet-ending turns (`end_mismatch`) than 8 kHz + 15 dB; bleed suspects stay ~0.2%. Demo/server must use the same VAD settings.
75
- - ~7% rule A/B disagreement, mostly B=complete / A=incomplete.
76
- - Live serving must keep ≥ 0.6 s of audio before a declared `speech_start` to reproduce the 0.3 s pre-roll.
77
- - Expected full size ~11 GB, ~300k rows.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
scripts/spokenwoz/build.py CHANGED
@@ -8,10 +8,10 @@ incomplete (they paused and went on).
8
  python -m scripts.spokenwoz.build --split train --vad-sr 16000 --out <root> [--limit N] [--workers K] [--correct-offset]
9
  python -m scripts.spokenwoz.build --split validation --vad-sr 16000 --out <root> # then validation / test
10
 
11
- Build train first: validation and test reuse train's annotation shift (stats/train_meta.json),
12
  so every split is labelled with exactly the same settings.
13
 
14
- Two stages over all dialogues (per-dialogue files in <root>/_parts_{split}/, deleted after the merge):
15
  1. per dialogue: VAD on both channels -> {id}.json
16
  then over all dialogues: annotation timing offset
17
  2. per dialogue: labels + clips -> {id}.parquet, {id}.dropped.parquet
@@ -294,8 +294,8 @@ def main():
294
  args = p.parse_args()
295
 
296
  out, split, vad = args.out, args.split, VadConfig(sr=args.vad_sr)
297
- parts = out / f"_parts_{split}"
298
- for d in (parts, out / "data", out / "dropped", out / "stats"):
299
  d.mkdir(parents=True, exist_ok=True)
300
  ids, text, index = split_dialogues(split, CFG)
301
  ids = ids[: args.limit]
@@ -321,20 +321,20 @@ def main():
321
  if split == "train":
322
  shift = float(offs.offset.median()) if args.correct_offset else 0.0
323
  else:
324
- shift = json.loads((out / "stats" / "train_meta.json").read_text())["shift"]
325
 
326
  # Stage 2
327
  run(pool, label_dialogue, [(did, text[did], index[did], shift, parts) for did in ids], "label")
328
 
329
- table, dropped = merge_parts(parts, ids, out, split, CFG.rows_per_shard)
330
 
331
  pd.DataFrame([
332
  {"dialogue_id": did, "duration": a["duration"], "merges": a["merges"]}
333
  for did, a in analyses.items()
334
- ]).to_parquet(out / "stats" / f"{split}_dialogues.parquet")
335
- offs.to_parquet(out / "stats" / f"{split}_offsets.parquet")
336
  meta = {"shift": shift, "channels": CHANNELS, "n_dialogues": len(ids), "config": vars(CFG), "vad": vars(vad)}
337
- (out / "stats" / f"{split}_meta.json").write_text(json.dumps(meta, indent=1))
338
  shutil.rmtree(parts)
339
  print(f"{split}: {len(table)} rows, {len(dropped)} dropped, shift={shift:+.3f}s")
340
 
 
8
  python -m scripts.spokenwoz.build --split train --vad-sr 16000 --out <root> [--limit N] [--workers K] [--correct-offset]
9
  python -m scripts.spokenwoz.build --split validation --vad-sr 16000 --out <root> # then validation / test
10
 
11
+ Build train first: validation and test reuse train's annotation shift (stats/spokenwoz/train_meta.json),
12
  so every split is labelled with exactly the same settings.
13
 
14
+ Two stages over all dialogues (per-dialogue files in <root>/_parts_{source}_{split}/, deleted after the merge):
15
  1. per dialogue: VAD on both channels -> {id}.json
16
  then over all dialogues: annotation timing offset
17
  2. per dialogue: labels + clips -> {id}.parquet, {id}.dropped.parquet
 
294
  args = p.parse_args()
295
 
296
  out, split, vad = args.out, args.split, VadConfig(sr=args.vad_sr)
297
+ parts, stats = out / f"_parts_{CFG.data_source}_{split}", out / "stats" / CFG.data_source
298
+ for d in (parts, out / "data", out / "dropped" / CFG.data_source, stats):
299
  d.mkdir(parents=True, exist_ok=True)
300
  ids, text, index = split_dialogues(split, CFG)
301
  ids = ids[: args.limit]
 
321
  if split == "train":
322
  shift = float(offs.offset.median()) if args.correct_offset else 0.0
323
  else:
324
+ shift = json.loads((stats / "train_meta.json").read_text())["shift"]
325
 
326
  # Stage 2
327
  run(pool, label_dialogue, [(did, text[did], index[did], shift, parts) for did in ids], "label")
328
 
329
+ table, dropped = merge_parts(parts, ids, out, split, CFG.data_source, CFG.rows_per_shard)
330
 
331
  pd.DataFrame([
332
  {"dialogue_id": did, "duration": a["duration"], "merges": a["merges"]}
333
  for did, a in analyses.items()
334
+ ]).to_parquet(stats / f"{split}_dialogues.parquet")
335
+ offs.to_parquet(stats / f"{split}_offsets.parquet")
336
  meta = {"shift": shift, "channels": CHANNELS, "n_dialogues": len(ids), "config": vars(CFG), "vad": vars(vad)}
337
+ (stats / f"{split}_meta.json").write_text(json.dumps(meta, indent=1))
338
  shutil.rmtree(parts)
339
  print(f"{split}: {len(table)} rows, {len(dropped)} dropped, shift={shift:+.3f}s")
340
 
scripts/spokenwoz/report.py CHANGED
@@ -24,16 +24,17 @@ N_LISTEN = 10
24
 
25
  def load(root: Path, split: str):
26
  files = sorted((root / "data").glob(f"{split}-*.parquet"))
27
- t = pq.ParquetDataset(files).read(columns=["id", "original_data_id", "channel", "timestamp_start", "timestamp_end", "label", "meta"]).to_pandas()
 
28
  kept = pd.concat([t.drop(columns=["label", "meta"]), pd.DataFrame([json.loads(m) for m in t.meta])], axis=1)
29
  kept["label"] = t.label.map({0: "incomplete", 1: "complete"})
30
- dropped = pd.read_parquet(root / "dropped" / f"{split}.parquet")
31
  for df in (kept, dropped): # derived from the columns (not stored in meta)
32
  df["fire_time"] = df.timestamp_end
33
  df["clip_duration_s"] = df.timestamp_end - df.timestamp_start
34
- dialogues = pd.read_parquet(root / "stats" / f"{split}_dialogues.parquet")
35
- offsets = pd.read_parquet(root / "stats" / f"{split}_offsets.parquet")
36
- meta = json.loads((root / "stats" / f"{split}_meta.json").read_text())
37
  return kept, dropped, dialogues, offsets, meta
38
 
39
 
@@ -150,7 +151,7 @@ def main():
150
  args = p.parse_args()
151
 
152
  cfg = Config()
153
- out = args.root / "report" / args.split
154
  out.mkdir(parents=True, exist_ok=True)
155
  kept, dropped, dialogues, offsets, meta = load(args.root, args.split)
156
  found = issues(kept, dropped)
 
24
 
25
  def load(root: Path, split: str):
26
  files = sorted((root / "data").glob(f"{split}-*.parquet"))
27
+ t = pq.ParquetDataset(files).read(columns=["id", "data_source", "original_data_id", "channel", "timestamp_start", "timestamp_end", "label", "meta"]).to_pandas()
28
+ t = t[t.data_source == "spokenwoz"].drop(columns="data_source").reset_index(drop=True) # shards hold every source
29
  kept = pd.concat([t.drop(columns=["label", "meta"]), pd.DataFrame([json.loads(m) for m in t.meta])], axis=1)
30
  kept["label"] = t.label.map({0: "incomplete", 1: "complete"})
31
+ dropped = pd.read_parquet(root / "dropped" / "spokenwoz" / f"{split}.parquet")
32
  for df in (kept, dropped): # derived from the columns (not stored in meta)
33
  df["fire_time"] = df.timestamp_end
34
  df["clip_duration_s"] = df.timestamp_end - df.timestamp_start
35
+ dialogues = pd.read_parquet(root / "stats" / "spokenwoz" / f"{split}_dialogues.parquet")
36
+ offsets = pd.read_parquet(root / "stats" / "spokenwoz" / f"{split}_offsets.parquet")
37
+ meta = json.loads((root / "stats" / "spokenwoz" / f"{split}_meta.json").read_text())
38
  return kept, dropped, dialogues, offsets, meta
39
 
40
 
 
151
  args = p.parse_args()
152
 
153
  cfg = Config()
154
+ out = args.root / "report" / "spokenwoz" / args.split
155
  out.mkdir(parents=True, exist_ok=True)
156
  kept, dropped, dialogues, offsets, meta = load(args.root, args.split)
157
  found = issues(kept, dropped)
scripts/utils.py CHANGED
@@ -72,13 +72,18 @@ def write_rows(rows: list[dict], path: Path) -> None:
72
  pq.write_table(table, path)
73
 
74
 
75
- def merge_parts(parts: Path, ids: list[str], out: Path, split: str, rows_per_shard: int) -> tuple[pa.Table, pd.DataFrame]:
76
- """Per-item parts -> data/{split}-XXXXX.parquet shards (numbered in order) + dropped/{split}.parquet."""
 
 
 
 
 
77
  table = pa.concat_tables([pq.read_table(parts / f"{i}.parquet") for i in ids])
78
  for n, start in enumerate(range(0, max(len(table), 1), rows_per_shard)):
79
- pq.write_table(table.slice(start, rows_per_shard), out / "data" / f"{split}-{n:05d}.parquet")
80
  dropped = pd.concat([pd.read_parquet(parts / f"{i}.dropped.parquet") for i in ids], ignore_index=True)
81
- dropped.to_parquet(out / "dropped" / f"{split}.parquet")
82
  return table, dropped
83
 
84
 
 
72
  pq.write_table(table, path)
73
 
74
 
75
+ def merge_parts(parts: Path, ids: list[str], out: Path, split: str, source: str, rows_per_shard: int) -> tuple[pa.Table, pd.DataFrame]:
76
+ """Per-item parts -> data/{split}-XXXXX.parquet shards + dropped/{source}/{split}.parquet.
77
+
78
+ Shard numbers continue after the split's existing shards, so sources built one after another into the same
79
+ root share one numbering (SpokenWOZ 00000.., then Seamless). Rebuilding a source means rebuilding the split.
80
+ """
81
+ first = len(list((out / "data").glob(f"{split}-*.parquet")))
82
  table = pa.concat_tables([pq.read_table(parts / f"{i}.parquet") for i in ids])
83
  for n, start in enumerate(range(0, max(len(table), 1), rows_per_shard)):
84
+ pq.write_table(table.slice(start, rows_per_shard), out / "data" / f"{split}-{first + n:05d}.parquet")
85
  dropped = pd.concat([pd.read_parquet(parts / f"{i}.dropped.parquet") for i in ids], ignore_index=True)
86
+ dropped.to_parquet(out / "dropped" / source / f"{split}.parquet")
87
  return table, dropped
88
 
89
 
tests/seamless/test_labels.py CHANGED
@@ -1,4 +1,6 @@
1
- from scripts.seamless.build import Config, floor_utterances, label_stop, words_and_utterances
 
 
2
  from scripts.vad import Segment
3
 
4
  CFG = Config()
@@ -70,3 +72,12 @@ def test_short_reply_then_speaker_goes_on_is_a_backchannel():
70
 
71
  def test_long_reply_always_takes_the_floor():
72
  assert floor_utterances([(2.4, 4.0, 6, False)], OWN + [(4.2, 5.0, "and")], CFG) == [(2.4, 4.0)]
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+
3
+ from scripts.seamless.build import Config, cap_incomplete, floor_utterances, label_stop, words_and_utterances
4
  from scripts.vad import Segment
5
 
6
  CFG = Config()
 
72
 
73
  def test_long_reply_always_takes_the_floor():
74
  assert floor_utterances([(2.4, 4.0, 6, False)], OWN + [(4.2, 5.0, "and")], CFG) == [(2.4, 4.0)]
75
+
76
+
77
+ def test_cap_incomplete_keeps_at_most_cap_per_turn_and_all_complete():
78
+ inc, com = {"label": "incomplete"}, {"label": "complete"}
79
+ labels = [inc] * 6 + [com] + [inc] * 2 + [com]
80
+ starts = [0.0] * 7 + [9.0] * 3 # turn 1: 6 incomplete + complete, turn 2: 2 incomplete + complete
81
+ drop = cap_incomplete(labels, starts, 3, np.random.default_rng(0))
82
+ assert len(drop) == 3 and drop <= set(range(6)) # 3 of the 6 in turn 1; turn 2 untouched; completes never dropped
83
+ assert drop == cap_incomplete(labels, starts, 3, np.random.default_rng(0)) # deterministic for a seed