owensong commited on
Commit
9528ca8
·
verified ·
1 Parent(s): 44ec191

Stage verified Inflect v2 release candidate and evaluation evidence

Browse files
Files changed (5) hide show
  1. .gitattributes +1 -3
  2. README.md +2 -2
  3. docs/EVALUATION.md +220 -33
  4. inference.py +28 -6
  5. release_manifest.json +6 -6
.gitattributes CHANGED
@@ -33,11 +33,9 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
36
  samples/male/conversational.wav filter=lfs diff=lfs merge=lfs -text
37
  samples/male/names_places.wav filter=lfs diff=lfs merge=lfs -text
38
  samples/male/numbers.wav filter=lfs diff=lfs merge=lfs -text
39
  samples/male/punctuation.wav filter=lfs diff=lfs merge=lfs -text
40
  samples/male/technical.wav filter=lfs diff=lfs merge=lfs -text
41
- smoke/release_smoke.wav filter=lfs diff=lfs merge=lfs -text
42
- smoke/standalone_cpu.wav filter=lfs diff=lfs merge=lfs -text
43
- assets/inflect-v2-repository-hero.png filter=lfs diff=lfs merge=lfs -text
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ assets/inflect-v2-repository-hero.png filter=lfs diff=lfs merge=lfs -text
37
  samples/male/conversational.wav filter=lfs diff=lfs merge=lfs -text
38
  samples/male/names_places.wav filter=lfs diff=lfs merge=lfs -text
39
  samples/male/numbers.wav filter=lfs diff=lfs merge=lfs -text
40
  samples/male/punctuation.wav filter=lfs diff=lfs merge=lfs -text
41
  samples/male/technical.wav filter=lfs diff=lfs merge=lfs -text
 
 
 
README.md CHANGED
@@ -30,8 +30,8 @@ inference: false
30
  <a href="https://huggingface.co/spaces/owensong/Inflect-v2"><img alt="Live playground" src="https://img.shields.io/badge/Playground-0B2A54?style=for-the-badge&logo=huggingface&logoColor=white"></a>
31
  <a href="https://github.com/owenawsong/Inflect"><img alt="GitHub" src="https://img.shields.io/badge/GitHub-1769E0?style=for-the-badge&logo=github&logoColor=white"></a>
32
  <a href="https://huggingface.co/owensong/Inflect-Nano-v2"><img alt="Inflect Nano v2" src="https://img.shields.io/badge/Nano_3.97M-FFFFFF?style=for-the-badge&logo=huggingface&logoColor=1769E0"></a>
33
- <a href="docs/FINETUNING.md"><img alt="Fine-tuning guide" src="https://img.shields.io/badge/Fine--tuning_Guide-1769E0?style=for-the-badge&logo=readthedocs&logoColor=white"></a>
34
- <a href="https://discord.gg/CVJYedvzvp"><img alt="Inflect Discord" src="https://img.shields.io/badge/Discord-0B2A54?style=for-the-badge&logo=discord&logoColor=white"></a>
35
  </p>
36
 
37
  <p align="center"><strong>9.36M complete parameters</strong> · <strong>37.53 MB FP32 weights</strong> · <strong>one fixed English voice</strong> · <strong>no external vocoder</strong></p>
 
30
  <a href="https://huggingface.co/spaces/owensong/Inflect-v2"><img alt="Live playground" src="https://img.shields.io/badge/Playground-0B2A54?style=for-the-badge&logo=huggingface&logoColor=white"></a>
31
  <a href="https://github.com/owenawsong/Inflect"><img alt="GitHub" src="https://img.shields.io/badge/GitHub-1769E0?style=for-the-badge&logo=github&logoColor=white"></a>
32
  <a href="https://huggingface.co/owensong/Inflect-Nano-v2"><img alt="Inflect Nano v2" src="https://img.shields.io/badge/Nano_3.97M-FFFFFF?style=for-the-badge&logo=huggingface&logoColor=1769E0"></a>
33
+ <a href="https://discord.gg/CVJYedvzvp"><img alt="Inflect Discord" src="https://img.shields.io/badge/Discord-1769E0?style=for-the-badge&logo=discord&logoColor=white"></a>
34
+ <a href="docs/EVALUATION.md"><img alt="Benchmarks" src="https://img.shields.io/badge/Benchmarks-0B2A54?style=for-the-badge&logo=chartdotjs&logoColor=white"></a>
35
  </p>
36
 
37
  <p align="center"><strong>9.36M complete parameters</strong> · <strong>37.53 MB FP32 weights</strong> · <strong>one fixed English voice</strong> · <strong>no external vocoder</strong></p>
docs/EVALUATION.md CHANGED
@@ -1,47 +1,234 @@
1
- # Final evaluation protocol
2
 
3
- ## Matched corpus
 
 
 
 
 
4
 
5
- Modern400 intelligibility results use 400 identical unseen English prompts per system. The set combines 200 fixed modern/stress prompts with 200 deterministic Google FLEURS `en_us` test prompts. Exact normalized text was excluded against 87,362 training transcripts. The frozen prompt manifest, corpus hash, exclusion report, compact summary, and compressed row-level reports are included under `evaluation/final/modern400/`. UTMOS22 remains a separate matched quality evaluation and is not merged with Modern400.
 
 
 
6
 
7
- ## Systems
8
 
9
- - Inflect-Micro-v2 and Inflect-Nano-v2, fixed release checkpoints.
10
- - KittenTTS Nano, Bruno and Hugo reported separately.
11
- - Piper low, Ryan and Danny reported separately.
12
- - Supertonic 3, James (`M2` preset) at 3 and 8 steps, reported separately.
13
 
14
- Kitten and Piper voices are reported separately. The two Supertonic step counts are never pooled.
15
 
16
- ## Intelligibility
17
 
18
- Semantic WER is run independently with Qwen3-ASR-1.7B, Nemotron 3.5 ASR 0.6B, and Whisper large-v3. Every input is explicitly resampled to each recognizer's required rate before inference. References and hypotheses are normalized into equivalent spoken English forms so formatting differences such as `12.6` versus `twelve point six` are not automatically counted as speech errors. Reports include every hypothesis, per-clip errors, prompt-category breakdowns, and 10,000-sample bootstrap intervals.
19
-
20
- `ASR avg.` is the unweighted arithmetic mean of the three corpus-level semantic WERs. Its interval uses matched-prompt bootstrap resampling. This average is descriptive rather than a replacement for individual ASR results because recognizers can share biases or fail catastrophically on isolated clips.
21
 
22
- ## Predicted quality
23
 
24
- UTMOS22 is run over every generated clip with 10,000-sample bootstrap intervals. It is a learned quality predictor, not human MOS, and is reported separately from WER and human preference.
 
 
 
 
25
 
26
- ## Runtime
27
-
28
- The release CPU snapshot uses an AMD Ryzen 9 3900X (12 physical cores, 24
29
- logical processors), a fixed 12-thread policy, the same 48-prompt subset, three
30
- warmups, one isolated process per system, and separate model-load timing.
31
- `CUDA_VISIBLE_DEVICES` is empty; active providers are captured in every report.
32
- The timed boundary includes each public text frontend and complete waveform
33
- generation. RTF, audio-seconds per wall-second, median latency, p95 latency, and
34
- per-prompt rows are retained.
35
-
36
- This remains **host-specific engineering evidence**, not a universal speed
37
- ranking. Frameworks use different execution engines and output sample rates.
38
- The raw reports disclose those boundaries so results can be reproduced rather
39
- than silently generalized to unrelated hardware.
40
 
41
- ## Human evidence
42
 
43
- The community study was blind, randomized left/right order, and stored pairwise preferences rather than user identity. Preference rate is `(wins + 0.5 × ties) / appearances`. It is descriptive community evidence, not a formal laboratory MOS study.
 
44
 
45
- ## Reporting rules
 
 
 
 
 
 
 
 
 
46
 
47
- No aggregate score combines WER, UTMOS22, speed, size, and human preference. Confidence intervals, raw reports, model weight footprint, and known limitations accompany headline values.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Inflect v2 evaluation and benchmark report
2
 
3
+ This page is the detailed evidence record for
4
+ [Inflect-Micro-v2](https://huggingface.co/owensong/Inflect-Micro-v2) and
5
+ [Inflect-Nano-v2](https://huggingface.co/owensong/Inflect-Nano-v2). The model
6
+ cards show the headline results; this document defines the datasets, systems,
7
+ normalization, uncertainty, exclusions, runtime boundaries, and raw artifacts
8
+ behind those results.
9
 
10
+ > **Interpret results by axis, not as one universal score.** Intelligibility,
11
+ > predicted naturalness, human preference, model footprint, and runtime measure
12
+ > different properties. Inflect does not combine them into a proprietary
13
+ > aggregate.
14
 
15
+ ## Evidence at a glance
16
 
17
+ | Release | Complete parameters | FP32 weights | UTMOS22 ↑ | Two-ASR semantic WER ↓ | Community preference ↑ |
18
+ | --- | ---: | ---: | ---: | ---: | ---: |
19
+ | **Inflect-Micro-v2** | **9,356,513** | **37.53 MB** | **4.395** | **3.99%** | **66.2%** |
20
+ | **Inflect-Nano-v2** | **3,966,721** | **15.97 MB** | **4.386** | **4.21%** | **63.9%** |
21
 
22
+ ![Community blind listening](../assets/evidence/human-preference.svg)
23
 
24
+ ![Predicted quality versus footprint](../assets/evidence/quality-vs-footprint.svg)
25
 
26
+ ![Two-ASR semantic WER](../assets/evidence/asr-consensus.svg)
 
 
27
 
28
+ ## Comparator policy
29
 
30
+ The comparison set intentionally uses serious compact or on-device systems:
31
+ KittenTTS Nano, Piper Low, and Supertonic 3. It does not use deliberately weak
32
+ baselines. Every comparator in this package-level study has a larger deployable
33
+ weight footprint than both Inflect releases. That makes the comparison
34
+ demanding, but it does not mean one benchmark proves universal superiority.
35
 
36
+ Voice variants are separate rows when voice identity can affect quality or
37
+ intelligibility. Kitten and Piper may be shown as equal-weight two-voice means
38
+ in family-level figures. Supertonic 3-step and 8-step are never pooled.
 
 
 
 
 
 
 
 
 
 
 
39
 
40
+ ## Complete automated result matrix
41
 
42
+ All systems received matched text within each benchmark. Lower WER is better;
43
+ higher UTMOS22 is better.
44
 
45
+ | System / voice | Complete weights ↓ | UTMOS22 ↑ | Qwen3-ASR WER ↓ | Nemotron 3.5 WER ↓ | Whisper large-v3 WER ↓ | Two-ASR consensus ↓ |
46
+ | --- | ---: | ---: | ---: | ---: | ---: | ---: |
47
+ | Inflect-Micro-v2 | 37.53 MB | **4.395** | 2.52% | 5.45% | 2.73% | **3.99%** |
48
+ | Inflect-Nano-v2 | 15.97 MB | **4.386** | 2.78% | 5.63% | 2.65% | **4.21%** |
49
+ | KittenTTS Nano · Bruno | 56.77 MB | **4.217** | 2.15% | 3.96% | 2.17% | **3.06%** |
50
+ | KittenTTS Nano · Hugo | 56.77 MB | **4.191** | 2.39% | 3.80% | 2.11% | **3.09%** |
51
+ | Piper Low · Danny | 63.10 MB | **4.195** | 2.62% | 5.60% | 2.55% | **4.11%** |
52
+ | Piper Low · Ryan | 63.10 MB | **4.289** | 2.81% | 5.51% | 2.87% | **4.16%** |
53
+ | Supertonic 3 · M2 · 8-step | 398.08 MB | **4.295** | 2.05% | 3.56% | 8.08% | **2.81%** |
54
+ | Supertonic 3 · M2 · 3-step | 398.08 MB | **2.471** | 3.03% | 6.04% | 3.22% | **4.54%** |
55
 
56
+ The two-ASR consensus is the unweighted mean of Qwen3-ASR and Nemotron 3.5
57
+ corpus-level semantic WER. Whisper remains visible but is excluded from the
58
+ headline consensus for every system because its Supertonic 8-step result
59
+ contains insertion-heavy outliers that conflict with the other recognizers and
60
+ human listening. This rule is applied globally, not selectively to Inflect.
61
+
62
+ ![Three-ASR intelligibility audit](../assets/evidence/modern400-three-asr.svg)
63
+
64
+ ## Uncertainty for the Inflect releases
65
+
66
+ Intervals use 10,000 matched-prompt bootstrap samples.
67
+
68
+ | Release | UTMOS22 mean (95% CI) | Qwen3-ASR WER (95% CI) | Nemotron WER (95% CI) | Whisper WER (95% CI) |
69
+ | --- | ---: | ---: | ---: | ---: |
70
+ | Inflect-Micro-v2 | 4.395 (4.381–4.408) | 2.52% (1.88%–3.24%) | 5.45% (4.50%–6.50%) | 2.73% (2.05%–3.49%) |
71
+ | Inflect-Nano-v2 | 4.386 (4.372–4.399) | 2.78% (2.13%–3.52%) | 5.63% (4.72%–6.62%) | 2.65% (2.03%–3.35%) |
72
+
73
+ ## Modern400 intelligibility protocol
74
+
75
+ - **400 identical unseen English prompts per system**
76
+ - **3,200 generated clips** across eight system/voice configurations
77
+ - 200 manually constructed modern and stress prompts
78
+ - 200 deterministic Google FLEURS `en_us` test prompts
79
+ - exact normalized-text exclusion against 87,362 training transcripts
80
+ - deterministic frontend and inference settings within each system
81
+ - explicit resampling to every recognizer's required sample rate
82
+ - corpus-level WER plus matched-prompt bootstrap intervals
83
+
84
+ The three independent recognizers are:
85
+
86
+ | Evaluator | Model |
87
+ | --- | --- |
88
+ | Qwen3-ASR | `Qwen/Qwen3-ASR-1.7B` |
89
+ | Nemotron 3.5 ASR | `nvidia/nemotron-3.5-asr-streaming-0.6b` |
90
+ | Whisper | `openai/whisper-large-v3` |
91
+
92
+ ### Semantic normalization
93
+
94
+ Raw orthographic WER is not sufficient for TTS. A recognizer may transcribe
95
+ “twelve point six” as `12.6` or “July twenty-first” as `July 21st` without the
96
+ audio being wrong. The semantic normalizer canonicalizes equivalent number,
97
+ currency, date, time, unit, abbreviation, and punctuation forms before scoring.
98
+ The release retains both raw and semantic hypotheses so normalization cannot
99
+ silently hide errors.
100
+
101
+ ### Where Inflect errors remain
102
+
103
+ The following diagnostic uses the same two-ASR consensus as the headline and
104
+ does not introduce a new score.
105
+
106
+ | Prompt category | Micro WER ↓ | Nano WER ↓ |
107
+ | --- | ---: | ---: |
108
+ | Names Places | 16.67% | 17.54% |
109
+ | Short | 4.29% | 9.05% |
110
+ | Rare Words | 7.89% | 7.89% |
111
+ | Numbers | 6.25% | 4.69% |
112
+ | Homographs | 3.57% | 5.71% |
113
+ | External Heldout | 5.39% | 5.48% |
114
+ | Technical | 4.10% | 3.12% |
115
+ | Narrative | 0.57% | 1.56% |
116
+ | Punctuation | 0.00% | 1.54% |
117
+ | Long Range | 0.83% | 1.24% |
118
+ | Conversational | 0.49% | 1.13% |
119
+ | Descriptive | 0.44% | 0.88% |
120
+ | Long | 0.81% | 0.58% |
121
+ | Emotional | 0.15% | 0.30% |
122
+ | Question | 0.00% | 0.00% |
123
+
124
+ ![Prompt-category semantic WER](../assets/evidence/category-semantic-wer.svg)
125
+
126
+ ## UTMOS22 predicted-naturalness protocol
127
+
128
+ - **500 identical unseen prompts per system**
129
+ - `tarepan/SpeechMOS` v1.2.0
130
+ - one score per generated clip
131
+ - mean, median, standard deviation, percentiles, extrema, and 95% bootstrap CI
132
+ - Kitten and Piper family figures use equal-weight means across their two voices
133
+
134
+ UTMOS22 is a learned non-intrusive quality predictor. It is useful for
135
+ large-scale screening but is **not human MOS**, can be sensitive to voice and
136
+ recording characteristics, and must be interpreted beside intelligibility and
137
+ listening evidence.
138
+
139
+ ## Community blind listening
140
+
141
+ The final community study stored anonymous pairwise choices rather than user
142
+ identity. Model names were hidden during voting, left/right order was
143
+ randomized, and a tie counts as half a win. The dataset contains **147 pairwise
144
+ decisions**; it does not claim a laboratory-controlled listener panel.
145
+
146
+ | System / voice | Wins | Losses | Ties | Appearances | Preference rate ↑ |
147
+ | --- | ---: | ---: | ---: | ---: | ---: |
148
+ | KittenTTS Nano · Hugo | 22 | 8 | 3 | 33 | **71.2%** |
149
+ | Inflect-Micro-v2 | 21 | 10 | 3 | 34 | **66.2%** |
150
+ | Inflect-Nano-v2 | 22 | 12 | 2 | 36 | **63.9%** |
151
+ | Supertonic 3 · James · 8-step | 16 | 12 | 3 | 31 | **56.5%** |
152
+ | KittenTTS Nano · Bruno | 16 | 13 | 7 | 36 | **54.2%** |
153
+ | Piper Low · Danny | 10 | 8 | 6 | 24 | **54.2%** |
154
+ | Piper Low · Ryan | 14 | 13 | 6 | 33 | **51.5%** |
155
+ | Inflect-Nano-v1 | 7 | 22 | 3 | 32 | **26.6%** |
156
+ | Supertonic 3 · James · 3-step | 1 | 29 | 2 | 32 | **6.2%** |
157
+
158
+ Preference rate is `(wins + 0.5 × ties) / appearances`. Unequal appearances
159
+ mean this table is descriptive; it should not be treated as a perfectly
160
+ balanced tournament or formal MOS.
161
+
162
+ ## Runtime and throughput
163
+
164
+ ### Current publication status
165
+
166
+ The previous Ryzen 9 3900X comparison is withdrawn. The host was under sustained
167
+ background saturation and the harness did not enforce the same thread policy
168
+ inside every PyTorch and ONNX runtime. Those numbers are not release evidence.
169
+
170
+ A replacement CPU benchmark must pass all of these gates before publication:
171
+
172
+ 1. named, idle host with sustained preflight load below the declared threshold;
173
+ 2. one isolated process per system;
174
+ 3. identical frozen prompt order;
175
+ 4. fixed warmup count and fixed thread budget;
176
+ 5. explicit PyTorch and ONNX intra/inter-op thread configuration;
177
+ 6. end-to-end timing including frontend and waveform generation;
178
+ 7. raw per-utterance latency, audio duration, RTF, provider, memory, and host load;
179
+ 8. repeated runs with median and dispersion, not one lucky pass.
180
+
181
+ The public runtime also collapses training-time weight normalization once,
182
+ immediately after loading the checkpoint. A fixed-seed regression test produced
183
+ bit-for-bit identical waveforms before and after this reparameterization. The
184
+ downloaded checkpoints retain **9,356,513** and **3,966,721** complete
185
+ parameters; the optimized live inference graphs contain **9,344,753** and
186
+ **3,958,801** parameters respectively. This is a deployment optimization, not
187
+ a smaller checkpoint or a changed acoustic model.
188
+
189
+ ### Retained CUDA engineering snapshot
190
+
191
+ The package retains a 50-prompt CUDA snapshot for the two Inflect releases. It
192
+ is useful for regression checking but is not a cross-system leaderboard because
193
+ the archived report does not identify the GPU model.
194
+
195
+ | Release | Prompts | RTF ↓ | Audio / wall time ↑ | Median latency | p95 latency |
196
+ | --- | ---: | ---: | ---: | ---: | ---: |
197
+ | Inflect-Micro-v2 | 50 | 0.0174 | 57.49× | 78.6 ms | 82.7 ms |
198
+ | Inflect-Nano-v2 | 50 | 0.0171 | 58.41× | 80.2 ms | 85.3 ms |
199
+
200
+ ## Complete model footprint
201
+
202
+ ![Complete model weight footprint](../assets/evidence/model-footprint.svg)
203
+
204
+ “Complete” means the downloadable weight file required for text-to-waveform
205
+ generation, including Inflect's integrated waveform decoder. Voice variants
206
+ that share identical weights are counted once in family-level footprint
207
+ figures. Package size is not the same as peak runtime memory.
208
+
209
+ ## Frozen artifacts and reproducibility
210
+
211
+ | Artifact | Purpose |
212
+ | --- | --- |
213
+ | [`evaluation/final/modern400/prompts.jsonl`](../evaluation/final/modern400/prompts.jsonl) | Frozen Modern400 prompt manifest |
214
+ | [`evaluation/final/modern400/summary.json`](../evaluation/final/modern400/summary.json) | Three-ASR summaries, intervals, and category results |
215
+ | [`evaluation/final/modern400/exclusion_report.json`](../evaluation/final/modern400/exclusion_report.json) | Exact-text training exclusion audit |
216
+ | [`evaluation/final/modern400/`](../evaluation/final/modern400/) | Compressed row-level hypotheses and scoring reports |
217
+ | [`evaluation/final/utmos22/report.json`](../evaluation/final/utmos22/report.json) | UTMOS22 clip scores and distributions |
218
+ | [`evaluation/final/runtime_snapshot/`](../evaluation/final/runtime_snapshot/) | Retained engineering snapshots |
219
+ | [`release_manifest.json`](../release_manifest.json) | File sizes and SHA-256 integrity hashes |
220
+
221
+ - Modern400 prompt SHA-256: `b7504ce2dce44a2da82770a6a5dfd2a034fe17e2113980f8a69663ade417a34c`
222
+ - UTMOS22 prompt SHA-256: `5b7aa33852e6c738eb0e1dbf9fcfcc90772b97ad219167e44aaf3917d063b056`
223
+ - Modern400 bootstrap samples: `10,000`
224
+ - UTMOS22 bootstrap samples: `10,000`
225
+
226
+ ## Interpretation limits
227
+
228
+ - ASR WER measures recognizer agreement with intended text, not naturalness.
229
+ - UTMOS22 predicts perceived quality; it is not a substitute for human MOS.
230
+ - Community preference is valuable human evidence but is not a controlled lab study.
231
+ - One fixed voice per release limits conclusions about speaker diversity.
232
+ - Runtime depends on hardware, framework, provider, compilation, thread policy, and host load.
233
+ - Results apply to these frozen checkpoints, frontends, prompts, and inference settings.
234
+ - No benchmark result should be presented as proof that one model is best for every deployment.
inference.py CHANGED
@@ -1,9 +1,12 @@
1
  from __future__ import annotations
2
 
3
  import argparse
 
 
4
  import logging
5
  import re
6
  import sys
 
7
  from pathlib import Path
8
 
9
  import numpy as np
@@ -73,17 +76,33 @@ def edge_fade(waveform: np.ndarray, sample_rate: int, milliseconds: float = 5.0)
73
  return output
74
 
75
 
 
 
 
 
 
 
 
 
 
 
76
  class InflectTTS:
77
  def __init__(self, model_dir: str | Path = PACKAGE_ROOT, device: str = "cpu") -> None:
78
  self.root = Path(model_dir).resolve()
79
  self.device = torch.device(device)
80
  self.hps = utils.get_hparams_from_file(str(self.root / "config.json"))
81
- self.model = SynthesizerTrn(
82
- len(symbols),
83
- self.hps.data.filter_length // 2 + 1,
84
- self.hps.train.segment_size // self.hps.data.hop_length,
85
- **self.hps.model,
86
- ).to(self.device).eval()
 
 
 
 
 
 
87
  root_logger = logging.getLogger()
88
  previous_level = root_logger.level
89
  try:
@@ -91,6 +110,9 @@ class InflectTTS:
91
  utils.load_checkpoint(str(self.root / "model.pth"), self.model, None)
92
  finally:
93
  root_logger.setLevel(previous_level)
 
 
 
94
  self.sample_rate = int(self.hps.data.sampling_rate)
95
 
96
  def _tokens(self, text: str) -> tuple[torch.Tensor, torch.Tensor]:
 
1
  from __future__ import annotations
2
 
3
  import argparse
4
+ import contextlib
5
+ import io
6
  import logging
7
  import re
8
  import sys
9
+ import warnings
10
  from pathlib import Path
11
 
12
  import numpy as np
 
76
  return output
77
 
78
 
79
+ def optimize_for_inference(model: SynthesizerTrn) -> None:
80
+ """Collapse training-time weight normalization without changing outputs."""
81
+ with contextlib.redirect_stdout(io.StringIO()):
82
+ model.dec.remove_weight_norm()
83
+ for flow in model.flow.flows:
84
+ encoder = getattr(flow, "enc", None)
85
+ if encoder is not None and hasattr(encoder, "remove_weight_norm"):
86
+ encoder.remove_weight_norm()
87
+
88
+
89
  class InflectTTS:
90
  def __init__(self, model_dir: str | Path = PACKAGE_ROOT, device: str = "cpu") -> None:
91
  self.root = Path(model_dir).resolve()
92
  self.device = torch.device(device)
93
  self.hps = utils.get_hparams_from_file(str(self.root / "config.json"))
94
+ with warnings.catch_warnings():
95
+ warnings.filterwarnings(
96
+ "ignore",
97
+ message="`torch.nn.utils.weight_norm` is deprecated",
98
+ category=FutureWarning,
99
+ )
100
+ self.model = SynthesizerTrn(
101
+ len(symbols),
102
+ self.hps.data.filter_length // 2 + 1,
103
+ self.hps.train.segment_size // self.hps.data.hop_length,
104
+ **self.hps.model,
105
+ ).to(self.device).eval()
106
  root_logger = logging.getLogger()
107
  previous_level = root_logger.level
108
  try:
 
110
  utils.load_checkpoint(str(self.root / "model.pth"), self.model, None)
111
  finally:
112
  root_logger.setLevel(previous_level)
113
+ self.checkpoint_parameters = sum(parameter.numel() for parameter in self.model.parameters())
114
+ optimize_for_inference(self.model)
115
+ self.deployed_parameters = sum(parameter.numel() for parameter in self.model.parameters())
116
  self.sample_rate = int(self.hps.data.sampling_rate)
117
 
118
  def _tokens(self, text: str) -> tuple[torch.Tensor, torch.Tensor]:
release_manifest.json CHANGED
@@ -89,8 +89,8 @@
89
  },
90
  {
91
  "path": "docs/EVALUATION.md",
92
- "bytes": 3246,
93
- "sha256": "4041e56250564366ff80ef9278d66bac5139d8833d368264931ba28ffbad7991"
94
  },
95
  {
96
  "path": "docs/EXPORTS.md",
@@ -264,8 +264,8 @@
264
  },
265
  {
266
  "path": "inference.py",
267
- "bytes": 6346,
268
- "sha256": "bb8b5302b16c35ee04d6729fd73caa95d1e72b2fc50420b1cdec120327f8b672"
269
  },
270
  {
271
  "path": "inflect_nano_v2_frontend.py",
@@ -294,8 +294,8 @@
294
  },
295
  {
296
  "path": "README.md",
297
- "bytes": 17214,
298
- "sha256": "52ffe98120d0f014f498378941524fb00a57a12de028cc587c6bfa90bc6a10a1"
299
  },
300
  {
301
  "path": "requirements-tested.txt",
 
89
  },
90
  {
91
  "path": "docs/EVALUATION.md",
92
+ "bytes": 11854,
93
+ "sha256": "b2aaf6f467b60d7414f4a4303e09213c382c3e73063deddb76268068dae62730"
94
  },
95
  {
96
  "path": "docs/EXPORTS.md",
 
264
  },
265
  {
266
  "path": "inference.py",
267
+ "bytes": 7311,
268
+ "sha256": "9bccc990aafa8e363a34269367a034fc69d8216f7317650be0e389bdd545eae3"
269
  },
270
  {
271
  "path": "inflect_nano_v2_frontend.py",
 
294
  },
295
  {
296
  "path": "README.md",
297
+ "bytes": 17198,
298
+ "sha256": "006177225cb135e5f376f7ac7383a93569d30639d3e555c2dfb500d84a04f7d5"
299
  },
300
  {
301
  "path": "requirements-tested.txt",