speechflow 1.6.6 → 1.7.0
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/CHANGELOG.md +17 -0
- package/README.md +28 -14
- package/etc/secretlint.json +7 -0
- package/etc/speechflow.yaml +13 -4
- package/etc/stx.conf +3 -2
- package/package.json +9 -7
- package/speechflow-cli/dst/speechflow-main-api.js +3 -3
- package/speechflow-cli/dst/speechflow-main-api.js.map +1 -1
- package/speechflow-cli/dst/speechflow-main-cli.js +2 -2
- package/speechflow-cli/dst/speechflow-main-cli.js.map +1 -1
- package/speechflow-cli/dst/speechflow-main-graph.js +10 -9
- package/speechflow-cli/dst/speechflow-main-graph.js.map +1 -1
- package/speechflow-cli/dst/speechflow-main-status.js +35 -1
- package/speechflow-cli/dst/speechflow-main-status.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-ffmpeg.js +2 -2
- package/speechflow-cli/dst/speechflow-node-a2a-ffmpeg.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-filler.js +46 -17
- package/speechflow-cli/dst/speechflow-node-a2a-filler.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-gain.js +0 -5
- package/speechflow-cli/dst/speechflow-node-a2a-gain.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-gender.js +1 -2
- package/speechflow-cli/dst/speechflow-node-a2a-gender.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-mute.js +0 -5
- package/speechflow-cli/dst/speechflow-node-a2a-mute.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-rnnoise.js +0 -5
- package/speechflow-cli/dst/speechflow-node-a2a-rnnoise.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-speex.js +0 -5
- package/speechflow-cli/dst/speechflow-node-a2a-speex.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2a-wav.js +0 -1
- package/speechflow-cli/dst/speechflow-node-a2a-wav.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2t-amazon.js +16 -13
- package/speechflow-cli/dst/speechflow-node-a2t-amazon.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2t-deepgram.js +21 -16
- package/speechflow-cli/dst/speechflow-node-a2t-deepgram.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-a2t-openai.js +75 -46
- package/speechflow-cli/dst/speechflow-node-a2t-openai.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2a-elevenlabs.js +39 -39
- package/speechflow-cli/dst/speechflow-node-t2a-elevenlabs.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2a-kokoro.js +0 -1
- package/speechflow-cli/dst/speechflow-node-t2a-kokoro.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-amazon.js +1 -2
- package/speechflow-cli/dst/speechflow-node-t2t-amazon.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-deepl.js +0 -1
- package/speechflow-cli/dst/speechflow-node-t2t-deepl.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-format.js +0 -1
- package/speechflow-cli/dst/speechflow-node-t2t-format.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-google.js +0 -1
- package/speechflow-cli/dst/speechflow-node-t2t-google.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-modify.js +0 -1
- package/speechflow-cli/dst/speechflow-node-t2t-modify.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-ollama.js +0 -1
- package/speechflow-cli/dst/speechflow-node-t2t-ollama.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-openai.js +0 -1
- package/speechflow-cli/dst/speechflow-node-t2t-openai.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-t2t-subtitle.js +173 -29
- package/speechflow-cli/dst/speechflow-node-t2t-subtitle.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-x2x-filter.js +0 -1
- package/speechflow-cli/dst/speechflow-node-x2x-filter.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-x2x-trace.js +0 -5
- package/speechflow-cli/dst/speechflow-node-x2x-trace.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-xio-device.js +2 -2
- package/speechflow-cli/dst/speechflow-node-xio-device.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-xio-file.js +3 -3
- package/speechflow-cli/dst/speechflow-node-xio-file.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-xio-mqtt.js +7 -2
- package/speechflow-cli/dst/speechflow-node-xio-mqtt.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node-xio-websocket.js +14 -4
- package/speechflow-cli/dst/speechflow-node-xio-websocket.js.map +1 -1
- package/speechflow-cli/dst/speechflow-node.js +1 -1
- package/speechflow-cli/dst/speechflow-node.js.map +1 -1
- package/speechflow-cli/dst/speechflow-util-audio.js +3 -3
- package/speechflow-cli/dst/speechflow-util-audio.js.map +1 -1
- package/speechflow-cli/dst/speechflow-util-misc.d.ts +2 -0
- package/speechflow-cli/dst/speechflow-util-misc.js +26 -0
- package/speechflow-cli/dst/speechflow-util-misc.js.map +1 -0
- package/speechflow-cli/dst/speechflow-util-queue.d.ts +9 -2
- package/speechflow-cli/dst/speechflow-util-queue.js +33 -12
- package/speechflow-cli/dst/speechflow-util-queue.js.map +1 -1
- package/speechflow-cli/dst/speechflow-util-stream.d.ts +2 -2
- package/speechflow-cli/dst/speechflow-util-stream.js +13 -17
- package/speechflow-cli/dst/speechflow-util-stream.js.map +1 -1
- package/speechflow-cli/dst/speechflow-util.d.ts +1 -0
- package/speechflow-cli/dst/speechflow-util.js +1 -0
- package/speechflow-cli/dst/speechflow-util.js.map +1 -1
- package/speechflow-cli/etc/oxlint.jsonc +7 -1
- package/speechflow-cli/etc/stx.conf +1 -0
- package/speechflow-cli/package.json +31 -30
- package/speechflow-cli/src/speechflow-main-api.ts +3 -6
- package/speechflow-cli/src/speechflow-main-cli.ts +2 -2
- package/speechflow-cli/src/speechflow-main-graph.ts +10 -11
- package/speechflow-cli/src/speechflow-main-status.ts +2 -2
- package/speechflow-cli/src/speechflow-node-a2a-ffmpeg.ts +4 -2
- package/speechflow-cli/src/speechflow-node-a2a-filler.ts +57 -20
- package/speechflow-cli/src/speechflow-node-a2a-gain.ts +0 -5
- package/speechflow-cli/src/speechflow-node-a2a-gender.ts +1 -2
- package/speechflow-cli/src/speechflow-node-a2a-mute.ts +0 -5
- package/speechflow-cli/src/speechflow-node-a2a-rnnoise.ts +0 -5
- package/speechflow-cli/src/speechflow-node-a2a-speex.ts +0 -5
- package/speechflow-cli/src/speechflow-node-a2a-wav.ts +0 -1
- package/speechflow-cli/src/speechflow-node-a2t-amazon.ts +21 -16
- package/speechflow-cli/src/speechflow-node-a2t-deepgram.ts +24 -16
- package/speechflow-cli/src/speechflow-node-a2t-openai.ts +86 -54
- package/speechflow-cli/src/speechflow-node-t2a-elevenlabs.ts +41 -38
- package/speechflow-cli/src/speechflow-node-t2a-kokoro.ts +0 -1
- package/speechflow-cli/src/speechflow-node-t2t-amazon.ts +1 -2
- package/speechflow-cli/src/speechflow-node-t2t-deepl.ts +0 -1
- package/speechflow-cli/src/speechflow-node-t2t-format.ts +0 -1
- package/speechflow-cli/src/speechflow-node-t2t-google.ts +0 -1
- package/speechflow-cli/src/speechflow-node-t2t-modify.ts +0 -1
- package/speechflow-cli/src/speechflow-node-t2t-ollama.ts +0 -1
- package/speechflow-cli/src/speechflow-node-t2t-openai.ts +0 -1
- package/speechflow-cli/src/speechflow-node-t2t-subtitle.ts +205 -33
- package/speechflow-cli/src/speechflow-node-x2x-filter.ts +0 -1
- package/speechflow-cli/src/speechflow-node-x2x-trace.ts +0 -5
- package/speechflow-cli/src/speechflow-node-xio-device.ts +2 -2
- package/speechflow-cli/src/speechflow-node-xio-file.ts +3 -3
- package/speechflow-cli/src/speechflow-node-xio-mqtt.ts +7 -2
- package/speechflow-cli/src/speechflow-node-xio-websocket.ts +14 -4
- package/speechflow-cli/src/speechflow-node.ts +1 -1
- package/speechflow-cli/src/speechflow-util-audio.ts +3 -3
- package/speechflow-cli/src/speechflow-util-misc.ts +23 -0
- package/speechflow-cli/src/speechflow-util-queue.ts +36 -16
- package/speechflow-cli/src/speechflow-util-stream.ts +24 -21
- package/speechflow-cli/src/speechflow-util.ts +1 -0
- package/speechflow-ui-db/dst/app-font-fa-brands-400.woff2 +0 -0
- package/speechflow-ui-db/dst/app-font-fa-regular-400.woff2 +0 -0
- package/speechflow-ui-db/dst/app-font-fa-solid-900.woff2 +0 -0
- package/speechflow-ui-db/dst/app-font-fa-v4compatibility.woff2 +0 -0
- package/speechflow-ui-db/dst/index.css +1 -5
- package/speechflow-ui-db/dst/index.js +17 -58
- package/speechflow-ui-db/etc/stx.conf +5 -16
- package/speechflow-ui-db/package.json +20 -19
- package/speechflow-ui-st/dst/app-font-fa-brands-400.woff2 +0 -0
- package/speechflow-ui-st/dst/app-font-fa-regular-400.woff2 +0 -0
- package/speechflow-ui-st/dst/app-font-fa-solid-900.woff2 +0 -0
- package/speechflow-ui-st/dst/app-font-fa-v4compatibility.woff2 +0 -0
- package/speechflow-ui-st/dst/index.css +1 -5
- package/speechflow-ui-st/dst/index.js +36 -79
- package/speechflow-ui-st/etc/stx.conf +5 -16
- package/speechflow-ui-st/package.json +21 -20
- package/speechflow-cli/dst/speechflow-node-a2a-pitch2-wt.d.ts +0 -1
- package/speechflow-cli/dst/speechflow-node-a2a-pitch2-wt.js +0 -149
- package/speechflow-cli/dst/speechflow-node-a2a-pitch2-wt.js.map +0 -1
- package/speechflow-cli/dst/speechflow-node-a2a-pitch2.d.ts +0 -13
- package/speechflow-cli/dst/speechflow-node-a2a-pitch2.js +0 -202
- package/speechflow-cli/dst/speechflow-node-a2a-pitch2.js.map +0 -1
|
@@ -21,22 +21,11 @@ lint-watch
|
|
|
21
21
|
nodemon --exec "npm start lint" --watch src --ext html,styl,js,ts,vue
|
|
22
22
|
|
|
23
23
|
# [speechflow-ui-st] static code analysis
|
|
24
|
-
lint
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
# [speechflow-ui-st] static code analysis (TypeScript language)
|
|
31
|
-
lint-eslint
|
|
32
|
-
eslint --config etc/eslint.mjs src/**/*.vue src/**/*.ts
|
|
33
|
-
|
|
34
|
-
# [speechflow-ui-st] static code analysis (CSS/Stylus languages)
|
|
35
|
-
lint-stylelint
|
|
36
|
-
stylelint --config etc/stylelint.yaml src/**/*.styl src/**/*.vue
|
|
37
|
-
|
|
38
|
-
# [speechflow-ui-st] static code analysis (HTML language)
|
|
39
|
-
lint-htmllint
|
|
24
|
+
lint
|
|
25
|
+
check-dependencies && \
|
|
26
|
+
vue-tsc --project etc/tsc-client.json --noEmit && \
|
|
27
|
+
eslint --config etc/eslint.mjs src/**/*.vue src/**/*.ts && \
|
|
28
|
+
stylelint --config etc/stylelint.yaml src/**/*.styl src/**/*.vue && \
|
|
40
29
|
htmllint --rc etc/htmllint.json src/**/*.html
|
|
41
30
|
|
|
42
31
|
# [speechflow-ui-st] build components for production
|
|
@@ -14,23 +14,23 @@
|
|
|
14
14
|
"url": "http://engelschall.com"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"vue": "3.5.
|
|
17
|
+
"vue": "3.5.25",
|
|
18
18
|
"vue3-spinners": "1.3.3",
|
|
19
19
|
"luxon": "3.7.2",
|
|
20
20
|
"@opensumi/reconnecting-websocket": "4.4.0",
|
|
21
|
-
"axios": "1.
|
|
21
|
+
"axios": "1.13.2",
|
|
22
22
|
"typopro-web": "4.2.7",
|
|
23
|
-
"@fortawesome/fontawesome-free": "7.0
|
|
24
|
-
"patch-package": "8.0.
|
|
23
|
+
"@fortawesome/fontawesome-free": "7.1.0",
|
|
24
|
+
"patch-package": "8.0.1",
|
|
25
25
|
"@rse/stx": "1.1.2",
|
|
26
|
-
"animejs": "4.
|
|
26
|
+
"animejs": "4.2.2"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"vite": "7.
|
|
30
|
-
"typescript-eslint": "8.
|
|
31
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
32
|
-
"@typescript-eslint/parser": "8.
|
|
33
|
-
"@vitejs/plugin-vue": "6.0.
|
|
29
|
+
"vite": "7.2.6",
|
|
30
|
+
"typescript-eslint": "8.48.1",
|
|
31
|
+
"@typescript-eslint/eslint-plugin": "8.48.1",
|
|
32
|
+
"@typescript-eslint/parser": "8.48.1",
|
|
33
|
+
"@vitejs/plugin-vue": "6.0.2",
|
|
34
34
|
"@rollup/plugin-yaml": "4.1.2",
|
|
35
35
|
"vite-plugin-node-polyfills": "0.24.0",
|
|
36
36
|
"vite-svg-loader": "5.1.0",
|
|
@@ -39,29 +39,30 @@
|
|
|
39
39
|
|
|
40
40
|
"@vue/eslint-config-typescript": "14.6.0",
|
|
41
41
|
"vue-eslint-parser": "10.2.0",
|
|
42
|
-
"eslint": "9.
|
|
43
|
-
"@eslint/js": "9.
|
|
42
|
+
"eslint": "9.39.1",
|
|
43
|
+
"@eslint/js": "9.39.1",
|
|
44
44
|
"neostandard": "0.12.2",
|
|
45
45
|
"eslint-plugin-import": "2.32.0",
|
|
46
|
-
"eslint-plugin-vue": "10.
|
|
46
|
+
"eslint-plugin-vue": "10.6.2",
|
|
47
47
|
|
|
48
48
|
"htmllint": "0.8.0",
|
|
49
49
|
"htmllint-cli": "0.0.7",
|
|
50
50
|
|
|
51
|
-
"
|
|
51
|
+
"check-dependencies": "2.0.0",
|
|
52
|
+
"nodemon": "3.1.11",
|
|
52
53
|
"shx": "0.4.0",
|
|
53
|
-
"stylelint": "16.
|
|
54
|
+
"stylelint": "16.26.1",
|
|
54
55
|
"stylelint-config-html": "1.1.0",
|
|
55
56
|
"stylelint-config-recommended-vue": "1.6.1",
|
|
56
|
-
"stylelint-config-standard": "39.0.
|
|
57
|
+
"stylelint-config-standard": "39.0.1",
|
|
57
58
|
"stylelint-config-standard-vue": "1.0.0",
|
|
58
59
|
"stylelint-stylus": "1.0.0",
|
|
59
60
|
"postcss-html": "1.8.0",
|
|
60
61
|
"stylus": "0.64.0",
|
|
61
|
-
"typescript": "5.9.
|
|
62
|
-
"vue-tsc": "3.
|
|
63
|
-
"delay-cli": "
|
|
64
|
-
"cross-env": "10.
|
|
62
|
+
"typescript": "5.9.3",
|
|
63
|
+
"vue-tsc": "3.1.7",
|
|
64
|
+
"delay-cli": "3.0.0",
|
|
65
|
+
"cross-env": "10.1.0",
|
|
65
66
|
"serve": "14.2.5",
|
|
66
67
|
|
|
67
68
|
"@types/luxon": "3.7.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
** SpeechFlow - Speech Processing Flow Graph
|
|
4
|
-
** Copyright (c) 2024-2025 Dr. Ralf S. Engelschall <rse@engelschall.com>
|
|
5
|
-
** Licensed under GPL 3.0 <https://spdx.org/licenses/GPL-3.0-only>
|
|
6
|
-
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
/* pitch shifter audio worklet processor */
|
|
9
|
-
class PitchShifterProcessor extends AudioWorkletProcessor {
|
|
10
|
-
/* internal state */
|
|
11
|
-
shift;
|
|
12
|
-
frameSize;
|
|
13
|
-
overlap;
|
|
14
|
-
hopSize;
|
|
15
|
-
inputBuffer;
|
|
16
|
-
outputBuffer;
|
|
17
|
-
overlapBuffer;
|
|
18
|
-
windowFunction;
|
|
19
|
-
windowedBuffer;
|
|
20
|
-
shiftedBuffer;
|
|
21
|
-
inputPos = 0;
|
|
22
|
-
outputPos = 0;
|
|
23
|
-
/* worklet construction */
|
|
24
|
-
constructor(options) {
|
|
25
|
-
super();
|
|
26
|
-
/* get configuration from options */
|
|
27
|
-
const processorOptions = options.processorOptions ?? {};
|
|
28
|
-
this.shift = processorOptions.shift ?? 1.0;
|
|
29
|
-
this.frameSize = processorOptions.frameSize ?? 2048;
|
|
30
|
-
this.overlap = processorOptions.overlap ?? 0.5;
|
|
31
|
-
this.hopSize = Math.floor(this.frameSize * (1 - this.overlap));
|
|
32
|
-
/* initialize buffers */
|
|
33
|
-
this.inputBuffer = new Float32Array(this.frameSize * 2);
|
|
34
|
-
this.outputBuffer = new Float32Array(this.frameSize * 2);
|
|
35
|
-
this.overlapBuffer = new Float32Array(this.frameSize);
|
|
36
|
-
this.windowFunction = new Float32Array(this.frameSize);
|
|
37
|
-
this.windowedBuffer = new Float32Array(this.frameSize);
|
|
38
|
-
this.shiftedBuffer = new Float32Array(this.frameSize);
|
|
39
|
-
/* initialize Hann window */
|
|
40
|
-
for (let i = 0; i < this.frameSize; i++)
|
|
41
|
-
this.windowFunction[i] = 0.5 * (1 - Math.cos(2 * Math.PI * i / (this.frameSize - 1)));
|
|
42
|
-
}
|
|
43
|
-
/* static parameter descriptors */
|
|
44
|
-
static get parameterDescriptors() {
|
|
45
|
-
return [{
|
|
46
|
-
name: "shift",
|
|
47
|
-
defaultValue: 1.0,
|
|
48
|
-
minValue: 0.25,
|
|
49
|
-
maxValue: 4.0
|
|
50
|
-
}];
|
|
51
|
-
}
|
|
52
|
-
/* process audio frame */
|
|
53
|
-
process(inputs, outputs, parameters) {
|
|
54
|
-
/* get input and output arrays */
|
|
55
|
-
const input = inputs[0];
|
|
56
|
-
const output = outputs[0];
|
|
57
|
-
if (!input || !output || input.length === 0 || output.length === 0)
|
|
58
|
-
return true;
|
|
59
|
-
/* update shift parameter if provided */
|
|
60
|
-
const shiftParam = parameters.shift;
|
|
61
|
-
if (shiftParam && shiftParam.length > 0)
|
|
62
|
-
this.shift = shiftParam[0];
|
|
63
|
-
/* determine sizes */
|
|
64
|
-
const frameCount = input[0]?.length ?? 0;
|
|
65
|
-
const channelCount = Math.min(input.length, output.length);
|
|
66
|
-
if (frameCount === 0)
|
|
67
|
-
return true;
|
|
68
|
-
/* process each channel independently */
|
|
69
|
-
for (let ch = 0; ch < channelCount; ch++) {
|
|
70
|
-
const inputChannel = input[ch];
|
|
71
|
-
const outputChannel = output[ch];
|
|
72
|
-
/* bypass processing if no pitch shift needed */
|
|
73
|
-
/*
|
|
74
|
-
if (Math.abs(this.shift - 1.0) < 0.001) {
|
|
75
|
-
for (let i = 0; i < frameCount; i++)
|
|
76
|
-
outputChannel[i] = inputChannel[i]
|
|
77
|
-
continue
|
|
78
|
-
}
|
|
79
|
-
*/
|
|
80
|
-
/* process each sample */
|
|
81
|
-
for (let i = 0; i < frameCount; i++) {
|
|
82
|
-
/* accumulate input samples */
|
|
83
|
-
this.inputBuffer[this.inputPos++] = inputChannel[i];
|
|
84
|
-
/* process when we have enough input */
|
|
85
|
-
if (this.inputPos >= this.frameSize) {
|
|
86
|
-
this.processFrame();
|
|
87
|
-
/* shift input buffer by hop size */
|
|
88
|
-
for (let j = 0; j < this.frameSize - this.hopSize; j++)
|
|
89
|
-
this.inputBuffer[j] = this.inputBuffer[j + this.hopSize];
|
|
90
|
-
this.inputPos -= this.hopSize;
|
|
91
|
-
}
|
|
92
|
-
/* output processed samples */
|
|
93
|
-
if (this.outputPos < this.hopSize)
|
|
94
|
-
outputChannel[i] = this.outputBuffer[this.outputPos++];
|
|
95
|
-
else
|
|
96
|
-
outputChannel[i] = 0;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
/* process a single frame with pitch shifting */
|
|
102
|
-
processFrame() {
|
|
103
|
-
/* apply window to input */
|
|
104
|
-
for (let i = 0; i < this.frameSize; i++)
|
|
105
|
-
this.windowedBuffer[i] = this.inputBuffer[i] * this.windowFunction[i];
|
|
106
|
-
/* pitch shift using time-domain resampling */
|
|
107
|
-
const shifted = this.pitchShiftTimeDomain(this.windowedBuffer);
|
|
108
|
-
/* overlap-add synthesis - copy current overlap buffer to output */
|
|
109
|
-
for (let i = 0; i < this.hopSize; i++)
|
|
110
|
-
this.outputBuffer[i] = this.overlapBuffer[i];
|
|
111
|
-
/* add new frame contribution to overlap buffer */
|
|
112
|
-
for (let i = 0; i < this.frameSize; i++) {
|
|
113
|
-
if (i < this.hopSize)
|
|
114
|
-
this.outputBuffer[i] += shifted[i];
|
|
115
|
-
else
|
|
116
|
-
this.overlapBuffer[i - this.hopSize] = shifted[i];
|
|
117
|
-
}
|
|
118
|
-
/* reset output position */
|
|
119
|
-
this.outputPos = 0;
|
|
120
|
-
}
|
|
121
|
-
/* time-domain pitch shifting using resampling */
|
|
122
|
-
pitchShiftTimeDomain(frame) {
|
|
123
|
-
const output = this.shiftedBuffer;
|
|
124
|
-
if (Math.abs(this.shift - 1.0) < 0.001)
|
|
125
|
-
/* no pitch shift needed */
|
|
126
|
-
output.set(frame);
|
|
127
|
-
else {
|
|
128
|
-
/* resample with linear interpolation */
|
|
129
|
-
const stretchFactor = 1.0 / this.shift;
|
|
130
|
-
for (let i = 0; i < this.frameSize; i++) {
|
|
131
|
-
const sourcePos = i * stretchFactor;
|
|
132
|
-
const idx0 = Math.floor(sourcePos);
|
|
133
|
-
const idx1 = Math.min(idx0 + 1, this.frameSize - 1);
|
|
134
|
-
const frac = sourcePos - idx0;
|
|
135
|
-
if (idx0 < this.frameSize)
|
|
136
|
-
output[i] = frame[idx0] * (1 - frac) + frame[idx1] * frac;
|
|
137
|
-
else
|
|
138
|
-
output[i] = 0;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
/* apply window to output */
|
|
142
|
-
for (let i = 0; i < this.frameSize; i++)
|
|
143
|
-
output[i] *= this.windowFunction[i];
|
|
144
|
-
return output;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
/* register the processor */
|
|
148
|
-
registerProcessor("pitch-shifter", PitchShifterProcessor);
|
|
149
|
-
//# sourceMappingURL=speechflow-node-a2a-pitch2-wt.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"speechflow-node-a2a-pitch2-wt.js","sourceRoot":"","sources":["../src/speechflow-node-a2a-pitch2-wt.ts"],"names":[],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lowNode {
|
|
3
|
-
static name: string;
|
|
4
|
-
private closing;
|
|
5
|
-
private pitchShifter;
|
|
6
|
-
constructor(id: string, cfg: {
|
|
7
|
-
[id: string]: any;
|
|
8
|
-
}, opts: {
|
|
9
|
-
[id: string]: any;
|
|
10
|
-
}, args: any[]);
|
|
11
|
-
open(): Promise<void>;
|
|
12
|
-
close(): Promise<void>;
|
|
13
|
-
}
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
** SpeechFlow - Speech Processing Flow Graph
|
|
4
|
-
** Copyright (c) 2024-2025 Dr. Ralf S. Engelschall <rse@engelschall.com>
|
|
5
|
-
** Licensed under GPL 3.0 <https://spdx.org/licenses/GPL-3.0-only>
|
|
6
|
-
*/
|
|
7
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
-
if (k2 === undefined) k2 = k;
|
|
9
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
-
}
|
|
13
|
-
Object.defineProperty(o, k2, desc);
|
|
14
|
-
}) : (function(o, m, k, k2) {
|
|
15
|
-
if (k2 === undefined) k2 = k;
|
|
16
|
-
o[k2] = m[k];
|
|
17
|
-
}));
|
|
18
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
-
}) : function(o, v) {
|
|
21
|
-
o["default"] = v;
|
|
22
|
-
});
|
|
23
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
-
var ownKeys = function(o) {
|
|
25
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
-
var ar = [];
|
|
27
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
-
return ar;
|
|
29
|
-
};
|
|
30
|
-
return ownKeys(o);
|
|
31
|
-
};
|
|
32
|
-
return function (mod) {
|
|
33
|
-
if (mod && mod.__esModule) return mod;
|
|
34
|
-
var result = {};
|
|
35
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
-
__setModuleDefault(result, mod);
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
|
-
})();
|
|
40
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
|
-
};
|
|
43
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
/* standard dependencies */
|
|
45
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
46
|
-
const node_stream_1 = __importDefault(require("node:stream"));
|
|
47
|
-
/* external dependencies */
|
|
48
|
-
const node_web_audio_api_1 = require("node-web-audio-api");
|
|
49
|
-
/* internal dependencies */
|
|
50
|
-
const speechflow_node_1 = __importDefault(require("./speechflow-node"));
|
|
51
|
-
const util = __importStar(require("./speechflow-util"));
|
|
52
|
-
/* audio pitch shifter class using WebAudio */
|
|
53
|
-
class AudioPitchShifter extends util.WebAudio {
|
|
54
|
-
/* internal state */
|
|
55
|
-
pitchNode = null;
|
|
56
|
-
config;
|
|
57
|
-
/* construct object */
|
|
58
|
-
constructor(sampleRate, channels, config = {}) {
|
|
59
|
-
super(sampleRate, channels);
|
|
60
|
-
this.config = {
|
|
61
|
-
shift: config.shift ?? 1.0,
|
|
62
|
-
frameSize: config.frameSize ?? 2048,
|
|
63
|
-
overlap: config.overlap ?? 0.5
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
/* setup object */
|
|
67
|
-
async setup() {
|
|
68
|
-
await super.setup();
|
|
69
|
-
/* add pitch shifter worklet module */
|
|
70
|
-
const url = node_path_1.default.resolve(__dirname, "speechflow-node-a2a-pitch2-wt.js");
|
|
71
|
-
await this.audioContext.audioWorklet.addModule(url);
|
|
72
|
-
/* create pitch shifter worklet node */
|
|
73
|
-
this.pitchNode = new node_web_audio_api_1.AudioWorkletNode(this.audioContext, "pitch-shifter", {
|
|
74
|
-
numberOfInputs: 1,
|
|
75
|
-
numberOfOutputs: 1,
|
|
76
|
-
outputChannelCount: [this.channels],
|
|
77
|
-
processorOptions: {
|
|
78
|
-
shift: this.config.shift,
|
|
79
|
-
frameSize: this.config.frameSize,
|
|
80
|
-
overlap: this.config.overlap
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
/* connect nodes: source -> pitch -> capture */
|
|
84
|
-
this.sourceNode.connect(this.pitchNode);
|
|
85
|
-
this.pitchNode.connect(this.captureNode);
|
|
86
|
-
/* configure initial pitch shift */
|
|
87
|
-
const currentTime = this.audioContext.currentTime;
|
|
88
|
-
const params = this.pitchNode.parameters;
|
|
89
|
-
params.get("shift")?.setValueAtTime(this.config.shift, currentTime);
|
|
90
|
-
}
|
|
91
|
-
/* update pitch shift value */
|
|
92
|
-
setShift(shift) {
|
|
93
|
-
if (this.pitchNode !== null) {
|
|
94
|
-
const currentTime = this.audioContext.currentTime;
|
|
95
|
-
const params = this.pitchNode.parameters;
|
|
96
|
-
params.get("shift")?.setTargetAtTime(shift, currentTime, 0.01);
|
|
97
|
-
}
|
|
98
|
-
this.config.shift = shift;
|
|
99
|
-
}
|
|
100
|
-
/* destroy the pitch shifter */
|
|
101
|
-
async destroy() {
|
|
102
|
-
/* disconnect pitch node */
|
|
103
|
-
if (this.pitchNode !== null) {
|
|
104
|
-
this.pitchNode.disconnect();
|
|
105
|
-
this.pitchNode = null;
|
|
106
|
-
}
|
|
107
|
-
/* destroy parent */
|
|
108
|
-
await super.destroy();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
/* SpeechFlow node for pitch adjustment using WebAudio */
|
|
112
|
-
class SpeechFlowNodeA2APitch2 extends speechflow_node_1.default {
|
|
113
|
-
/* declare official node name */
|
|
114
|
-
static name = "a2a-pitch2";
|
|
115
|
-
/* internal state */
|
|
116
|
-
closing = false;
|
|
117
|
-
pitchShifter = null;
|
|
118
|
-
/* construct node */
|
|
119
|
-
constructor(id, cfg, opts, args) {
|
|
120
|
-
super(id, cfg, opts, args);
|
|
121
|
-
/* declare node configuration parameters */
|
|
122
|
-
this.configure({
|
|
123
|
-
shift: { type: "number", val: 1.0, match: (n) => n >= 0.25 && n <= 4.0 },
|
|
124
|
-
frameSize: { type: "number", val: 2048, match: (n) => n >= 256 && n <= 8192 && (n & (n - 1)) === 0 },
|
|
125
|
-
overlap: { type: "number", val: 0.5, match: (n) => n >= 0.0 && n <= 0.9 }
|
|
126
|
-
});
|
|
127
|
-
/* declare node input/output format */
|
|
128
|
-
this.input = "audio";
|
|
129
|
-
this.output = "audio";
|
|
130
|
-
}
|
|
131
|
-
/* open node */
|
|
132
|
-
async open() {
|
|
133
|
-
/* clear destruction flag */
|
|
134
|
-
this.closing = false;
|
|
135
|
-
/* setup pitch shifter */
|
|
136
|
-
this.pitchShifter = new AudioPitchShifter(this.config.audioSampleRate, this.config.audioChannels, {
|
|
137
|
-
shift: this.params.shift,
|
|
138
|
-
frameSize: this.params.frameSize,
|
|
139
|
-
overlap: this.params.overlap
|
|
140
|
-
});
|
|
141
|
-
await this.pitchShifter.setup();
|
|
142
|
-
/* establish a transform stream */
|
|
143
|
-
const self = this;
|
|
144
|
-
this.stream = new node_stream_1.default.Transform({
|
|
145
|
-
readableObjectMode: true,
|
|
146
|
-
writableObjectMode: true,
|
|
147
|
-
decodeStrings: false,
|
|
148
|
-
transform(chunk, encoding, callback) {
|
|
149
|
-
if (self.closing) {
|
|
150
|
-
callback(new Error("stream already destroyed"));
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
if (!Buffer.isBuffer(chunk.payload))
|
|
154
|
-
callback(new Error("invalid chunk payload type"));
|
|
155
|
-
else {
|
|
156
|
-
/* shift pitch of audio chunk */
|
|
157
|
-
const payload = util.convertBufToI16(chunk.payload, self.config.audioLittleEndian);
|
|
158
|
-
self.pitchShifter?.process(payload).then((result) => {
|
|
159
|
-
if (self.closing)
|
|
160
|
-
throw new Error("stream already destroyed");
|
|
161
|
-
/* take over pitch-shifted data */
|
|
162
|
-
const outputPayload = util.convertI16ToBuf(result, self.config.audioLittleEndian);
|
|
163
|
-
/* final check before pushing to avoid race condition */
|
|
164
|
-
if (self.closing)
|
|
165
|
-
throw new Error("stream already destroyed");
|
|
166
|
-
chunk.payload = outputPayload;
|
|
167
|
-
this.push(chunk);
|
|
168
|
-
callback();
|
|
169
|
-
}).catch((error) => {
|
|
170
|
-
if (!self.closing)
|
|
171
|
-
callback(util.ensureError(error, "pitch shifting failed"));
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
final(callback) {
|
|
176
|
-
if (self.closing) {
|
|
177
|
-
callback();
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
this.push(null);
|
|
181
|
-
callback();
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
/* close node */
|
|
186
|
-
async close() {
|
|
187
|
-
/* indicate closing */
|
|
188
|
-
this.closing = true;
|
|
189
|
-
/* destroy pitch shifter */
|
|
190
|
-
if (this.pitchShifter !== null) {
|
|
191
|
-
await this.pitchShifter.destroy();
|
|
192
|
-
this.pitchShifter = null;
|
|
193
|
-
}
|
|
194
|
-
/* shutdown stream */
|
|
195
|
-
if (this.stream !== null) {
|
|
196
|
-
await util.destroyStream(this.stream);
|
|
197
|
-
this.stream = null;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
exports.default = SpeechFlowNodeA2APitch2;
|
|
202
|
-
//# sourceMappingURL=speechflow-node-a2a-pitch2.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"speechflow-node-a2a-pitch2.js","sourceRoot":"","sources":["../src/speechflow-node-a2a-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