@handsforbots/voice-effects 0.0.0-stage → 2.0.0-alpha.1

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/LICENSE.md ADDED
@@ -0,0 +1,9 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright © 2024 Alex Lana and Hands for Bots contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,23 @@
1
- # Temporary Holding Version
1
+ # @handsforbots/voice-effects
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Standalone. Declarative effects for synthesized speech: a JSON chain in Web Audio terms, parameters described like Web Audio Modules, SSML prosody, presets, offline rendering and export to FFmpeg filtergraphs and SSML.
4
+
5
+ Part of [Hands for Bots](https://github.com/handsforbots/handsforbots), a headless multimodal and action layer between users, GUIs and agents.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @handsforbots/voice-effects@alpha
11
+ ```
12
+
13
+ Optional: `@handsforbots/voice` (types only; chains, SSML and FFmpeg export work without it).
14
+
15
+ ## Documentation
16
+
17
+ - [This package](https://github.com/handsforbots/handsforbots/blob/main/docs/en-us/plugins.md#voice-effects)
18
+ - [Getting started](https://github.com/handsforbots/handsforbots/blob/main/docs/en-us/getting-started.md)
19
+ - [Documentação em português](https://github.com/handsforbots/handsforbots/blob/main/docs/pt-br/README.md)
20
+
21
+ ## License
22
+
23
+ MIT
@@ -0,0 +1,53 @@
1
+ import type { EffectsInstance, Prosody, SpeechAudio, SpeechEffects } from '@handsforbots/voice';
2
+ import { type PresetName } from './presets.js';
3
+ import type { EffectChain, EffectDefinition, EffectParams, EffectSpec } from './types.js';
4
+ export type Registry = ReadonlyMap<string, EffectDefinition>;
5
+ export declare const createRegistry: (extra?: EffectDefinition[]) => Registry;
6
+ /** Problems with a chain, as readable sentences (empty = valid). */
7
+ export declare function validateChain(chain: unknown, registry?: Registry): string[];
8
+ /** Every parameter of an effect, with defaults filled in and integers rounded. */
9
+ export declare function paramsOf(spec: EffectSpec, definition: EffectDefinition): EffectParams;
10
+ export type ResolvedEffect = {
11
+ spec: EffectSpec;
12
+ definition: EffectDefinition;
13
+ params: EffectParams;
14
+ };
15
+ /** The effects that apply (not bypassed), with their parameters. */
16
+ export declare function activeEffects(chain: EffectChain, registry: Registry): ResolvedEffect[];
17
+ /** Runs the sample-level effects (`process`) in order. */
18
+ export declare function processSamples(audio: SpeechAudio, effects: ResolvedEffect[]): SpeechAudio;
19
+ /** Builds the Web Audio graph of the chain after `source`. */
20
+ export declare function connectEffects(context: BaseAudioContext, source: AudioBufferSourceNode, effects: ResolvedEffect[]): EffectsInstance;
21
+ export type RenderOptions = {
22
+ /** Offline context factory (tests, or a worker without the global). Default `new OfflineAudioContext(...)`. */
23
+ createContext?: (length: number, sampleRate: number) => OfflineAudioContext;
24
+ /** Playback rate before the effects (the pitch part of the prosody, as the voice player applies it). */
25
+ playbackRate?: number;
26
+ };
27
+ /** Renders `audio` through the chain, offline, tails included. */
28
+ export declare function renderEffects(audio: SpeechAudio, effects: ResolvedEffect[], options?: RenderOptions): Promise<SpeechAudio>;
29
+ export type VoiceEffectsOptions = {
30
+ /** Your own effect types, next to the built-in ones. */
31
+ effects?: EffectDefinition[];
32
+ };
33
+ /** A live chain: plug it into `voice({ effects })` and change it while the bot talks. */
34
+ export type VoiceEffects = SpeechEffects & {
35
+ /** A copy of the chain. */
36
+ get(): EffectChain;
37
+ /** Replaces the chain (or loads a preset by name). Throws on an invalid chain. */
38
+ set(chain: EffectChain | PresetName): void;
39
+ /** Changes one effect, by index or `id`: parameters, `bypass`. Throws on invalid values. */
40
+ update(target: number | string, patch: Partial<EffectSpec>): void;
41
+ /** Changes the prosody. */
42
+ setProsody(prosody: Prosody): void;
43
+ /** Called after every change. */
44
+ subscribe(listener: () => void): () => void;
45
+ /** The effect types this chain understands (for editors). */
46
+ definitions(): EffectDefinition[];
47
+ /** Renders audio through the chain, offline (to save or to pre-generate fixed lines). */
48
+ render(audio: SpeechAudio, options?: RenderOptions): Promise<SpeechAudio>;
49
+ };
50
+ export declare function resolveChain(chain: EffectChain | PresetName): EffectChain;
51
+ /** A chain of effects for synthesized speech, from JSON or a preset name. */
52
+ export declare function voiceEffects(initial?: EffectChain | PresetName, options?: VoiceEffectsOptions): VoiceEffects;
53
+ //# sourceMappingURL=chain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../src/chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAE/F,OAAO,EAAW,KAAK,UAAU,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAEzF,MAAM,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;AAE5D,e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F;AACzF,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG;IACzC,2BAA2B;IAC3B,GAAG,IAAI,WAAW,CAAA;IAClB,kFAAkF;IAClF,GAAG,CAAC,KAAK,EAAE,WAAW,GAAG,UAAU,GAAG,IAAI,CAAA;IAC1C,4FAA4F;IAC5F,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI,CAAA;IACjE,2BAA2B;IAC3B,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAA;IAClC,iCAAiC;IACjC,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAA;IAC3C,6DAA6D;IAC7D,WAAW,IAAI,gBAAgB,EAAE,CAAA;IACjC,yFAAyF;IACzF,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;CAC1E,CAAA;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,UAAU,GAAG,WAAW,CAKzE;AAED,6EAA6E;AAC7E,wBAAgB,YAAY,CAAC,OAAO,GAAE,WAAW,GAAG,UAAoB,EAAE,OAAO,GAAE,mBAAwB,GAAG,YAAY,CA2CzH"}
package/dist/chain.js ADDED
@@ -0,0 +1,184 @@
1
+ import { builtinEffects } from './effects.js';
2
+ import { presets } from './presets.js';
3
+ export const createRegistry = (extra = []) => new Map([...builtinEffects, ...extra].map((definition) => [definition.type, definition]));
4
+ const RESERVED = new Set(['type', 'id', 'bypass']);
5
+ const PROSODY = ['rate', 'pitch', 'volume'];
6
+ /** Problems with a chain, as readable sentences (empty = valid). */
7
+ export function validateChain(chain, registry = createRegistry()) {
8
+ const errors = [];
9
+ if (!chain || typeof chain !== 'object')
10
+ return ['the chain must be an object'];
11
+ const c = chain;
12
+ if (c.version !== 1)
13
+ errors.push('version must be 1');
14
+ if (c.prosody !== undefined) {
15
+ if (!c.prosody || typeof c.prosody !== 'object')
16
+ errors.push('prosody must be an object');
17
+ else
18
+ for (const [key, value] of Object.entries(c.prosody)) {
19
+ if (!PROSODY.includes(key))
20
+ errors.push(`prosody.${key} is not rate, pitch or volume`);
21
+ else if (typeof value !== 'number' || !Number.isFinite(value))
22
+ errors.push(`prosody.${key} must be a number`);
23
+ else if (key === 'rate' && value <= 0)
24
+ errors.push('prosody.rate must be above 0');
25
+ }
26
+ }
27
+ if (!Array.isArray(c.effects))
28
+ return [...errors, 'effects must be an array'];
29
+ c.effects.forEach((spec, index) => {
30
+ const at = `effects[${index}]`;
31
+ if (!spec || typeof spec !== 'object')
32
+ return errors.push(`${at} must be an object`);
33
+ const definition = registry.get(String(spec.type));
34
+ if (!definition)
35
+ return errors.push(`${at}: unknown effect type "${String(spec.type)}"`);
36
+ for (const [key, value] of Object.entries(spec)) {
37
+ if (RESERVED.has(key))
38
+ continue;
39
+ const info = definition.params[key];
40
+ if (!info) {
41
+ errors.push(`${at}.${key}: "${definition.type}" has no such parameter`);
42
+ continue;
43
+ }
44
+ const number = typeof value === 'boolean' && info.type === 'boolean' ? Number(value) : value;
45
+ if (typeof number !== 'number' || !Number.isFinite(number))
46
+ errors.push(`${at}.${key} must be a number`);
47
+ else if (number < info.minValue || number > info.maxValue)
48
+ errors.push(`${at}.${key} = ${number} is outside ${info.minValue}–${info.maxValue}`);
49
+ }
50
+ if (spec.bypass !== undefined && typeof spec.bypass !== 'boolean')
51
+ errors.push(`${at}.bypass must be a boolean`);
52
+ if (spec.id !== undefined && typeof spec.id !== 'string')
53
+ errors.push(`${at}.id must be a string`);
54
+ });
55
+ return errors;
56
+ }
57
+ /** Every parameter of an effect, with defaults filled in and integers rounded. */
58
+ export function paramsOf(spec, definition) {
59
+ const params = {};
60
+ for (const [key, info] of Object.entries(definition.params)) {
61
+ const raw = spec[key];
62
+ let value = typeof raw === 'number' ? raw : typeof raw === 'boolean' ? Number(raw) : info.defaultValue;
63
+ if (info.type === 'int' || info.type === 'choice' || info.type === 'boolean')
64
+ value = Math.round(value);
65
+ params[key] = Math.min(info.maxValue, Math.max(info.minValue, value));
66
+ }
67
+ return params;
68
+ }
69
+ const copy = (chain) => JSON.parse(JSON.stringify(chain));
70
+ /** The effects that apply (not bypassed), with their parameters. */
71
+ export function activeEffects(chain, registry) {
72
+ return chain.effects
73
+ .filter((spec) => !spec.bypass)
74
+ .map((spec) => {
75
+ const definition = registry.get(spec.type);
76
+ if (!definition)
77
+ throw new TypeError(`Unknown effect type "${spec.type}"`);
78
+ return { spec, definition, params: paramsOf(spec, definition) };
79
+ });
80
+ }
81
+ /** Runs the sample-level effects (`process`) in order. */
82
+ export function processSamples(audio, effects) {
83
+ let out = audio;
84
+ for (const { definition, params } of effects)
85
+ if (definition.process)
86
+ out = definition.process(out, params);
87
+ return out;
88
+ }
89
+ /** Builds the Web Audio graph of the chain after `source`. */
90
+ export function connectEffects(context, source, effects) {
91
+ let node = source;
92
+ let tail = 0;
93
+ const disposers = [];
94
+ for (const { definition, params } of effects) {
95
+ if (!definition.build)
96
+ continue;
97
+ const built = definition.build(context, params, source);
98
+ node.connect(built.input);
99
+ node = built.output;
100
+ tail += definition.tail?.(params) ?? 0;
101
+ if (built.dispose)
102
+ disposers.push(built.dispose);
103
+ }
104
+ return { output: node, tail, dispose: () => disposers.splice(0).forEach((dispose) => dispose()) };
105
+ }
106
+ /** Renders `audio` through the chain, offline, tails included. */
107
+ export async function renderEffects(audio, effects, options = {}) {
108
+ const processed = processSamples(audio, effects);
109
+ const { sampleRate } = processed;
110
+ let speed = options.playbackRate ?? 1;
111
+ let tail = 0.2;
112
+ for (const { definition, params } of effects) {
113
+ speed *= definition.speed?.(params) ?? 1;
114
+ tail += definition.tail?.(params) ?? 0;
115
+ }
116
+ const length = Math.ceil((processed.samples.length / sampleRate / speed + tail) * sampleRate);
117
+ const context = options.createContext?.(length, sampleRate) ?? new OfflineAudioContext(1, length, sampleRate);
118
+ const buffer = context.createBuffer(1, Math.max(1, processed.samples.length), sampleRate);
119
+ buffer.getChannelData(0).set(processed.samples);
120
+ const source = context.createBufferSource();
121
+ source.buffer = buffer;
122
+ source.playbackRate.value = options.playbackRate ?? 1;
123
+ const instance = connectEffects(context, source, effects);
124
+ instance.output.connect(context.destination);
125
+ source.start();
126
+ const rendered = await context.startRendering();
127
+ instance.dispose?.();
128
+ return { samples: rendered.getChannelData(0).slice(), sampleRate };
129
+ }
130
+ export function resolveChain(chain) {
131
+ if (typeof chain !== 'string')
132
+ return chain;
133
+ const preset = presets[chain];
134
+ if (!preset)
135
+ throw new TypeError(`Unknown preset "${chain}"`);
136
+ return preset;
137
+ }
138
+ /** A chain of effects for synthesized speech, from JSON or a preset name. */
139
+ export function voiceEffects(initial = 'clean', options = {}) {
140
+ const registry = createRegistry(options.effects);
141
+ const listeners = new Set();
142
+ const checked = (next) => {
143
+ const errors = validateChain(next, registry);
144
+ if (errors.length)
145
+ throw new TypeError(`Invalid effect chain: ${errors.join('; ')}`);
146
+ return copy(next);
147
+ };
148
+ let chain = checked(resolveChain(initial));
149
+ const changed = () => listeners.forEach((listener) => listener());
150
+ return {
151
+ get name() {
152
+ return chain.name ?? 'voice-effects';
153
+ },
154
+ prosody: () => ({ ...chain.prosody }),
155
+ process: (audio) => processSamples(audio, activeEffects(chain, registry)),
156
+ connect: (context, source) => connectEffects(context, source, activeEffects(chain, registry)),
157
+ get: () => copy(chain),
158
+ set(next) {
159
+ chain = checked(resolveChain(next));
160
+ changed();
161
+ },
162
+ update(target, patch) {
163
+ const index = typeof target === 'number' ? target : chain.effects.findIndex((e) => e.id === target);
164
+ const current = chain.effects[index];
165
+ if (!current)
166
+ throw new RangeError(`No effect ${JSON.stringify(target)} in the chain`);
167
+ const effects = [...chain.effects];
168
+ effects[index] = { ...current, ...patch, type: patch.type ?? current.type };
169
+ chain = checked({ ...chain, effects });
170
+ changed();
171
+ },
172
+ setProsody(prosody) {
173
+ chain = checked({ ...chain, prosody: { ...prosody } });
174
+ changed();
175
+ },
176
+ subscribe(listener) {
177
+ listeners.add(listener);
178
+ return () => listeners.delete(listener);
179
+ },
180
+ definitions: () => [...registry.values()],
181
+ render: (audio, renderOptions) => renderEffects(audio, activeEffects(chain, registry), renderOptions),
182
+ };
183
+ }
184
+ //# sourceMappingURL=chain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chain.js","sourceRoot":"","sources":["../src/chain.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAmB,MAAM,cAAc,CAAA;AAKvD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAK,GAAuB,EAAE,EAAY,EAAE,CACzE,IAAI,GAAG,CAAC,CAAC,GAAG,cAAc,EAAE,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAA;AAE3F,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAA;AAClD,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAA;AAEpD,oEAAoE;AACpE,MAAM,UAAU,aAAa,CAAC,KAAc,EAAE,QAAQ,GAAa,cAAc,EAAE;IACjF,MAAM,MAAM,GAAa,EAAE,CAAA;IAC3B,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,CAAC,6BAA6B,CAAC,CAAA;IAC/E,MAAM,CAAC,GAAG,KAA6B,CAAA;IACvC,IAAI,CAAC,CAAC,OAAO,KAAK,CAAC;QAAE,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAA;IACrD,IAAI,CAAC,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAC5B,IAAI,CAAC,CAAC,CAAC,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EffectDefinition, EffectNodes, FfmpegFilter } from './types.js';
2
+ /** Registers an effect type (returns it unchanged, typed). */
3
+ export declare const defineEffect: (definition: EffectDefinition) => EffectDefinition;
4
+ /** The effect types every chain understands. */
5
+ export declare const builtinEffects: EffectDefinition[];
6
+ export type { EffectNodes, FfmpegFilter };
7
+ //# sourceMappingURL=effects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effects.d.ts","sourceRoot":"","sources":["../src/effects.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAgB,YAAY,EAAa,MAAM,YAAY,CAAA;AAEtG,8DAA8D;AAC9D,eAAO,MAAM,YAAY,eAAgB,gBAAgB,KAAG,gBAA8B,CAAA;AAyf1F,gDAAgD;AAChD,eAAO,MAAM,cAAc,EAAE,gBAAgB,EAe5C,CAAA;AAED,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,CAAA"}