├── .babelrc
├── .eslintignore
├── .eslintrc.js
├── .github
└── workflows
│ ├── codestyle.yml
│ ├── demo.yml
│ ├── link-check.yml
│ ├── package.yml
│ └── spell-check.yml
├── .gitignore
├── .npmignore
├── .prettierignore
├── .prettierrc
├── LICENSE
├── README.md
├── cypress.config.ts
├── cypress
├── fixtures
│ ├── .gitkeep
│ └── audio_samples
│ │ ├── 9khz_noise_16kHz_ds_30.pcm
│ │ ├── 9khz_noise_16kHz_ds_40.pcm
│ │ ├── 9khz_noise_16kHz_ds_50.pcm
│ │ ├── 9khz_noise_48kHz.pcm
│ │ ├── tone-9khz_noise_16kHz_ds_100.pcm
│ │ └── tone-9khz_noise_44.1kHz.pcm
├── support
│ ├── commands.ts
│ ├── component-index.html
│ └── index.ts
└── tsconfig.json
├── demo
├── .gitignore
├── README.md
├── index.html
├── package.json
└── yarn.lock
├── lib
└── pv_resampler.wasm
├── module.d.ts
├── package.json
├── resources
└── .lint
│ └── spell-check
│ ├── .cspell.json
│ └── dict.txt
├── rollup.config.js
├── src
├── audio_worklet
│ └── recorder_processor.js
├── engines
│ ├── audio_dump_engine.ts
│ ├── vu_meter_engine.ts
│ └── vu_meter_worker.ts
├── index.ts
├── polyfill
│ └── audioworklet_polyfill.ts
├── resampler.ts
├── resampler_worker.ts
├── resampler_worker_handler.ts
├── types.ts
├── utils.ts
├── wasi_snapshot.ts
└── web_voice_processor.ts
├── test
├── resampler.test.ts
└── wvp.test.ts
├── tsconfig.json
└── yarn.lock
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["@babel/preset-env"],
3 | "plugins": ["@babel/plugin-transform-runtime"]
4 | }
5 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .*
3 | bamboo
4 | coverage
5 | dist
6 | example
7 | gulpfile.js
8 | tests
9 | *.worker.js
10 | packages/**/dist/*
11 | **/rollup.config.js
12 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | // Rules reference: http://eslint.org/docs/rules/
2 | module.exports = {
3 | env: {
4 | browser: true,
5 | node: true,
6 | es6: true,
7 | mocha: true
8 | },
9 |
10 | parser: '@typescript-eslint/parser',
11 | parserOptions: {
12 | ecmaVersion: 2018
13 | },
14 |
15 | ignorePatterns: ['**/*.js', 'node_modules', 'dist'],
16 | overrides: [
17 | {
18 | files: ['src/**/*.ts'],
19 | extends: ['plugin:@typescript-eslint/recommended'],
20 | rules: {
21 | '@typescript-eslint/no-parameter-properties': 2,
22 | '@typescript-eslint/no-explicit-any': 0,
23 | '@typescript-eslint/no-var-requires': 2,
24 | '@typescript-eslint/no-non-null-assertion': 2,
25 | '@typescript-eslint/no-use-before-define': 2,
26 | '@typescript-eslint/camelcase': 0,
27 | '@typescript-eslint/no-empty-interface': 2,
28 | '@typescript-eslint/explicit-function-return-type': 1,
29 | '@typescript-eslint/ban-ts-comment': 0,
30 | '@typescript-eslint/no-empty-function': [2, { "allow": ["constructors"] }],
31 | '@typescript-eslint/no-inferrable-types': [
32 | 2,
33 | {
34 | ignoreParameters: true,
35 | ignoreProperties: true
36 | }
37 | ],
38 | '@typescript-eslint/no-shadow': ["error"]
39 | }
40 | },
41 | {
42 | files: ['test/**/*.ts', 'cypress/**/*.ts'],
43 | extends: ['plugin:cypress/recommended'],
44 | rules: {
45 | 'no-unused-expressions': 0,
46 | 'no-unused-vars': 0
47 | }
48 | }
49 | ],
50 |
51 | rules: {
52 | //=========================================================================
53 | //==================== Possible Errors ====================================
54 | //=========================================================================
55 |
56 | // disallow trailing commas in object literals
57 | 'comma-dangle': [0, 'always-multiline'],
58 | // disallow assignment in conditional expressions
59 | 'no-cond-assign': [2, 'always'],
60 | // disallow use of console
61 | 'no-console': 1,
62 | // disallow use of constant expressions in conditions
63 | 'no-constant-condition': [2, { checkLoops: false }],
64 | // disallow control characters in regular expressions
65 | 'no-control-regex': 2,
66 | // disallow use of debugger
67 | 'no-debugger': 2,
68 | // disallow duplicate arguments in functions
69 | 'no-dupe-args': 2,
70 | // disallow duplicate keys when creating object literals
71 | 'no-dupe-keys': 2,
72 | // disallow a duplicate case label.
73 | 'no-duplicate-case': 2,
74 | // disallow the use of empty character classes in regular expressions
75 | 'no-empty-character-class': 2,
76 | // disallow empty statements
77 | 'no-empty': 2,
78 | // disallow assigning to the exception in a catch block
79 | 'no-ex-assign': 2,
80 | // disallow double-negation boolean casts in a boolean context
81 | 'no-extra-boolean-cast': 2,
82 | // disallow unnecessary parentheses
83 | 'no-extra-parens': [2, 'functions'],
84 | // disallow unnecessary semicolons
85 | 'no-extra-semi': 2,
86 | // disallow overwriting functions written as function declarations
87 | 'no-func-assign': 2,
88 | // disallow function or variable declarations in nested blocks
89 | 'no-inner-declarations': 2,
90 | // disallow invalid regular expression strings in the RegExp constructor
91 | 'no-invalid-regexp': 2,
92 | // disallow irregular whitespace outside of strings and comments
93 | 'no-irregular-whitespace': 2,
94 | // disallow negation of the left operand of an in expression
95 | 'no-negated-in-lhs': 2,
96 | // disallow the use of object properties of the global object (Math and JSON) as functions
97 | 'no-obj-calls': 2,
98 | // disallow multiple spaces in a regular expression literal
99 | 'no-regex-spaces': 2,
100 | // disallow sparse arrays
101 | 'no-sparse-arrays': 2,
102 | // Avoid code that looks like two expressions but is actually one
103 | 'no-unexpected-multiline': 2,
104 | // disallow unreachable statements after a return, throw, continue, or break statement
105 | 'no-unreachable': 2,
106 | // disallow comparisons with the value NaN
107 | 'use-isnan': 2,
108 | // ensure JSDoc comments are valid
109 | 'valid-jsdoc': [
110 | 0,
111 | {
112 | requireReturn: false,
113 | requireReturnDescription: false
114 | }
115 | ],
116 | // ensure that the results of typeof are compared against a valid string
117 | 'valid-typeof': 2,
118 |
119 | //=========================================================================
120 | //==================== Best Practices =====================================
121 | //=========================================================================
122 | // Enforces getter/setter pairs in objects
123 | 'accessor-pairs': 2,
124 | // treat var statements as if they were block scoped
125 | 'block-scoped-var': 2,
126 | // specify the maximum cyclomatic complexity allowed in a program
127 | complexity: [0, 11],
128 | // require return statements to either always or never specify values
129 | 'consistent-return': 2,
130 | // specify curly brace conventions for all control statements
131 | curly: [2, 'multi-line'],
132 | // require default case in switch statements
133 | 'default-case': 2,
134 | // encourages use of dot notation whenever possible
135 | 'dot-notation': [2, { allowKeywords: true }],
136 | // enforces consistent newlines before or after dots
137 | 'dot-location': [2, 'property'],
138 | // require the use of === and !==
139 | eqeqeq: 2,
140 | // make sure for-in loops have an if statement
141 | 'guard-for-in': 2,
142 | // disallow the use of alert, confirm, and prompt
143 | 'no-alert': 2,
144 | // disallow use of arguments.caller or arguments.callee
145 | 'no-caller': 2,
146 | // disallow lexical declarations in case clauses
147 | 'no-case-declarations': 2,
148 | // disallow division operators explicitly at beginning of regular expression
149 | 'no-div-regex': 2,
150 | // disallow else after a return in an if
151 | 'no-else-return': 2,
152 | // disallow use of empty destructuring patterns
153 | 'no-empty-pattern': 2,
154 | // disallow comparisons to null without a type-checking operator
155 | 'no-eq-null': 2,
156 | // disallow use of eval()
157 | 'no-eval': 2,
158 | // disallow adding to native types
159 | 'no-extend-native': 2,
160 | // disallow unnecessary function binding
161 | 'no-extra-bind': 2,
162 | // disallow fallthrough of case statements
163 | 'no-fallthrough': 2,
164 | // disallow the use of leading or trailing decimal points in numeric literals
165 | 'no-floating-decimal': 2,
166 | // disallow the type conversions with shorter notations
167 | 'no-implicit-coercion': 2,
168 | // disallow use of eval()-like methods
169 | 'no-implied-eval': 2,
170 | // disallow this keywords outside of classes or class-like objects
171 | 'no-invalid-this': 0,
172 | // disallow usage of __iterator__ property
173 | 'no-iterator': 2,
174 | // disallow use of labeled statements
175 | 'no-labels': 2,
176 | // disallow unnecessary nested blocks
177 | 'no-lone-blocks': 2,
178 | // disallow creation of functions within loops
179 | 'no-loop-func': 2,
180 | // disallow the use of magic numbers
181 | 'no-magic-numbers': 0, //TODO: need discussion
182 | // disallow use of multiple spaces
183 | 'no-multi-spaces': 2,
184 | // disallow use of multiline strings
185 | 'no-multi-str': 2,
186 | // disallow reassignments of native objects
187 | 'no-native-reassign': 2,
188 | // disallow use of new operator for Function object
189 | 'no-new-func': 2,
190 | // disallows creating new instances of String,Number, and Boolean
191 | 'no-new-wrappers': 2,
192 | // disallow use of new operator when not part of the assignment or comparison
193 | 'no-new': 2,
194 | // disallow use of octal escape sequences in string literals, such as
195 | // var foo = "Copyright \251";
196 | 'no-octal-escape': 2,
197 | // disallow use of (old style) octal literals
198 | 'no-octal': 2,
199 | // disallow reassignment of function parameters
200 | 'no-param-reassign': 1,
201 | // disallow use of process.env
202 | 'no-process-env': 2,
203 | // disallow usage of __proto__ property
204 | 'no-proto': 2,
205 | // disallow declaring the same variable more then once
206 | 'no-redeclare': 2,
207 | // disallow use of assignment in return statement
208 | 'no-return-assign': 2,
209 | // disallow use of `javascript:` urls.
210 | 'no-script-url': 2,
211 | // disallow comparisons where both sides are exactly the same
212 | 'no-self-compare': 2,
213 | // disallow use of comma operator
214 | 'no-sequences': 2,
215 | // restrict what can be thrown as an exception
216 | 'no-throw-literal': 0,
217 | // disallow usage of expressions in statement position
218 | 'no-unused-expressions': 2,
219 | // disallow unnecessary .call() and .apply()
220 | 'no-useless-call': 2,
221 | // disallow unnecessary concatenation of literals or template literals
222 | 'no-useless-concat': 2,
223 | // disallow use of void operator
224 | 'no-void': 2,
225 | // disallow usage of configurable warning terms in comments: e.g. todo
226 | 'no-warning-comments': [
227 | 1,
228 | { terms: ['todo', 'fixme', 'xxx'], location: 'start' }
229 | ],
230 | // disallow use of the with statement
231 | 'no-with': 2,
232 | // require use of the second argument for parseInt()
233 | radix: 2,
234 | // requires to declare all vars on top of their containing scope
235 | 'vars-on-top': 0,
236 | // require immediate function invocation to be wrapped in parentheses
237 | 'wrap-iife': [2, 'any'],
238 | // require or disallow Yoda conditions
239 | yoda: 2,
240 |
241 | // //=========================================================================
242 | // //==================== Strict Mode ========================================
243 | // //=========================================================================
244 | // require that all functions are run in strict mode
245 | // "strict": [2, "global"],
246 | //
247 | //=========================================================================
248 | //==================== Variables ==========================================
249 | //=========================================================================
250 | // enforce or disallow variable initializations at definition
251 | 'init-declarations': 0,
252 | // disallow the catch clause parameter name being the same as a variable in the outer scope
253 | 'no-catch-shadow': 0,
254 | // disallow deletion of variables
255 | 'no-delete-var': 2,
256 | // disallow labels that share a name with a variable
257 | 'no-label-var': 2,
258 | // disallow shadowing of names such as arguments
259 | 'no-shadow-restricted-names': 2,
260 | // disallow declaration of variables already declared in the outer scope
261 | 'no-shadow': 0,
262 | // disallow use of undefined when initializing variables
263 | 'no-undef-init': 0,
264 | // disallow use of undeclared variables unless mentioned in a /*global */ block
265 | 'no-undef': 2,
266 | // disallow use of undefined variable
267 | 'no-undefined': 0,
268 | // disallow declaration of variables that are not used in the code
269 | 'no-unused-vars': [1, { vars: 'local', args: 'after-used' }],
270 | // disallow use of variables before they are defined
271 | 'no-use-before-define': 0,
272 |
273 | //=========================================================================
274 | //==================== Node.js ============================================
275 | //=========================================================================
276 | // enforce return after a callback
277 | 'callback-return': 0,
278 | // disallow require() outside of the top-level module scope
279 | 'global-require': 2,
280 | // enforces error handling in callbacks (node environment)
281 | 'handle-callback-err': 2,
282 | // disallow mixing regular variable and require declarations
283 | 'no-mixed-requires': 2,
284 | // disallow use of new operator with the require function
285 | 'no-new-require': 2,
286 | // disallow string concatenation with __dirname and __filename
287 | 'no-path-concat': 1,
288 | // disallow process.exit()
289 | 'no-process-exit': 2,
290 | // restrict usage of specified node modules
291 | 'no-restricted-modules': 0,
292 | // disallow use of synchronous methods (off by default)
293 | 'no-sync': 0,
294 |
295 | //=========================================================================
296 | //==================== Stylistic Issues ===================================
297 | //=========================================================================
298 | // enforce spacing inside array brackets
299 | 'array-bracket-spacing': 0,
300 | // disallow or enforce spaces inside of single line blocks
301 | 'block-spacing': 1,
302 | // enforce one true brace style
303 | 'brace-style': [1, '1tbs', { allowSingleLine: true }],
304 | // require camel case names
305 | camelcase: [1, { properties: 'always' }],
306 | // enforce spacing before and after comma
307 | 'comma-spacing': [1, { before: false, after: true }],
308 | // enforce one true comma style
309 | 'comma-style': [1, 'last'],
310 | // require or disallow padding inside computed properties
311 | 'computed-property-spacing': 0,
312 | // enforces consistent naming when capturing the current execution context
313 | 'consistent-this': 0,
314 | // enforce newline at the end of file, with no multiple empty lines
315 | 'eol-last': 1,
316 | // require function expressions to have a name
317 | 'func-names': 0,
318 | // enforces use of function declarations or expressions
319 | 'func-style': 0,
320 | // this option enforces minimum and maximum identifier lengths (variable names, property names etc.)
321 | 'id-length': 0,
322 | // require identifiers to match the provided regular expression
323 | 'id-match': 0,
324 | // this option sets a specific tab width for your code
325 | indent: [1, 2, { SwitchCase: 1 }],
326 | // specify whether double or single quotes should be used in JSX attributes
327 | 'jsx-quotes': [1, 'prefer-double'],
328 | // enforces spacing between keys and values in object literal properties
329 | 'key-spacing': [1, { beforeColon: false, afterColon: true }],
330 | // disallow mixed "LF" and "CRLF" as linebreaks
331 | 'linebreak-style': 0,
332 | // enforces empty lines around comments
333 | 'lines-around-comment': 0,
334 | // specify the maximum depth that blocks can be nested
335 | 'max-depth': [0, 4],
336 | // specify the maximum length of a line in your program
337 | 'max-len': [0, 80, 4],
338 | // specify the maximum depth callbacks can be nested
339 | 'max-nested-callbacks': 0,
340 | // limits the number of parameters that can be used in the function declaration.
341 | 'max-params': [0, 3],
342 | // specify the maximum number of statement allowed in a function
343 | 'max-statements': [0, 10],
344 | // require a capital letter for constructors
345 | 'new-cap': [1, { newIsCap: true }],
346 | // disallow the omission of parentheses when invoking a constructor with no arguments
347 | 'new-parens': 0,
348 | // allow/disallow an empty newline after var statement
349 | 'newline-after-var': 0,
350 | // disallow use of the Array constructor
351 | 'no-array-constructor': 0,
352 | // disallow use of bitwise operators
353 | 'no-bitwise': 0,
354 | // disallow use of the continue statement
355 | 'no-continue': 0,
356 | // disallow comments inline after code
357 | 'no-inline-comments': 0,
358 | // disallow if as the only statement in an else block
359 | 'no-lonely-if': 0,
360 | // disallow mixed spaces and tabs for indentation
361 | 'no-mixed-spaces-and-tabs': 1,
362 | // disallow multiple empty lines
363 | 'no-multiple-empty-lines': [1, { max: 2, maxEOF: 1 }],
364 | // disallow negated conditions
365 | 'no-negated-condition': 0,
366 | // disallow nested ternary expressions
367 | 'no-nested-ternary': 1,
368 | // disallow use of the Object constructor
369 | 'no-new-object': 1,
370 | // disallow use of unary operators, ++ and --
371 | 'no-plusplus': 0,
372 | // disallow use of certain syntax in code
373 | 'no-restricted-syntax': 0,
374 | // disallow space between function identifier and application
375 | 'no-spaced-func': 1,
376 | // disallow the use of ternary operators
377 | 'no-ternary': 0,
378 | // disallow trailing whitespace at the end of lines
379 | 'no-trailing-spaces': 1,
380 | // disallow dangling underscores in identifiers
381 | 'no-underscore-dangle': 0,
382 | // disallow the use of Boolean literals in conditional expressions
383 | 'no-unneeded-ternary': 0,
384 | // require or disallow padding inside curly braces
385 | 'object-curly-spacing': 0,
386 | // allow just one var statement per function
387 | 'one-var': [1, 'never'],
388 | // require assignment operator shorthand where possible or prohibit it entirely
389 | 'operator-assignment': 0,
390 | // enforce operators to be placed before or after line breaks
391 | 'operator-linebreak': 0,
392 | // enforce padding within blocks
393 | 'padded-blocks': [1, 'never'],
394 | // require quotes around object literal property names
395 | 'quote-props': 0,
396 | // specify whether double or single quotes should be used
397 | quotes: 0,
398 | // Require JSDoc comment
399 | 'require-jsdoc': 0,
400 | // enforce spacing before and after semicolons
401 | 'semi-spacing': [1, { before: false, after: true }],
402 | // require or disallow use of semicolons instead of ASI
403 | semi: [1, 'always'],
404 | // sort variables within the same declaration block
405 | 'sort-vars': 0,
406 | // require a space after certain keywords
407 | 'keyword-spacing': 1,
408 | // require or disallow space before blocks
409 | 'space-before-blocks': 1,
410 | // require or disallow space before function opening parenthesis
411 | 'space-before-function-paren': [0, { anonymous: 'always', named: 'never' }],
412 | // require or disallow space before blocks
413 | 'space-in-parens': 0,
414 | // require spaces around operators
415 | 'space-infix-ops': 1,
416 | // Require or disallow spaces before/after unary operators
417 | 'space-unary-ops': 0,
418 | // require or disallow a space immediately following the // or /* in a comment
419 | 'spaced-comment': [
420 | 1,
421 | 'always',
422 | {
423 | exceptions: ['-', '+', '/', '='],
424 | markers: ['=', '!', '/'] // space here to support sprockets directives
425 | }
426 | ],
427 | // require regex literals to be wrapped in parentheses
428 | 'wrap-regex': 0,
429 |
430 | //=========================================================================
431 | //==================== ES6 Rules ==========================================
432 | //=========================================================================
433 | 'arrow-body-style': [1, 'as-needed'],
434 | // require parens in arrow function arguments
435 | 'arrow-parens': [1, 'as-needed'],
436 | // require space before/after arrow function"s arrow
437 | 'arrow-spacing': 1,
438 | // verify super() callings in constructors
439 | 'constructor-super': 1,
440 | // enforce the spacing around the * in generator functions
441 | 'generator-star-spacing': 1,
442 | // disallow arrow functions where a condition is expected
443 | 'no-confusing-arrow': 1,
444 | // disallow modifying variables of class declarations
445 | 'no-class-assign': 1,
446 | // disallow modifying variables that are declared using const
447 | 'no-const-assign': 1,
448 | // disallow duplicate name in class members
449 | 'no-dupe-class-members': 1,
450 | // disallow to use this/super before super() calling in constructors.
451 | 'no-this-before-super': 1,
452 | // require let or const instead of var
453 | 'no-var': 0, //TODO: enable on full migration to es6
454 | // require method and property shorthand syntax for object literals
455 | 'object-shorthand': 0,
456 | // suggest using arrow functions as callbacks
457 | 'prefer-arrow-callback': 0, //TODO: enable on full migration to es6
458 | // suggest using of const declaration for variables that are never modified after declared
459 | 'prefer-const': 0, //TODO: enable on full migration to es6
460 | // suggest using Reflect methods where applicable
461 | 'prefer-reflect': 0,
462 | // suggest using the spread operator instead of .apply()
463 | 'prefer-spread': 0,
464 | // suggest using template literals instead of strings concatenation
465 | 'prefer-template': 0, //TODO: enable on full migration to es6
466 | // disallow generator functions that do not have yield
467 | 'require-yield': 0
468 | }
469 | };
470 |
--------------------------------------------------------------------------------
/.github/workflows/codestyle.yml:
--------------------------------------------------------------------------------
1 | name: Codestyle
2 |
3 | on:
4 | workflow_dispatch:
5 | push:
6 | branches: [ master ]
7 | paths:
8 | - '**/src/*.js'
9 | - '**/src/*.ts'
10 | - '.github/workflows/codestyle.yml'
11 | pull_request:
12 | branches: [ master, 'v[0-9]+.[0-9]+' ]
13 | paths:
14 | - '**/src/*.js'
15 | - '**/src/*.ts'
16 | - '.github/workflows/codestyle.yml'
17 |
18 | jobs:
19 | check-web-codestyle:
20 | runs-on: ubuntu-latest
21 |
22 | steps:
23 | - uses: actions/checkout@v3
24 |
25 | - name: Set up Node.js LTS
26 | uses: actions/setup-node@v3
27 | with:
28 | node-version: lts/*
29 |
30 | - name: Pre-build dependencies
31 | run: npm install yarn
32 |
33 | - name: Run Binding Linter
34 | run: yarn && yarn lint
35 |
--------------------------------------------------------------------------------
/.github/workflows/demo.yml:
--------------------------------------------------------------------------------
1 | name: Package-build
2 |
3 | on:
4 | workflow_dispatch:
5 | push:
6 | branches: [ master ]
7 | paths:
8 | - "demo/**"
9 | - '.github/workflows/demo.yml'
10 | pull_request:
11 | branches: [ master, 'v[0-9]+.[0-9]+' ]
12 | paths:
13 | - "demo/**"
14 | - '.github/workflows/demo.yml'
15 |
16 | jobs:
17 | build:
18 | runs-on: ubuntu-latest
19 |
20 | strategy:
21 | matrix:
22 | node-version: [ 14.x, 16.x, 18.x, 20.x ]
23 |
24 | steps:
25 | - uses: actions/checkout@v3
26 |
27 | - name: Set up Node.js
28 | uses: actions/setup-node@v3
29 |
30 | - name: Pre-build dependencies
31 | run: npm install yarn
32 |
33 | - name: Install dependencies
34 | run: yarn install
35 |
--------------------------------------------------------------------------------
/.github/workflows/link-check.yml:
--------------------------------------------------------------------------------
1 | name: Check Markdown links
2 |
3 | on:
4 | workflow_dispatch:
5 | push:
6 | branches: [ master ]
7 | pull_request:
8 | branches: [ master, 'v[0-9]+.[0-9]+' ]
9 |
10 | jobs:
11 | markdown-link-check:
12 | runs-on: ubuntu-latest
13 | steps:
14 | - uses: actions/checkout@master
15 | - uses: gaurav-nelson/github-action-markdown-link-check@1.0.14
16 | with:
17 | use-quiet-mode: 'yes'
18 | use-verbose-mode: 'yes'
19 |
--------------------------------------------------------------------------------
/.github/workflows/package.yml:
--------------------------------------------------------------------------------
1 | name: Package-build
2 |
3 | on:
4 | workflow_dispatch:
5 | push:
6 | branches: [ master ]
7 | paths:
8 | - "audio/**"
9 | - "src/**"
10 | - "lib/**"
11 | - '.github/workflows/package.yml'
12 | pull_request:
13 | branches: [ master, 'v[0-9]+.[0-9]+' ]
14 | paths:
15 | - "audio/**"
16 | - "src/**"
17 | - "lib/**"
18 | - '.github/workflows/package.yml'
19 |
20 | jobs:
21 | build:
22 | runs-on: ubuntu-latest
23 |
24 | strategy:
25 | matrix:
26 | node-version: [ 14.x, 16.x, 18.x, 20.x ]
27 |
28 | steps:
29 | - uses: actions/checkout@v3
30 |
31 | - name: Set up Node.js
32 | uses: actions/setup-node@v3
33 |
34 | - name: Pre-build dependencies
35 | run: npm install yarn
36 |
37 | - name: Install dependencies
38 | run: yarn install
39 |
40 | - name: Generate the package
41 | run: yarn build
42 |
43 | - name: Build
44 | run: yarn && yarn build
45 |
46 | - name: Test
47 | run: yarn test
48 |
--------------------------------------------------------------------------------
/.github/workflows/spell-check.yml:
--------------------------------------------------------------------------------
1 | name: SpellCheck
2 |
3 | on:
4 | workflow_dispatch:
5 | push:
6 | branches: [ master ]
7 | pull_request:
8 | branches: [ master, 'v[0-9]+.[0-9]+' ]
9 |
10 | jobs:
11 | markdown:
12 | runs-on: ubuntu-latest
13 |
14 | steps:
15 | - uses: actions/checkout@v3
16 |
17 | - uses: actions/setup-node@v3
18 | with:
19 | node-version: 18
20 |
21 | - name: Install CSpell
22 | run: npm install -g cspell
23 |
24 | - name: Run CSpell
25 | run: cspell --config resources/.lint/spell-check/.cspell.json "**/*"
26 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | node_modules
3 | .DS_Store
4 | dist
5 | package-lock.json
6 | cypress/downloads
7 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | .idea
2 | node_modules
3 | .DS_Store
4 | demo
5 | test
6 | .github
7 | audio
8 |
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | .eslintrc.js
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "semi": true,
3 | "trailingComma": "all",
4 | "singleQuote": true,
5 | "printWidth": 80,
6 | "tabWidth": 2,
7 | "arrowParens": "avoid"
8 | }
9 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Web Voice Processor
2 |
3 | [](https://github.com/Picovoice/web-voice-processor/releases)
4 | [](https://github.com/Picovoice/web-voice-processor/releases)
5 | [](https://www.npmjs.com/package/@picovoice/web-voice-processor)
6 |
7 | Made in Vancouver, Canada by [Picovoice](https://picovoice.ai)
8 |
9 | A library for real-time voice processing in web browsers.
10 |
11 | - Uses the [Web Audio API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API) to access microphone audio.
12 | - Leverages [Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Worker) to offload compute-intensive tasks off of the main thread.
13 | - Converts the microphone sampling rate to 16kHz, the _de facto_ standard for voice processing engines.
14 | - Provides a flexible interface to pass in arbitrary voice processing workers.
15 |
16 | - [Web Voice Processor](#web-voice-processor)
17 | - [Browser compatibility](#browser-compatibility)
18 | - [Browser features](#browser-features)
19 | - [Installation](#installation)
20 | - [How to use](#how-to-use)
21 | - [Via ES Modules (Create React App, Angular, Webpack, etc.)](#via-es-modules-create-react-app-angular-webpack-etc)
22 | - [Via HTML script tag](#via-html-script-tag)
23 | - [Start listening](#start-listening)
24 | - [Stop listening](#stop-listening)
25 | - [Build from source](#build-from-source)
26 |
27 | ## Browser compatibility
28 |
29 | All modern browsers (Chrome/Edge/Opera, Firefox, Safari) are supported, including on mobile. Internet Explorer is _not_ supported.
30 |
31 | Using the Web Audio API requires a secure context (HTTPS connection), with the exception of `localhost`, for local development.
32 |
33 | This library includes the utility function `browserCompatibilityCheck` which can be used to perform feature detection on the current browser and return an object
34 | indicating browser capabilities.
35 |
36 | ESM:
37 |
38 | ```javascript
39 | import { browserCompatibilityCheck } from '@picovoice/web-voice-processor';
40 | browserCompatibilityCheck();
41 | ```
42 |
43 | IIFE:
44 |
45 | ```javascript
46 | window.WebVoiceProcessor.browserCompatibilityCheck();
47 | ```
48 |
49 | ### Browser features
50 |
51 | - '\_picovoice' : whether all Picovoice requirements are met
52 | - 'AudioWorklet' (not currently used; intended for the future)
53 | - 'isSecureContext' (required for microphone permission for non-localhost)
54 | - 'mediaDevices' (basis for microphone enumeration / access)
55 | - 'WebAssembly' (required for all Picovoice engines)
56 | - 'webKitGetUserMedia' (legacy predecessor to getUserMedia)
57 | - 'Worker' (required for resampler and for all engine processing)
58 |
59 | ## Installation
60 |
61 | ```console
62 | npm install @picovoice/web-voice-processor
63 | ```
64 |
65 | (or)
66 |
67 | ```console
68 | yarn add @picovoice/web-voice-processor
69 | ```
70 |
71 | ## How to use
72 |
73 | ### Via ES Modules (Create React App, Angular, Webpack, etc.)
74 |
75 | ```javascript
76 | import { WebVoiceProcessor } from '@picovoice/web-voice-processor';
77 | ```
78 |
79 | ### Via HTML script tag
80 |
81 | Add the following to your HTML:
82 |
83 | ```html
84 |
85 | ```
86 |
87 | The IIFE version of the library adds `WebVoiceProcessor` to the `window` global scope.
88 |
89 | ### Start listening
90 |
91 | WebVoiceProcessor follows the subscribe/unsubscribe pattern. WebVoiceProcessor
92 | will automatically start recording audio as soon as an engine is subscribed.
93 |
94 | ```javascript
95 | const worker = new Worker('${WORKER_PATH}');
96 | const engine = {
97 | onmessage: function(e) {
98 | /// ... handle inputFrame
99 | }
100 | }
101 |
102 | await WebVoiceProcessor.subscribe(engine);
103 | await WebVoiceProcessor.subscribe(worker);
104 | // or
105 | await WebVoiceProcessor.subscribe([engine, worker]);
106 | ```
107 |
108 | An `engine` is either a [Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Worker) or an object
109 | implementing the following interface within their `onmessage` method:
110 |
111 | ```javascript
112 | onmessage = function (e) {
113 | switch (e.data.command) {
114 | case 'process':
115 | process(e.data.inputFrame);
116 | break;
117 | }
118 | };
119 | ```
120 |
121 | where `e.data.inputFrame` is an `Int16Array` of `frameLength` audio samples.
122 |
123 | For examples of using engines, look at [src/engines](src/engines).
124 |
125 | This is async due to its [Web Audio API microphone request](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia). The promise will be rejected if the user refuses permission, no suitable devices are found, etc. Your calling code should anticipate the possibility of rejection. When the promise resolves, the WebVoiceProcessor is running.
126 |
127 | ### Stop Listening
128 |
129 | Unsubscribing the engines initially subscribed will stop audio recorder.
130 |
131 | ```javascript
132 | await WebVoiceProcessor.unsubscribe(engine);
133 | await WebVoiceProcessor.unsubscribe(worker);
134 | //or
135 | await WebVoiceProcessor.unsubscribe([engine, worker]);
136 | ```
137 |
138 | ### Reset
139 |
140 | Use the `reset` function to remove all engines and stop recording audio.
141 |
142 | ```javascript
143 | await WebVoiceProcessor.reset();
144 | ```
145 |
146 | ### Options
147 |
148 | To update the audio settings in `WebVoiceProcessor`, use the `setOptions` function:
149 |
150 | ```javascript
151 | // Override default options
152 | let options = {
153 | frameLength: 512,
154 | outputSampleRate: 16000,
155 | deviceId: null,
156 | filterOrder: 50,
157 | };
158 |
159 | WebVoiceProcessor.setOptions(options);
160 | ```
161 |
162 | ### Custom Recorder Processor
163 |
164 | **NOTE**: Issues related to custom recorder processor implementations are out of the scope of this repo.
165 |
166 | Take a look at [recorder_processor.js](src/audio_worklet/recorder_processor.js) in this repo as a reference
167 | on how to create a simple recorder processor. To learn more about creating a recorder processor,
168 | check out [AudioWorkletProcessor](https://developer.mozilla.org/en-US/docs/Web/API/AudioWorkletProcessor) docs.
169 |
170 | Add the option `customRecorderProcessorURL` to options object to use your own recorder processor.
171 | Enter the string to the custom recorder processor URL or leave it blank to use the default recorder processor.
172 |
173 | ```javascript
174 | // Override default options
175 | let options = {
176 | frameLength: 512,
177 | outputSampleRate: 16000,
178 | deviceId: null,
179 | filterOrder: 50,
180 | customRecorderProcessorURL: "${URL_PATH_TO_RECORDER_PROCESSOR}"
181 | };
182 |
183 | WebVoiceProcessor.setOptions(options);
184 | ```
185 |
186 | ### VuMeter
187 |
188 | `WebVoiceProcessor` includes a built-in engine which returns the [VU meter](https://en.wikipedia.org/wiki/VU_meter).
189 | To capture the VU meter value, create a VuMeterEngine instance and subscribe it to the engine:
190 |
191 | ```javascript
192 | function vuMeterCallback(dB) {
193 | console.log(dB)
194 | }
195 |
196 | const vuMeterEngine = new VuMeterEngine(vuMeterCallback);
197 | WebVoiceProcessor.subscribe(vuMeterEngine);
198 | ```
199 |
200 | The `vuMeterCallback` should expected a number in terms of [dBFS](https://en.wikipedia.org/wiki/DBFS) within the range of [-96, 0].
201 |
202 | ## Build from source
203 |
204 | Use `yarn` or `npm` to build WebVoiceProcessor:
205 |
206 | ```console
207 | yarn
208 | yarn build
209 | ```
210 |
211 | (or)
212 |
213 | ```console
214 | npm install
215 | npm run-script build
216 | ```
217 |
218 | The build script outputs minified and non-minified versions of the IIFE and ESM formats to the `dist` folder. It also will output the TypeScript type definitions.
219 |
--------------------------------------------------------------------------------
/cypress.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "cypress";
2 |
3 | export default defineConfig({
4 | env: {
5 | "DEBUG": false,
6 | },
7 | e2e: {
8 | defaultCommandTimeout: 30000,
9 | supportFile: "cypress/support/index.ts",
10 | specPattern: "test/*.test.{js,jsx,ts,tsx}",
11 | video: false,
12 | screenshotOnRunFailure: false,
13 | }
14 | });
15 |
--------------------------------------------------------------------------------
/cypress/fixtures/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Picovoice/web-voice-processor/56c4207286a4a0c9aaf4b4199280e23d3cf505b4/cypress/fixtures/.gitkeep
--------------------------------------------------------------------------------
/cypress/fixtures/audio_samples/9khz_noise_16kHz_ds_30.pcm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Picovoice/web-voice-processor/56c4207286a4a0c9aaf4b4199280e23d3cf505b4/cypress/fixtures/audio_samples/9khz_noise_16kHz_ds_30.pcm
--------------------------------------------------------------------------------
/cypress/fixtures/audio_samples/9khz_noise_16kHz_ds_40.pcm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Picovoice/web-voice-processor/56c4207286a4a0c9aaf4b4199280e23d3cf505b4/cypress/fixtures/audio_samples/9khz_noise_16kHz_ds_40.pcm
--------------------------------------------------------------------------------
/cypress/fixtures/audio_samples/9khz_noise_16kHz_ds_50.pcm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Picovoice/web-voice-processor/56c4207286a4a0c9aaf4b4199280e23d3cf505b4/cypress/fixtures/audio_samples/9khz_noise_16kHz_ds_50.pcm
--------------------------------------------------------------------------------
/cypress/fixtures/audio_samples/9khz_noise_48kHz.pcm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Picovoice/web-voice-processor/56c4207286a4a0c9aaf4b4199280e23d3cf505b4/cypress/fixtures/audio_samples/9khz_noise_48kHz.pcm
--------------------------------------------------------------------------------
/cypress/fixtures/audio_samples/tone-9khz_noise_16kHz_ds_100.pcm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Picovoice/web-voice-processor/56c4207286a4a0c9aaf4b4199280e23d3cf505b4/cypress/fixtures/audio_samples/tone-9khz_noise_16kHz_ds_100.pcm
--------------------------------------------------------------------------------
/cypress/fixtures/audio_samples/tone-9khz_noise_44.1kHz.pcm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Picovoice/web-voice-processor/56c4207286a4a0c9aaf4b4199280e23d3cf505b4/cypress/fixtures/audio_samples/tone-9khz_noise_44.1kHz.pcm
--------------------------------------------------------------------------------
/cypress/support/commands.ts:
--------------------------------------------------------------------------------
1 |
2 | Cypress.Commands.add("getFramesFromFile", (path: string) => {
3 | cy.fixture(path, 'base64').then(Cypress.Blob.base64StringToBlob).then(async blob => {
4 | return new Int16Array(await blob.arrayBuffer());
5 | });
6 | });
7 |
--------------------------------------------------------------------------------
/cypress/support/component-index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Components App
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/cypress/support/index.ts:
--------------------------------------------------------------------------------
1 | import "./commands";
2 |
3 | declare global {
4 | namespace Cypress {
5 | interface Chainable {
6 | getFramesFromFile(path: string): Chainable;
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/cypress/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "types": ["cypress"]
5 | },
6 | "include": [
7 | "../test/**/*.ts",
8 | "./**/*.ts"
9 | ],
10 | "exclude": []
11 | }
12 |
--------------------------------------------------------------------------------
/demo/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
--------------------------------------------------------------------------------
/demo/README.md:
--------------------------------------------------------------------------------
1 | # WebVoiceProcessor - Demo
2 |
3 | This is a basic demo to show how to use WebVoiceProcessor. It passes in a worker that returns the volume level of the downsampled signal. It also allows you to dump raw PCM data that has passed through the resampler.
4 |
5 | ## Install / run
6 |
7 | Use `yarn` or `npm` to install the dependencies, and the `start` script to start a local web server hosting the demo.
8 |
9 | ```bash
10 | yarn
11 | yarn start
12 | ```
13 |
14 | Open `localhost:5000` in your web browser, as hinted at in the output:
15 |
16 | ```console
17 | Available on:
18 | http://localhost:5000
19 | Hit CTRL-C to stop the server
20 | ```
21 |
22 | You will see the VU meter responding to microphone volume in real time.
23 |
24 | ### Audio Dump
25 |
26 | Press the "Start Audio Dump" button to activate web voice processor's audio dump feature. When it's ready, you can click "Download raw PCM" to download the data. You can use a tool like Audacity to open this file (signed 16-bit, 16000Hz).
27 |
--------------------------------------------------------------------------------
/demo/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
21 |
22 |
23 |
24 |
91 |
92 |
93 |