polyvoice 0.6.8

Speaker diarization for Rust — who spoke when. ONNX-powered: Silero VAD, WeSpeaker embeddings, Pyannote segmentation, K-means/AHC clustering, overlap detection.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
name: CI

on:
  push:
    branches: [master, main]
    tags: ["v*"]
  pull_request:
    branches: [master, main]
  schedule:
    - cron: "0 2 * * *"
  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

permissions: {}

env:
  CARGO_TERM_COLOR: always

jobs:
  check:
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            flags: --all-targets --all-features
          - os: macos-latest
            flags: --all-targets --features onnx,ffi,cli
          - os: windows-latest
            flags: --all-targets --features onnx,ffi,cli
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - run: cargo check ${{ matrix.flags }}

  fmt:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt
      - run: cargo fmt --check

  clippy:
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            flags: --all-targets --all-features
          - os: macos-latest
            flags: --all-targets --features onnx,ffi,cli
          - os: windows-latest
            flags: --all-targets --features onnx,ffi,cli
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy
      - uses: Swatinem/rust-cache@v2
        with:
          key: clippy-${{ matrix.os }}-${{ hashFiles('Cargo.toml', '**/Cargo.toml', '**/Cargo.lock') }}
          cache-on-failure: false
      - shell: bash
        run: cargo clippy ${{ matrix.flags }} -- -D warnings 2>&1 | tee clippy.log
      - if: failure()
        uses: actions/upload-artifact@v4
        with:
          name: clippy-log-${{ matrix.os }}
          path: clippy.log

  test:
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            flags: --all-features
          - os: macos-latest
            flags: --features onnx,ffi,cli
          - os: windows-latest
            flags: --features onnx,ffi,cli
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - uses: taiki-e/install-action@v2
        with:
          tool: cargo-nextest
      - run: cargo nextest run --profile ci ${{ matrix.flags }}

  doc:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - run: cargo doc --no-deps --all-features
        env:
          RUSTDOCFLAGS: "-D warnings"

  coverage:
    runs-on: ubuntu-latest
    timeout-minutes: 30
    permissions:
      contents: read
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: llvm-tools-preview
      - uses: Swatinem/rust-cache@v2
      - uses: taiki-e/install-action@v2
        with:
          tool: cargo-llvm-cov
      - uses: taiki-e/install-action@v2
        with:
          tool: cargo-nextest
      - run: cargo llvm-cov nextest --profile ci --all-features --cobertura --output-path cobertura.xml --fail-under-lines 70
      - if: always()
        uses: actions/upload-artifact@v4
        with:
          name: coverage-report
          path: cobertura.xml
      - uses: codecov/codecov-action@v4
        with:
          files: ./cobertura.xml
          fail_ci_if_error: false
        env:
          CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

  miri:
    runs-on: ubuntu-latest
    timeout-minutes: 30
    continue-on-error: true
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@nightly
        with:
          components: miri
      - uses: Swatinem/rust-cache@v2
      - run: |
          cargo miri test --features ffi --test ffi_smoke_test ffi_create
          cargo miri test --features resegmentation --test miri_resegmentation
          cargo miri test --features ffi --test test_ahc
        env:
          MIRIFLAGS: "-Zmiri-disable-isolation"

  valgrind:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - run: sudo apt-get update && sudo apt-get install -y valgrind
      - run: cargo test --features ffi --test ffi_smoke_test --no-run
      - name: Run under valgrind
        run: |
          BIN=$(find target/debug/deps -maxdepth 1 -name 'ffi_smoke_test-*' -type f -executable | head -1)
          valgrind --leak-check=full --errors-for-leak-kinds=definite --error-exitcode=1 \
            "$BIN" ffi_create_invalid_profile_returns_invalid_arg ffi_create_null_out_handle_returns_error

  loom:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - run: cargo test --test loom_pool
        env:
          LOOM_MAX_PREEMPTIONS: 3

  semver-checks:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - uses: taiki-e/install-action@v2
        with:
          tool: cargo-semver-checks
      - run: cargo semver-checks check-release

  audit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - uses: taiki-e/install-action@v2
        with:
          tool: cargo-audit
      - run: cargo audit

  deny:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: taiki-e/install-action@v2
        with:
          tool: cargo-deny
      - run: cargo deny check advisories licenses

  hack:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - uses: taiki-e/install-action@v2
        with:
          tool: cargo-hack
      - run: cargo hack check --feature-powerset --depth 2 --lib --bins

  msrv:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@1.85.0
      - uses: Swatinem/rust-cache@v2
      # MSRV applies to the core library (default features). ONNX-dependent
      # features pull ort which requires a newer Rust compiler.
      - run: cargo check --lib

  machete:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: taiki-e/install-action@v2
        with:
          tool: cargo-machete
      - run: cargo machete

  kani:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: model-checking/kani-github-action@v1
        with:
          args: "--lib"

  cross-aarch64-linux:
    runs-on: ubuntu-latest
    env:
      CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: aarch64-unknown-linux-gnu
      - uses: Swatinem/rust-cache@v2
      - run: sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu
      - run: cargo check --target aarch64-unknown-linux-gnu
      - run: cargo check --target aarch64-unknown-linux-gnu --features download

  wasm32-smoke:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: wasm32-unknown-unknown
      - uses: Swatinem/rust-cache@v2
      - run: cargo check --target wasm32-unknown-unknown --no-default-features --lib

  e2e-smoke:
    runs-on: ubuntu-latest
    needs: [test]
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - uses: actions/cache@v4
        with:
          path: ~/.cache/polyvoice/models
          key: models-balanced-${{ hashFiles('src/models/manifest.rs') }}
      - name: Download ONNX models
        run: cargo run --features cli --bin polyvoice -- download-models --profile balanced
      - uses: taiki-e/install-action@v2
        with:
          tool: cargo-nextest
      - name: Run E2E smoke test
        run: cargo nextest run --profile ci --run-ignored only --test e2e_smoke_test --features "onnx download" --nocapture

  e2e-der-regression:
    runs-on: ubuntu-latest
    needs: [test]
    if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/v')
    timeout-minutes: 45
    strategy:
      fail-fast: false
      matrix:
        include:
          - name: legacy-e2e-smoke
            test: der_regression_e2e_smoke
            test_flags: "--test der_regression_test --features onnx,download"
            data_key: e2e-smoke-bundled
            data_path: tests/data/e2e-smoke
          - name: legacy-ami-single
            test: der_regression_ami_test_single
            test_flags: "--test der_regression_test --features onnx,download"
            data_script: scripts/download-ami-test-single.sh
            data_key: ami-test-single
            data_path: data/ami-test-single
          - name: pipeline-v2
            test_flags: "--test pipeline_v2_integration --features onnx,segmentation,embedder,clusterer,resegmentation,download"
            data_key: e2e-smoke-bundled
            data_path: tests/data/e2e-smoke
          - name: pipeline-v2-ami
            test: v2_der_ami_test_single
            test_flags: "--test der_v2_baseline_test --features onnx,segmentation,embedder,clusterer,resegmentation,download"
            data_script: scripts/download-ami-test-single.sh
            data_key: ami-test-single
            data_path: data/ami-test-single
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - uses: actions/cache@v4
        with:
          path: ~/.cache/polyvoice/models
          key: models-balanced-${{ hashFiles('src/models/manifest.rs') }}
      - uses: actions/cache@v4
        if: matrix.data_script
        with:
          path: ${{ matrix.data_path }}
          key: ${{ matrix.data_key }}-${{ hashFiles(format('{0}.sh', matrix.data_script)) }}
      - name: Download external test data
        if: matrix.data_script
        run: bash ${{ matrix.data_script }}
      - name: Download ONNX models
        run: cargo run --features cli --bin polyvoice -- download-models --profile balanced
      - uses: taiki-e/install-action@v2
        with:
          tool: cargo-nextest
      - name: Run DER regression — ${{ matrix.name }}
        shell: bash
        run: cargo nextest run --profile ci --run-ignored only ${{ matrix.test_flags }} ${{ matrix.test }} --nocapture 2>&1 | tee der-regression.log
      - if: failure() || cancelled()
        uses: actions/upload-artifact@v4
        with:
          name: der-regression-log-${{ matrix.name }}
          path: der-regression.log
        continue-on-error: true

  perf-regression:
    runs-on: ubuntu-latest
    needs: [test]
    if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - uses: actions/cache@v4
        with:
          path: data/voxconverse-test
          key: voxconverse-test-${{ hashFiles('scripts/download-voxconverse-test.sh') }}
      - uses: actions/cache@v4
        with:
          path: ~/.cache/polyvoice/models
          key: models-balanced-${{ hashFiles('src/models/manifest.rs') }}
      - run: bash scripts/download-voxconverse-test.sh
      - run: cargo run --features cli --bin polyvoice -- download-models --profile balanced
      - uses: taiki-e/install-action@v2
        with:
          tool: cargo-nextest
      - name: Run perf regression test
        shell: bash
        run: cargo nextest run --profile ci --run-ignored only --test perf_regression_test --features "onnx download" --nocapture 2>&1 | tee perf-regression.log
      - if: always()
        uses: actions/upload-artifact@v4
        with:
          name: perf-regression-log
          path: perf-regression.log

  e2e-der-regression-voxconverse:
    runs-on: ubuntu-latest
    needs: [test]
    if: github.event_name == 'schedule'
    timeout-minutes: 45
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - uses: actions/cache@v4
        with:
          path: ~/.cache/polyvoice/models
          key: models-balanced-${{ hashFiles('src/models/manifest.rs') }}
      - uses: actions/cache@v4
        with:
          path: data/voxconverse-test
          key: voxconverse-test-${{ hashFiles('scripts/download-voxconverse-test.sh') }}
      - run: bash scripts/download-voxconverse-test.sh
      - run: cargo run --features cli --bin polyvoice -- download-models --profile balanced
      - uses: taiki-e/install-action@v2
        with:
          tool: cargo-nextest
      - name: Run DER regression — VoxConverse 10-file
        shell: bash
        run: cargo nextest run --profile ci --run-ignored only --test der_regression_test --features onnx,download der_regression_voxconverse_10_file_subset --nocapture 2>&1 | tee der-regression.log
      - if: failure() || cancelled()
        uses: actions/upload-artifact@v4
        with:
          name: der-regression-log-voxconverse-10
          path: der-regression.log
        continue-on-error: true

  sign-manifest-dry-run:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: |
          sudo apt-get update && sudo apt-get install -y minisign
      - run: ./scripts/sign-models.sh --dry-run