@onjmin/koe 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +440 -375
- package/dist/index.d.ts +461 -2
- package/dist/index.js +886 -11
- package/dist/index.js.map +1 -1
- package/dist/utautts/frame-intonation-v8.json +34590 -0
- package/dist/utautts/hts/COPYRIGHT.txt +30 -0
- package/dist/utautts/hts/README.md +11 -0
- package/dist/utautts/hts/tohoku-f01-neutral.htsvoice +0 -0
- package/dist/utautts/jpreprocess_wasm/jpreprocess_wasm.js +431 -0
- package/dist/utautts/jpreprocess_wasm/jpreprocess_wasm_bg.wasm +0 -0
- package/dist/utautts/jpreprocess_wasm/naist-jdic/char_def.bin.gz +0 -0
- package/dist/utautts/jpreprocess_wasm/naist-jdic/dict.da.gz +0 -0
- package/dist/utautts/jpreprocess_wasm/naist-jdic/dict.vals.gz +0 -0
- package/dist/utautts/jpreprocess_wasm/naist-jdic/dict.words.gz +0 -0
- package/dist/utautts/jpreprocess_wasm/naist-jdic/dict.wordsidx.gz +0 -0
- package/dist/utautts/jpreprocess_wasm/naist-jdic/matrix.mtx.gz +0 -0
- package/dist/utautts/jpreprocess_wasm/naist-jdic/metadata.json.gz +0 -0
- package/dist/utautts/jpreprocess_wasm/naist-jdic/unk.bin.gz +0 -0
- package/dist/utautts/utautts.wasm +0 -0
- package/dist/utautts/wasm_exec.js +575 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -401,15 +401,38 @@ interface WorldlineLoadOptions {
|
|
|
401
401
|
* function you give it once per frame.
|
|
402
402
|
*/
|
|
403
403
|
type CurveInput = number | ((tMs: number, totalMs: number) => number);
|
|
404
|
+
/**
|
|
405
|
+
* One sample placed on a phrase timeline (mirrors worldline's
|
|
406
|
+
* `PhraseSynth::AddRequest` + the UTAU `SynthRequest` fields that matter for
|
|
407
|
+
* speech). All times are ms.
|
|
408
|
+
*/
|
|
404
409
|
interface PhraseUnit {
|
|
405
410
|
pcm: Float64Array;
|
|
411
|
+
/** Where the (offset-trimmed) sample head is placed on the phrase timeline. */
|
|
406
412
|
posMs: number;
|
|
413
|
+
/** Leading part of the resampled sample to skip before `posMs`. */
|
|
407
414
|
skipMs: number;
|
|
415
|
+
/** How much of the resampled sample is used from `posMs`. */
|
|
408
416
|
lengthMs: number;
|
|
409
417
|
fadeInMs: number;
|
|
410
418
|
fadeOutMs: number;
|
|
419
|
+
/** Fixed (unstretched) consonant region of the sample. */
|
|
411
420
|
consonantMs: number;
|
|
421
|
+
/** Trim from the sample tail; defaults to two WORLD frames. */
|
|
412
422
|
cutMs?: number;
|
|
423
|
+
/**
|
|
424
|
+
* UTAU "required length": the resampler stretches the sample to this total
|
|
425
|
+
* length (consonant kept, vowel stretched). Defaults to `lengthMs`. UtauTTS
|
|
426
|
+
* rounds it up to 50 ms steps so the vowel loop has slack for the release.
|
|
427
|
+
*/
|
|
428
|
+
requiredLengthMs?: number;
|
|
429
|
+
/** UTAU volume, 100 = unity. */
|
|
430
|
+
volume?: number;
|
|
431
|
+
/**
|
|
432
|
+
* MIDI note the resampler targets before the F0 curve is applied. Pick the
|
|
433
|
+
* note closest to the sample's own pitch to keep the formant shift minimal.
|
|
434
|
+
*/
|
|
435
|
+
tone?: number;
|
|
413
436
|
}
|
|
414
437
|
interface RenderPhraseParams {
|
|
415
438
|
units: PhraseUnit[];
|
|
@@ -574,7 +597,7 @@ interface Frames {
|
|
|
574
597
|
peakDb: number;
|
|
575
598
|
}
|
|
576
599
|
/** Extract every feature the mora estimator needs from one mono signal. */
|
|
577
|
-
declare function analyze(wav: WavData): Frames;
|
|
600
|
+
declare function analyze$1(wav: WavData): Frames;
|
|
578
601
|
/** Convenience wrapper: decode a WAV buffer and analyse it. */
|
|
579
602
|
declare function analyzeWav(buf: ArrayBuffer): Frames;
|
|
580
603
|
|
|
@@ -830,4 +853,440 @@ declare function formatOto(entries: readonly OtoEntry[]): string;
|
|
|
830
853
|
/** Render entries as Shift-JIS oto.ini bytes, ready to write to disk. */
|
|
831
854
|
declare function encodeOto(entries: readonly OtoEntry[]): Uint8Array;
|
|
832
855
|
|
|
833
|
-
|
|
856
|
+
/**
|
|
857
|
+
* Asset loading for the TTS stack: the Go UtauTTS wasm (~10 MB), the
|
|
858
|
+
* jpreprocess wasm (~2 MB) and its naist-jdic dictionary (~29 MB gzipped,
|
|
859
|
+
* ~80 MB inflated) and the TCN prosody model (~1 MB).
|
|
860
|
+
*
|
|
861
|
+
* Everything goes through {@link fetchAsset}, which streams the download with
|
|
862
|
+
* progress callbacks and stores the raw response in the Cache API so the second
|
|
863
|
+
* visit skips the network entirely (the browser HTTP cache alone is not
|
|
864
|
+
* reliable for files this size).
|
|
865
|
+
*/
|
|
866
|
+
interface AssetProgress {
|
|
867
|
+
url: string;
|
|
868
|
+
/** Bytes received so far (compressed bytes for gzipped files). */
|
|
869
|
+
loaded: number;
|
|
870
|
+
/** Total bytes when the server sent Content-Length, otherwise 0. */
|
|
871
|
+
total: number;
|
|
872
|
+
/** True when served from the Cache API (no network). */
|
|
873
|
+
fromCache: boolean;
|
|
874
|
+
}
|
|
875
|
+
interface AssetFetchOptions {
|
|
876
|
+
/**
|
|
877
|
+
* Cache API bucket name. `null` disables caching. Defaults to
|
|
878
|
+
* `"koe-tts-assets-v1"`.
|
|
879
|
+
*/
|
|
880
|
+
cacheName?: string | null;
|
|
881
|
+
onProgress?: (progress: AssetProgress) => void;
|
|
882
|
+
signal?: AbortSignal;
|
|
883
|
+
/**
|
|
884
|
+
* Check the cached copy against the server with a HEAD request (ETag,
|
|
885
|
+
* Last-Modified or Content-Length) so a redeployed asset is refetched.
|
|
886
|
+
* Offline or on error the cached copy is used. Default true.
|
|
887
|
+
*/
|
|
888
|
+
revalidate?: boolean;
|
|
889
|
+
}
|
|
890
|
+
/**
|
|
891
|
+
* Fetch a static asset with download progress, backed by the Cache API.
|
|
892
|
+
*
|
|
893
|
+
* The returned Response has a fully buffered body, so it can be handed to
|
|
894
|
+
* `WebAssembly.instantiateStreaming` / wasm-bindgen `init()` as-is.
|
|
895
|
+
*/
|
|
896
|
+
declare function fetchAsset(url: string, options?: AssetFetchOptions): Promise<Response>;
|
|
897
|
+
/** {@link fetchAsset} and return the body bytes. */
|
|
898
|
+
declare function fetchAssetBytes(url: string, options?: AssetFetchOptions): Promise<Uint8Array>;
|
|
899
|
+
/** {@link fetchAsset} and return the body as text. */
|
|
900
|
+
declare function fetchAssetText(url: string, options?: AssetFetchOptions): Promise<string>;
|
|
901
|
+
/** The naist-jdic files produced by jpreprocess's dictionary build, in `init_dictionary` order. */
|
|
902
|
+
declare const NAIST_JDIC_FILES: readonly ["metadata.json", "char_def.bin", "matrix.mtx", "dict.da", "dict.vals", "unk.bin", "dict.wordsidx", "dict.words"];
|
|
903
|
+
type NaistJdicFile = (typeof NAIST_JDIC_FILES)[number];
|
|
904
|
+
type NaistJdicData = Record<NaistJdicFile, Uint8Array>;
|
|
905
|
+
/** The subset of the wasm-bindgen module surface used by koe. */
|
|
906
|
+
interface JpreprocessModule {
|
|
907
|
+
init_dictionary(metadata: Uint8Array, charDef: Uint8Array, matrix: Uint8Array, dictDa: Uint8Array, dictVals: Uint8Array, unk: Uint8Array, wordsIdx: Uint8Array, words: Uint8Array): void;
|
|
908
|
+
analyze_text(text: string): string;
|
|
909
|
+
is_ready(): boolean;
|
|
910
|
+
/** Load an HTS voice (.htsvoice bytes) for `analyze_prosody`. */
|
|
911
|
+
init_voice?(htsvoice: Uint8Array): void;
|
|
912
|
+
is_voice_ready?(): boolean;
|
|
913
|
+
/** HTS phoneme durations + F0 for the text (JSON, see `HtsProsodyFrames`). */
|
|
914
|
+
analyze_prosody?(text: string, speed: number): string;
|
|
915
|
+
}
|
|
916
|
+
interface LoadNaistJdicOptions extends AssetFetchOptions {
|
|
917
|
+
/** Files are `<name>.gz` and inflated in the browser. Default true. */
|
|
918
|
+
compressed?: boolean;
|
|
919
|
+
}
|
|
920
|
+
/**
|
|
921
|
+
* Download (or read from the Cache API) the naist-jdic dictionary files for
|
|
922
|
+
* jpreprocess. `baseUrl` is the directory holding `dict.da.gz` etc.
|
|
923
|
+
*
|
|
924
|
+
* Progress is reported per file via `onProgress`; sum `loaded`/`total` across
|
|
925
|
+
* the {@link NAIST_JDIC_FILES} URLs for an aggregate bar.
|
|
926
|
+
*/
|
|
927
|
+
declare function loadNaistJdic(baseUrl: string, options?: LoadNaistJdicOptions): Promise<NaistJdicData>;
|
|
928
|
+
/** Hand the loaded dictionary to the jpreprocess wasm module (once per page). */
|
|
929
|
+
declare function initJpreprocessDictionary(module: JpreprocessModule, data: NaistJdicData): void;
|
|
930
|
+
|
|
931
|
+
interface NjdNode {
|
|
932
|
+
string: string;
|
|
933
|
+
pos: string;
|
|
934
|
+
pos_group1: string;
|
|
935
|
+
pron: string;
|
|
936
|
+
read: string;
|
|
937
|
+
acc: number;
|
|
938
|
+
mora_size: number;
|
|
939
|
+
chain_flag: number;
|
|
940
|
+
}
|
|
941
|
+
interface FeatureFrame {
|
|
942
|
+
mora: string;
|
|
943
|
+
pause: boolean;
|
|
944
|
+
accent_phrase_position?: number;
|
|
945
|
+
accent_phrase_length?: number;
|
|
946
|
+
accent_nucleus?: number;
|
|
947
|
+
accent_high?: boolean;
|
|
948
|
+
accent_phrase_start?: boolean;
|
|
949
|
+
accent_phrase_end?: boolean;
|
|
950
|
+
word_start?: boolean;
|
|
951
|
+
word_end?: boolean;
|
|
952
|
+
pos?: string;
|
|
953
|
+
pos_group1?: string;
|
|
954
|
+
}
|
|
955
|
+
declare function analyze(nodes: NjdNode[]): {
|
|
956
|
+
reading: string;
|
|
957
|
+
features: FeatureFrame[];
|
|
958
|
+
};
|
|
959
|
+
declare function sparse_features(token: FeatureFrame): Record<string, number>;
|
|
960
|
+
|
|
961
|
+
/**
|
|
962
|
+
* Prosody transplant from an HTS voice (Open JTalk's statistical model, run by
|
|
963
|
+
* jbonsai inside the jpreprocess wasm): HTS decides *how long* each mora is and
|
|
964
|
+
* *what pitch contour* the sentence has; the UTAU voice bank only supplies the
|
|
965
|
+
* timbre. This is the same division of labour as Cantari (VOICEVOX prosody +
|
|
966
|
+
* worldline) but with a 1-2 MB model that runs in the browser.
|
|
967
|
+
*/
|
|
968
|
+
/** One phoneme of the HTS timeline (`analyze_prosody` output). */
|
|
969
|
+
interface HtsPhoneme {
|
|
970
|
+
phone: string;
|
|
971
|
+
start_ms: number;
|
|
972
|
+
duration_ms: number;
|
|
973
|
+
}
|
|
974
|
+
/** Raw `analyze_prosody` result. */
|
|
975
|
+
interface HtsProsodyFrames {
|
|
976
|
+
frame_ms: number;
|
|
977
|
+
sample_rate: number;
|
|
978
|
+
phonemes: HtsPhoneme[];
|
|
979
|
+
/** F0 in Hz per frame; 0 = unvoiced. */
|
|
980
|
+
f0_hz: number[];
|
|
981
|
+
}
|
|
982
|
+
/** HTS prosody aligned to the UtauTTS mora sequence, ready for `plan()`. */
|
|
983
|
+
interface HtsProsody {
|
|
984
|
+
/** Per feature-frame (mora or pause) duration in ms, same order as the features. */
|
|
985
|
+
moraDurationsMs: number[];
|
|
986
|
+
/** Cents relative to the speaker median, on the plan time axis (0 = first mora onset). */
|
|
987
|
+
pitchCurve: {
|
|
988
|
+
frame_ms: number;
|
|
989
|
+
cents: number[];
|
|
990
|
+
};
|
|
991
|
+
/** Median voiced F0 of the HTS utterance in Hz. */
|
|
992
|
+
medianHz: number;
|
|
993
|
+
/** Total planned duration in ms (sum of `moraDurationsMs`). */
|
|
994
|
+
durationMs: number;
|
|
995
|
+
/**
|
|
996
|
+
* Per feature-frame flag: HTS predicted the mora nucleus as a devoiced vowel
|
|
997
|
+
* (Open JTalk's upper-case `I`/`U`, e.g. the "su" in "desu"). Pauses are false.
|
|
998
|
+
*/
|
|
999
|
+
devoiced: boolean[];
|
|
1000
|
+
/**
|
|
1001
|
+
* Optional per feature-frame linear gain (1 = unity) applied to the units of
|
|
1002
|
+
* that mora on top of UtauTTS's own volume; filled by `shapeProsody`.
|
|
1003
|
+
*/
|
|
1004
|
+
moraGains?: number[];
|
|
1005
|
+
}
|
|
1006
|
+
interface AlignHtsOptions {
|
|
1007
|
+
/** Multiplier on the cents curve. 1 = HTS as-is. Default 1. */
|
|
1008
|
+
intonationStrength?: number;
|
|
1009
|
+
/** Output frame period for the pitch curve in ms. Default 10 (worldline's frame). */
|
|
1010
|
+
frameMs?: number;
|
|
1011
|
+
/** Pause length used when the features have a pause HTS did not produce. Default 150. */
|
|
1012
|
+
fallbackPauseMs?: number;
|
|
1013
|
+
/**
|
|
1014
|
+
* Soft limit for the cents curve: excursions beyond `kneeCents` are halved,
|
|
1015
|
+
* then hard-clamped at `maxCents`. HTS voices end phrases with a creaky
|
|
1016
|
+
* drop of close to an octave, which WORLD resynthesis of a singing sample
|
|
1017
|
+
* cannot follow cleanly. Defaults: knee 400, max 700.
|
|
1018
|
+
*/
|
|
1019
|
+
kneeCents?: number;
|
|
1020
|
+
maxCents?: number;
|
|
1021
|
+
}
|
|
1022
|
+
/**
|
|
1023
|
+
* Align HTS phoneme timing and F0 to the mora/pause sequence in `features`
|
|
1024
|
+
* (from `openjtalkAnalyze`). Returns null when the two mora sequences cannot
|
|
1025
|
+
* be matched, in which case the caller should fall back to the TCN contour.
|
|
1026
|
+
*/
|
|
1027
|
+
declare function alignHtsProsody(frames: HtsProsodyFrames, features: FeatureFrame[], options?: AlignHtsOptions): HtsProsody | null;
|
|
1028
|
+
|
|
1029
|
+
/**
|
|
1030
|
+
* Rule-based residuals on top of the HTS prosody (a cut-down Fujisaki-style
|
|
1031
|
+
* layer): the statistical model gives the accent shape, these rules add what
|
|
1032
|
+
* the HTS voices were not trained for and what a concatenative voice bank
|
|
1033
|
+
* lacks on its own.
|
|
1034
|
+
*
|
|
1035
|
+
* - question rise: a sentence ending in 「?」 gets at least a minimum rise
|
|
1036
|
+
* on its last mora; Open JTalk's interrogative label flag already makes
|
|
1037
|
+
* tohoku-f01 rise, so this only tops up voices/sentences that do not
|
|
1038
|
+
* - energy envelope: loudness follows pitch (accented morae louder, phrase
|
|
1039
|
+
* ends softer), which a plain unit concatenation renders flat
|
|
1040
|
+
* - devoiced vowels: morae HTS predicted as devoiced (「です」「ます」…) are
|
|
1041
|
+
* attenuated so the voiced sample does not shout a vowel the speaker
|
|
1042
|
+
* would whisper
|
|
1043
|
+
*
|
|
1044
|
+
* Zero assets, negligible compute; everything is mora-level arithmetic.
|
|
1045
|
+
*/
|
|
1046
|
+
interface ShapeProsodyOptions {
|
|
1047
|
+
/** Treat the utterance as a question (see {@link isQuestion}). Default false. */
|
|
1048
|
+
question?: boolean;
|
|
1049
|
+
/**
|
|
1050
|
+
* Minimum rise across the final mora of a question, in cents. Open JTalk
|
|
1051
|
+
* labels carry an interrogative flag and HTS voices trained with it (e.g.
|
|
1052
|
+
* tohoku-f01) already rise; the rule only tops up whatever is missing, so
|
|
1053
|
+
* it is a safety net for voices/sentences where the rise does not appear.
|
|
1054
|
+
* Default 350.
|
|
1055
|
+
*/
|
|
1056
|
+
questionRiseCents?: number;
|
|
1057
|
+
/**
|
|
1058
|
+
* Loudness coupling: dB per 100 cents of pitch relative to the speaker
|
|
1059
|
+
* median. 0 disables the energy envelope. Default 0.5 (≈ +2 dB at +400 cent).
|
|
1060
|
+
*/
|
|
1061
|
+
energyDbPerSemitone?: number;
|
|
1062
|
+
/** Linear gain for morae with a devoiced nucleus. Default 0.5 (−6 dB). */
|
|
1063
|
+
devoicedGain?: number;
|
|
1064
|
+
/** Clamp for the per-mora gain. Defaults 0.35 … 1.8. */
|
|
1065
|
+
minGain?: number;
|
|
1066
|
+
maxGain?: number;
|
|
1067
|
+
}
|
|
1068
|
+
/** True when the text ends with a question mark (「?」 or "?"), ignoring closing quotes. */
|
|
1069
|
+
declare function isQuestion(text: string): boolean;
|
|
1070
|
+
/**
|
|
1071
|
+
* Apply the residual rules to an aligned HTS prosody. Returns a new object;
|
|
1072
|
+
* `prosody` is not modified. Pass the result to `plan({ prosody })`: the pitch
|
|
1073
|
+
* curve carries the question rise, `moraGains` the energy envelope.
|
|
1074
|
+
*/
|
|
1075
|
+
declare function shapeProsody(prosody: HtsProsody, features: FeatureFrame[], options?: ShapeProsodyOptions): HtsProsody;
|
|
1076
|
+
|
|
1077
|
+
/** One unit of the UtauTTS synthesis plan (`internal/plan.Unit`). */
|
|
1078
|
+
interface UtauTTSUnit {
|
|
1079
|
+
position: number;
|
|
1080
|
+
role: string;
|
|
1081
|
+
mora: string;
|
|
1082
|
+
alias: string;
|
|
1083
|
+
note_start_ms: number;
|
|
1084
|
+
duration_ms: number;
|
|
1085
|
+
offset_ms: number;
|
|
1086
|
+
consonant_ms: number;
|
|
1087
|
+
cutoff_ms: number;
|
|
1088
|
+
preutterance_ms: number;
|
|
1089
|
+
overlap_ms: number;
|
|
1090
|
+
silent?: boolean;
|
|
1091
|
+
pitch_factor: number;
|
|
1092
|
+
energy_factor: number;
|
|
1093
|
+
effective_preutterance_ms: number;
|
|
1094
|
+
effective_consonant_ms: number;
|
|
1095
|
+
effective_overlap_ms: number;
|
|
1096
|
+
source_f0_hz?: number;
|
|
1097
|
+
target_f0_hz?: number;
|
|
1098
|
+
[extra: string]: unknown;
|
|
1099
|
+
}
|
|
1100
|
+
/** Placement of one unit on the worldline phrase timeline (`render.WorldlineTimelineUnit`). */
|
|
1101
|
+
interface UtauTTSTimelineUnit {
|
|
1102
|
+
index: number;
|
|
1103
|
+
position: number;
|
|
1104
|
+
role: string;
|
|
1105
|
+
mora: string;
|
|
1106
|
+
alias: string;
|
|
1107
|
+
note_start_ms: number;
|
|
1108
|
+
duration_ms: number;
|
|
1109
|
+
position_ms: number;
|
|
1110
|
+
skip_ms: number;
|
|
1111
|
+
length_ms: number;
|
|
1112
|
+
fade_in_ms: number;
|
|
1113
|
+
fade_out_ms: number;
|
|
1114
|
+
offset_ms: number;
|
|
1115
|
+
required_length_ms: number;
|
|
1116
|
+
consonant_ms: number;
|
|
1117
|
+
cutoff_ms: number;
|
|
1118
|
+
tone: number;
|
|
1119
|
+
consonant_velocity: number;
|
|
1120
|
+
volume: number;
|
|
1121
|
+
energy_factor: number;
|
|
1122
|
+
source_f0_hz: number;
|
|
1123
|
+
target_f0_hz: number;
|
|
1124
|
+
envelope?: {
|
|
1125
|
+
x_ms: number;
|
|
1126
|
+
y: number;
|
|
1127
|
+
}[];
|
|
1128
|
+
}
|
|
1129
|
+
/** Whole-phrase placement + F0 curve (`render.WorldlineTimeline`). */
|
|
1130
|
+
interface UtauTTSTimeline {
|
|
1131
|
+
frame_ms: number;
|
|
1132
|
+
leading_ms: number;
|
|
1133
|
+
/** Timeline length in ms (plan duration + release + leading margin). */
|
|
1134
|
+
duration_ms: number;
|
|
1135
|
+
reference_hz: number;
|
|
1136
|
+
/** Target F0 in Hz per `frame_ms` frame, starting at timeline 0. */
|
|
1137
|
+
f0_curve: number[];
|
|
1138
|
+
units: UtauTTSTimelineUnit[];
|
|
1139
|
+
}
|
|
1140
|
+
interface UtauTTSPlan {
|
|
1141
|
+
reading: string;
|
|
1142
|
+
language: string;
|
|
1143
|
+
morae: {
|
|
1144
|
+
Text: string;
|
|
1145
|
+
Consonant: string;
|
|
1146
|
+
Vowel: string;
|
|
1147
|
+
Pause: boolean;
|
|
1148
|
+
}[];
|
|
1149
|
+
plan: {
|
|
1150
|
+
duration_ms: number;
|
|
1151
|
+
single_cv?: boolean;
|
|
1152
|
+
leading_margin_ms?: number;
|
|
1153
|
+
units: UtauTTSUnit[];
|
|
1154
|
+
[extra: string]: unknown;
|
|
1155
|
+
};
|
|
1156
|
+
/** Frame pitch curve in cents relative to each unit's own pitch (plan time base). */
|
|
1157
|
+
pitch_curve?: {
|
|
1158
|
+
frame_ms: number;
|
|
1159
|
+
cents: number[];
|
|
1160
|
+
};
|
|
1161
|
+
mora_timings: {
|
|
1162
|
+
StartMS: number;
|
|
1163
|
+
DurationMS: number;
|
|
1164
|
+
}[];
|
|
1165
|
+
timeline: UtauTTSTimeline;
|
|
1166
|
+
/** @deprecated use `plan.duration_ms` */
|
|
1167
|
+
duration_ms: number;
|
|
1168
|
+
/** @deprecated use `plan.units` */
|
|
1169
|
+
units: UtauTTSUnit[];
|
|
1170
|
+
/** @deprecated use `pitch_curve` */
|
|
1171
|
+
pitch_cents?: number[];
|
|
1172
|
+
/** @deprecated use `pitch_curve` */
|
|
1173
|
+
pitch_frame_ms?: number;
|
|
1174
|
+
}
|
|
1175
|
+
/** Synthesis parameters, same meaning and defaults as `utautts-cli` / the UtauTTS GUI. */
|
|
1176
|
+
interface UtauTTSOptions {
|
|
1177
|
+
/** Voicebank tone for prefix.map lookups. Default "C4". */
|
|
1178
|
+
tone?: string;
|
|
1179
|
+
/** Base mora length in ms (0 = UtauTTS default 140). */
|
|
1180
|
+
moraDurationMs?: number;
|
|
1181
|
+
/** Pause length for punctuation in ms (0 = UtauTTS default 180). */
|
|
1182
|
+
pauseDurationMs?: number;
|
|
1183
|
+
/** Release envelope in ms. Default 20. */
|
|
1184
|
+
releaseMs?: number;
|
|
1185
|
+
/** Cap on the leading preutterance margin before the first mora (0 = no cap). */
|
|
1186
|
+
leadingPreutteranceMs?: number;
|
|
1187
|
+
/** Apply the TCN frame pitch contour and source pitch stabilisation. Default true. */
|
|
1188
|
+
applyPitch?: boolean;
|
|
1189
|
+
/** Contour strength 0..4. Default 1. */
|
|
1190
|
+
intonationStrength?: number;
|
|
1191
|
+
/** UtauTTS experimental speech timing (voicebank calibration). Default false. */
|
|
1192
|
+
speechTiming?: boolean;
|
|
1193
|
+
wordBoundaryEnvelope?: boolean;
|
|
1194
|
+
/**
|
|
1195
|
+
* External prosody (mora durations + cents curve) from `alignHtsProsody`.
|
|
1196
|
+
* When set, UtauTTS uses these instead of its own durations and TCN contour;
|
|
1197
|
+
* `intonationStrength` is applied by `alignHtsProsody`, not here.
|
|
1198
|
+
*/
|
|
1199
|
+
prosody?: HtsProsody;
|
|
1200
|
+
}
|
|
1201
|
+
/** One rendered piece of audio. Sum overlapping chunks: seams are equal-power crossfades. */
|
|
1202
|
+
interface UtauTTSChunk {
|
|
1203
|
+
/** Float32 PCM at 48 kHz. */
|
|
1204
|
+
pcm: Float32Array;
|
|
1205
|
+
/** Where the chunk starts on the timeline (ms from timeline 0). */
|
|
1206
|
+
startMs: number;
|
|
1207
|
+
index: number;
|
|
1208
|
+
/** Timeline units rendered into this chunk (context units for seams excluded). */
|
|
1209
|
+
units: UtauTTSTimelineUnit[];
|
|
1210
|
+
}
|
|
1211
|
+
interface UtauTTSRenderOptions {
|
|
1212
|
+
/** Units in the first chunk (small → audio starts sooner). Default 3. */
|
|
1213
|
+
firstChunkUnits?: number;
|
|
1214
|
+
/** Units per later chunk. Default 6. */
|
|
1215
|
+
chunkUnits?: number;
|
|
1216
|
+
/** Crossfade length at a mid-phrase seam in ms. Default 20. */
|
|
1217
|
+
seamCrossfadeMs?: number;
|
|
1218
|
+
signal?: AbortSignal;
|
|
1219
|
+
gender?: number;
|
|
1220
|
+
tension?: number;
|
|
1221
|
+
breathiness?: number;
|
|
1222
|
+
voicing?: number;
|
|
1223
|
+
}
|
|
1224
|
+
/**
|
|
1225
|
+
* Build the kana reading UtauTTS parses from the jpreprocess token features,
|
|
1226
|
+
* so the mora sequence and the feature frames line up 1:1 by construction.
|
|
1227
|
+
*/
|
|
1228
|
+
declare function readingFromFeatures(features: FeatureFrame[]): string;
|
|
1229
|
+
/**
|
|
1230
|
+
* Text-to-speech with UtauTTS's planner (Go wasm) and koe's worldline renderer.
|
|
1231
|
+
*
|
|
1232
|
+
* Pipeline per utterance:
|
|
1233
|
+
* 1. jpreprocess (caller) → NJD nodes → {@link FeatureFrame}s via `openjtalkAnalyze`
|
|
1234
|
+
* 2. {@link plan}: UtauTTS resolves units (Viterbi), builds the timing plan,
|
|
1235
|
+
* predicts the TCN pitch contour and lays the units on the worldline timeline
|
|
1236
|
+
* exactly as its native worldline bridge would
|
|
1237
|
+
* 3. {@link renderChunks}: worldline renders the timeline in small chunks so
|
|
1238
|
+
* playback can start after the first few morae
|
|
1239
|
+
*
|
|
1240
|
+
* Load order: `initializeWasm()` once per page, `setModel()` once per model,
|
|
1241
|
+
* `setBank()` once per voice bank.
|
|
1242
|
+
*/
|
|
1243
|
+
declare class UtauTTSAdapter {
|
|
1244
|
+
private worldline;
|
|
1245
|
+
private static modelId;
|
|
1246
|
+
private bankAliases;
|
|
1247
|
+
private currentBank;
|
|
1248
|
+
private pcmCache;
|
|
1249
|
+
constructor(worldline: Worldline);
|
|
1250
|
+
/**
|
|
1251
|
+
* Load the UtauTTS Go wasm. `wasm_exec.js` must already be on the page.
|
|
1252
|
+
* Pass `fetch` (e.g. koe's `fetchAsset`) to stream from the Cache API.
|
|
1253
|
+
*/
|
|
1254
|
+
static initializeWasm(wasmUrl?: string, options?: {
|
|
1255
|
+
fetch?: (url: string) => Promise<Response>;
|
|
1256
|
+
}): Promise<void>;
|
|
1257
|
+
static get ready(): boolean;
|
|
1258
|
+
/** Parse and cache a prosody model (e.g. `frame-intonation-v8.json`) inside the wasm. */
|
|
1259
|
+
static setModel(modelJSON: string): string | null;
|
|
1260
|
+
static get currentModelId(): string | null;
|
|
1261
|
+
private static assertReady;
|
|
1262
|
+
/**
|
|
1263
|
+
* Register a koe voice bank with the planner: the manifest becomes a virtual
|
|
1264
|
+
* oto.ini (koe PCM is pre-trimmed, so offset is 0) plus each sample's
|
|
1265
|
+
* recorded pitch. Called automatically by {@link plan}; cheap when unchanged.
|
|
1266
|
+
*/
|
|
1267
|
+
setBank(bank: VoiceBank): void;
|
|
1268
|
+
/**
|
|
1269
|
+
* Plan an utterance: unit selection, timing, pitch contour and worldline
|
|
1270
|
+
* placement. `features` are the mora-level frames from `openjtalkAnalyze`
|
|
1271
|
+
* (pauses included); the kana reading is derived from them.
|
|
1272
|
+
*/
|
|
1273
|
+
plan(bank: VoiceBank, text: string, features: FeatureFrame[], options?: UtauTTSOptions): UtauTTSPlan;
|
|
1274
|
+
private getPcm;
|
|
1275
|
+
/**
|
|
1276
|
+
* Render a plan chunk by chunk. Each chunk is independent audio positioned
|
|
1277
|
+
* at `startMs`; schedule them as they arrive (see the demo) or sum them.
|
|
1278
|
+
*
|
|
1279
|
+
* Chunk breaks fall on pauses when possible. Inside a phrase a break renders
|
|
1280
|
+
* one neighbouring unit of context on each side so the unit crossfade stays
|
|
1281
|
+
* WORLD's spectral one, then the two renders are joined with a short
|
|
1282
|
+
* equal-power crossfade in the following vowel.
|
|
1283
|
+
*/
|
|
1284
|
+
renderChunks(bank: VoiceBank, plan: UtauTTSPlan, options?: UtauTTSRenderOptions): AsyncGenerator<UtauTTSChunk>;
|
|
1285
|
+
/**
|
|
1286
|
+
* Plan + render an utterance into one buffer (Float32, 48 kHz) covering the
|
|
1287
|
+
* whole timeline. Use {@link plan} + {@link renderChunks} for streaming.
|
|
1288
|
+
*/
|
|
1289
|
+
synthesizeText(bank: VoiceBank, text: string, features: FeatureFrame[], options?: UtauTTSOptions & UtauTTSRenderOptions): Promise<Float32Array | null>;
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
export { type AlignHtsOptions, type AssetFetchOptions, type AssetProgress, type ConsonantClass, type FeatureFrame, type FileResult, type Frames, type FrqData, type GenerateOptions, type GenerateResult, type Grid, type HtsPhoneme, type HtsProsody, type HtsProsodyFrames, type JpreprocessModule, KoeEngine, type KoeEngineOptions, MIN_WORLDLINE_SAMPLES, type Manifest, type MoraPosition, NAIST_JDIC_FILES, type NaistJdicData, type NjdNode, type NoteEvent, type OtoEntry, type PackInput, type PackOutput, type PhonemeEntry, type PlayOptions, type RenderNoteParams, type ShapeProsodyOptions, type SkippedFile, type Syllable, type TrimmedPhoneme, UtauTTSAdapter, type UtauTTSChunk, type UtauTTSOptions, type UtauTTSPlan, type UtauTTSRenderOptions, type UtauTTSTimeline, type UtauTTSTimelineUnit, type UtauTTSUnit, VoiceBank, WORLDLINE_SAMPLE_RATE, type WavData, type WavInput, Worldline, type WorldlineLoadOptions, type ZipFile, alignHtsProsody, analyze$1 as analyze, analyzeWav, detectF0, detectGrid, encodeOto, encodeShiftJis, estimateSequence, estimateSolo, estimateVowelJoin, fetchAsset, fetchAssetBytes, fetchAssetText, formatOto, frqAverageF0InRange, frqFileName, generateOto, generateOtoForFile, initJpreprocessDictionary, isQuestion, leadInFromEntry, loadNaistJdic, locateMora, normalizePcm, noteNameToHz, analyze as openjtalkAnalyze, otoRegion, pack, packKoe, parseFrq, parseFrqAverageF0, parseKoeHeader, parseOto, parseWav, pcmBase, pitchFromAliasSuffix, readWavPcm48k, readingFromFeatures, resample, samplesToMs, shapeProsody, sparse_features, splitKana, suffixFromFolderName, summarise, toHiragana, toInt16, toMono, transcribe, trimToOto, unzipToFileMap, zipFiles };
|