├── .gitignore ├── .prettierrc ├── LICENSE ├── README.md ├── package-lock.json ├── package.json ├── public ├── assemblyai-voice-helper.js ├── index.html └── main.js ├── src ├── index.js ├── lib │ ├── assemblyai.js │ ├── microphone.js │ ├── recorder.js │ ├── request.js │ └── vad.js └── scss │ └── main.scss └── webpack.config.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | 3 | .firebase/ 4 | .firebaserc 5 | firebase.json -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "tabWidth": 2, 3 | "singleQuote": true, 4 | "trailingComma": "none", 5 | "arrowParens": "avoid" 6 | } 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 AssemblyAI, INC. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AssemblyAI Voice Search Widget 2 | 3 | Using this widget, you can effortlessly add voice search to your website and/or app. 4 | 5 | - [Getting Started](#getting-started) 6 | - [Supported Platforms/Browsers](#supported-platforms-browsers) 7 | - [Supported Languages](#supported-languages) 8 | - [Getting an AssemblyAI API Token](#getting-an-assemblyai-api-token) 9 | - [Feedback/Support](#feedback-and-support) 10 | 11 | # Getting Started 12 | 13 | ### 1: Include AssemblyAI 14 | 15 | ```html 16 | 17 | ``` 18 | 19 | ### 2. Configure Algolia InstantSearch 20 | 21 | > The below Voice Search Widget requires you have an AssemblyAI Token, which you can get [here](#getting-an-assemblyai-api-token) 22 | 23 | ```js 24 | const search = instantsearch({ 25 | indexName: '...', 26 | searchClient: algoliasearch('...', '...'), 27 | }); 28 | 29 | search.addWidgets([ 30 | instantsearch.widgets.hits({ 31 | container: '#hits', 32 | }), 33 | instantsearch.widgets.searchBox({ 34 | container: '#searchbox' 35 | }), 36 | instantsearch.widgets.voiceSearch({ 37 | container: '#voicesearch', 38 | createVoiceSearchHelper: window.assemblyAIHelper( 39 | 'xxxxxxxxxxxxxxx', // Your AssemblyAI API Token 40 | { 41 | word_boost: ['AssemblyAI', 'Google', 'Facebook'], // AssemblyAI word_boost parameter. See: https://docs.assemblyai.com/all-guides/synchronous-transcription-for-short-audio-files#boost 42 | format_text: true // AssemblyAI format_text parameter. See: https://docs.assemblyai.com/all-guides/synchronous-transcription-for-short-audio-files#format 43 | } 44 | ), 45 | cssClasses: { 46 | root: ['AssemblyAIHelper'] // Add AssemblyAI stylings or use your own 47 | }, 48 | templates: { 49 | status: ({errorCode}) => Boolean(errorCode) ? `
${errorCode}
` : '' // AssemblyAI error handling 50 | } 51 | }), 52 | // ... other configurations 53 | ]); 54 | 55 | search.start(); 56 | 57 | ``` 58 | 59 | # Supported Platforms Browsers 60 | 61 | 62 | | Browser | Supported | 63 | | ------------- | ------------- | 64 | | Dekstop Safari | Yes | 65 | | Desktop Chrome | Yes | 66 | | Desktop Firefox | Yes | 67 | | iOS Safari | Yes | 68 | | iOS Chrome | No | 69 | | iOS Firefox | No | 70 | | Android Chrome | Yes | 71 | | Android Firefox | Yes | 72 | 73 | # Supported Languages 74 | 75 | At this time, only **English** (all accents) is supported. 76 | 77 | # Getting an AssemblyAI API Token 78 | 79 | AssemblyAI is a [Speech-to-Text API](https://www.assemblyai.com/) that can convert voice into text. You must have an AssemblyAI API Token to use this voice search widget. 80 | 81 | 1. Register for an AssemblyAI API token [here](https://app.assemblyai.com/login/) 82 | 1. Add a credit card to your AssemblyAI account [here](https://app.assemblyai.com/dashboard/account/) 83 | 1. Pricing is billed at **$0.008 per request to AssemblyAI**. 84 | 85 | # Feedback and Support 86 | 87 | For questions about AssemblyAI, please email support@assemblyai.com. For questions about Algolia, please visit Algolia's support center [here](https://www.algolia.com/support/). 88 | 89 | # Dev 90 | 91 | ## Build 92 | 93 | ```js 94 | https://github.com/AssemblyAI/assemblyai-algolia-voice-widget 95 | cd assemblyai-voice-widget 96 | npm install 97 | npm run build 98 | ``` 99 | 100 | ## Development 101 | ```js 102 | https://github.com/AssemblyAI/assemblyai-algolia-voice-widget 103 | cd assemblyai-voice-widget 104 | npm install 105 | npm run dev // Server is running with webpack-dev-server (http://localhost:3000) 106 | ``` 107 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "assemblyai-voice-widget", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "public/assemblyai-voice-widget.js", 6 | "scripts": { 7 | "dev": "webpack-dev-server", 8 | "build": "webpack --mode=production" 9 | }, 10 | "author": "Max Blank", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "@babel/core": "^7.8.6", 14 | "@babel/preset-env": "^7.8.6", 15 | "babel-loader": "^8.0.6", 16 | "babel-polyfill": "^6.26.0", 17 | "css-loader": "^3.4.2", 18 | "expose-loader": "^0.7.5", 19 | "node-sass": "^4.13.1", 20 | "sass-loader": "^8.0.2", 21 | "style-loader": "^1.1.3", 22 | "webpack": "^4.41.6", 23 | "webpack-cli": "^3.3.11", 24 | "webpack-dev-server": "^3.10.3" 25 | }, 26 | "dependencies": { 27 | "audio-resampler": "^1.0.1" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /public/assemblyai-voice-helper.js: -------------------------------------------------------------------------------- 1 | var assemblyAIHelper=function(t){var n={};function e(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,e),i.l=!0,i.exports}return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:r})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var i in t)e.d(r,i,function(n){return t[n]}.bind(null,i));return r},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="",e(e.s=344)}([function(t,n,e){var r=e(2),i=e(18),o=e(11),u=e(12),a=e(19),c=function(t,n,e){var s,f,l,h,p=t&c.F,v=t&c.G,d=t&c.S,g=t&c.P,y=t&c.B,m=v?r:d?r[n]||(r[n]={}):(r[n]||{}).prototype,b=v?i:i[n]||(i[n]={}),w=b.prototype||(b.prototype={});for(s in v&&(e=n),e)l=((f=!p&&m&&void 0!==m[s])?m:e)[s],h=y&&f?a(l,r):g&&"function"==typeof l?a(Function.call,l):l,m&&u(m,s,l,t&c.U),b[s]!=l&&o(b,s,h),g&&w[s]!=l&&(w[s]=l)};r.core=i,c.F=1,c.G=2,c.S=4,c.P=8,c.B=16,c.W=32,c.U=64,c.R=128,t.exports=c},function(t,n,e){var r=e(4);t.exports=function(t){if(!r(t))throw TypeError(t+" is not an object!");return t}},function(t,n){var e=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=e)},function(t,n){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,n){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,n,e){var r=e(47)("wks"),i=e(33),o=e(2).Symbol,u="function"==typeof o;(t.exports=function(t){return r[t]||(r[t]=u&&o[t]||(u?o:i)("Symbol."+t))}).store=r},function(t,n,e){var r=e(21),i=Math.min;t.exports=function(t){return t>0?i(r(t),9007199254740991):0}},function(t,n,e){t.exports=!e(3)((function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}))},function(t,n,e){var r=e(1),i=e(95),o=e(23),u=Object.defineProperty;n.f=e(7)?Object.defineProperty:function(t,n,e){if(r(t),n=o(n,!0),r(e),i)try{return u(t,n,e)}catch(t){}if("get"in e||"set"in e)throw TypeError("Accessors not supported!");return"value"in e&&(t[n]=e.value),t}},function(t,n,e){var r=e(24);t.exports=function(t){return Object(r(t))}},function(t,n){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},function(t,n,e){var r=e(8),i=e(32);t.exports=e(7)?function(t,n,e){return r.f(t,n,i(1,e))}:function(t,n,e){return t[n]=e,t}},function(t,n,e){var r=e(2),i=e(11),o=e(14),u=e(33)("src"),a=e(135),c=(""+a).split("toString");e(18).inspectSource=function(t){return a.call(t)},(t.exports=function(t,n,e,a){var s="function"==typeof e;s&&(o(e,"name")||i(e,"name",n)),t[n]!==e&&(s&&(o(e,u)||i(e,u,t[n]?""+t[n]:c.join(String(n)))),t===r?t[n]=e:a?t[n]?t[n]=e:i(t,n,e):(delete t[n],i(t,n,e)))})(Function.prototype,"toString",(function(){return"function"==typeof this&&this[u]||a.call(this)}))},function(t,n,e){var r=e(0),i=e(3),o=e(24),u=/"/g,a=function(t,n,e,r){var i=String(o(t)),a="<"+n;return""!==e&&(a+=" "+e+'="'+String(r).replace(u,""")+'"'),a+">"+i+""};t.exports=function(t,n){var e={};e[t]=n(a),r(r.P+r.F*i((function(){var n=""[t]('"');return n!==n.toLowerCase()||n.split('"').length>3})),"String",e)}},function(t,n){var e={}.hasOwnProperty;t.exports=function(t,n){return e.call(t,n)}},function(t,n,e){var r=e(48),i=e(24);t.exports=function(t){return r(i(t))}},function(t,n,e){var r=e(49),i=e(32),o=e(15),u=e(23),a=e(14),c=e(95),s=Object.getOwnPropertyDescriptor;n.f=e(7)?s:function(t,n){if(t=o(t),n=u(n,!0),c)try{return s(t,n)}catch(t){}if(a(t,n))return i(!r.f.call(t,n),t[n])}},function(t,n,e){var r=e(14),i=e(9),o=e(69)("IE_PROTO"),u=Object.prototype;t.exports=Object.getPrototypeOf||function(t){return t=i(t),r(t,o)?t[o]:"function"==typeof t.constructor&&t instanceof t.constructor?t.constructor.prototype:t instanceof Object?u:null}},function(t,n){var e=t.exports={version:"2.6.11"};"number"==typeof __e&&(__e=e)},function(t,n,e){var r=e(10);t.exports=function(t,n,e){if(r(t),void 0===n)return t;switch(e){case 1:return function(e){return t.call(n,e)};case 2:return function(e,r){return t.call(n,e,r)};case 3:return function(e,r,i){return t.call(n,e,r,i)}}return function(){return t.apply(n,arguments)}}},function(t,n){var e={}.toString;t.exports=function(t){return e.call(t).slice(8,-1)}},function(t,n){var e=Math.ceil,r=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?r:e)(t)}},function(t,n,e){"use strict";var r=e(3);t.exports=function(t,n){return!!t&&r((function(){n?t.call(null,(function(){}),1):t.call(null)}))}},function(t,n,e){var r=e(4);t.exports=function(t,n){if(!r(t))return t;var e,i;if(n&&"function"==typeof(e=t.toString)&&!r(i=e.call(t)))return i;if("function"==typeof(e=t.valueOf)&&!r(i=e.call(t)))return i;if(!n&&"function"==typeof(e=t.toString)&&!r(i=e.call(t)))return i;throw TypeError("Can't convert object to primitive value")}},function(t,n){t.exports=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t}},function(t,n,e){var r=e(0),i=e(18),o=e(3);t.exports=function(t,n){var e=(i.Object||{})[t]||Object[t],u={};u[t]=n(e),r(r.S+r.F*o((function(){e(1)})),"Object",u)}},function(t,n,e){var r=e(19),i=e(48),o=e(9),u=e(6),a=e(85);t.exports=function(t,n){var e=1==t,c=2==t,s=3==t,f=4==t,l=6==t,h=5==t||l,p=n||a;return function(n,a,v){for(var d,g,y=o(n),m=i(y),b=r(a,v,3),w=u(m.length),_=0,x=e?p(n,w):c?p(n,0):void 0;w>_;_++)if((h||_ in m)&&(g=b(d=m[_],_,y),t))if(e)x[_]=g;else if(g)switch(t){case 3:return!0;case 5:return d;case 6:return _;case 2:x.push(d)}else if(f)return!1;return l?-1:s||f?f:x}}},function(t,n,e){"use strict";if(e(7)){var r=e(29),i=e(2),o=e(3),u=e(0),a=e(62),c=e(93),s=e(19),f=e(39),l=e(32),h=e(11),p=e(41),v=e(21),d=e(6),g=e(123),y=e(35),m=e(23),b=e(14),w=e(44),_=e(4),x=e(9),S=e(82),A=e(36),O=e(17),E=e(37).f,P=e(84),M=e(33),k=e(5),j=e(26),F=e(52),I=e(51),C=e(87),T=e(46),R=e(57),L=e(38),N=e(86),D=e(112),U=e(8),B=e(16),W=U.f,V=B.f,G=i.RangeError,z=i.TypeError,H=i.Uint8Array,q=Array.prototype,J=c.ArrayBuffer,Y=c.DataView,$=j(0),K=j(2),X=j(3),Q=j(4),Z=j(5),tt=j(6),nt=F(!0),et=F(!1),rt=C.values,it=C.keys,ot=C.entries,ut=q.lastIndexOf,at=q.reduce,ct=q.reduceRight,st=q.join,ft=q.sort,lt=q.slice,ht=q.toString,pt=q.toLocaleString,vt=k("iterator"),dt=k("toStringTag"),gt=M("typed_constructor"),yt=M("def_constructor"),mt=a.CONSTR,bt=a.TYPED,wt=a.VIEW,_t=j(1,(function(t,n){return Et(I(t,t[yt]),n)})),xt=o((function(){return 1===new H(new Uint16Array([1]).buffer)[0]})),St=!!H&&!!H.prototype.set&&o((function(){new H(1).set({})})),At=function(t,n){var e=v(t);if(e<0||e%n)throw G("Wrong offset!");return e},Ot=function(t){if(_(t)&&bt in t)return t;throw z(t+" is not a typed array!")},Et=function(t,n){if(!(_(t)&> in t))throw z("It is not a typed array constructor!");return new t(n)},Pt=function(t,n){return Mt(I(t,t[yt]),n)},Mt=function(t,n){for(var e=0,r=n.length,i=Et(t,r);r>e;)i[e]=n[e++];return i},kt=function(t,n,e){W(t,n,{get:function(){return this._d[e]}})},jt=function(t){var n,e,r,i,o,u,a=x(t),c=arguments.length,f=c>1?arguments[1]:void 0,l=void 0!==f,h=P(a);if(null!=h&&!S(h)){for(u=h.call(a),r=[],n=0;!(o=u.next()).done;n++)r.push(o.value);a=r}for(l&&c>2&&(f=s(f,arguments[2],2)),n=0,e=d(a.length),i=Et(this,e);e>n;n++)i[n]=l?f(a[n],n):a[n];return i},Ft=function(){for(var t=0,n=arguments.length,e=Et(this,n);n>t;)e[t]=arguments[t++];return e},It=!!H&&o((function(){pt.call(new H(1))})),Ct=function(){return pt.apply(It?lt.call(Ot(this)):Ot(this),arguments)},Tt={copyWithin:function(t,n){return D.call(Ot(this),t,n,arguments.length>2?arguments[2]:void 0)},every:function(t){return Q(Ot(this),t,arguments.length>1?arguments[1]:void 0)},fill:function(t){return N.apply(Ot(this),arguments)},filter:function(t){return Pt(this,K(Ot(this),t,arguments.length>1?arguments[1]:void 0))},find:function(t){return Z(Ot(this),t,arguments.length>1?arguments[1]:void 0)},findIndex:function(t){return tt(Ot(this),t,arguments.length>1?arguments[1]:void 0)},forEach:function(t){$(Ot(this),t,arguments.length>1?arguments[1]:void 0)},indexOf:function(t){return et(Ot(this),t,arguments.length>1?arguments[1]:void 0)},includes:function(t){return nt(Ot(this),t,arguments.length>1?arguments[1]:void 0)},join:function(t){return st.apply(Ot(this),arguments)},lastIndexOf:function(t){return ut.apply(Ot(this),arguments)},map:function(t){return _t(Ot(this),t,arguments.length>1?arguments[1]:void 0)},reduce:function(t){return at.apply(Ot(this),arguments)},reduceRight:function(t){return ct.apply(Ot(this),arguments)},reverse:function(){for(var t,n=Ot(this).length,e=Math.floor(n/2),r=0;r1?arguments[1]:void 0)},sort:function(t){return ft.call(Ot(this),t)},subarray:function(t,n){var e=Ot(this),r=e.length,i=y(t,r);return new(I(e,e[yt]))(e.buffer,e.byteOffset+i*e.BYTES_PER_ELEMENT,d((void 0===n?r:y(n,r))-i))}},Rt=function(t,n){return Pt(this,lt.call(Ot(this),t,n))},Lt=function(t){Ot(this);var n=At(arguments[1],1),e=this.length,r=x(t),i=d(r.length),o=0;if(i+n>e)throw G("Wrong length!");for(;o255?255:255&r),i.v[p](e*n+i.o,r,xt)}(this,e,t)},enumerable:!0})};b?(v=e((function(t,e,r,i){f(t,v,s,"_d");var o,u,a,c,l=0,p=0;if(_(e)){if(!(e instanceof J||"ArrayBuffer"==(c=w(e))||"SharedArrayBuffer"==c))return bt in e?Mt(v,e):jt.call(v,e);o=e,p=At(r,n);var y=e.byteLength;if(void 0===i){if(y%n)throw G("Wrong length!");if((u=y-p)<0)throw G("Wrong length!")}else if((u=d(i)*n)+p>y)throw G("Wrong length!");a=u/n}else a=g(e),o=new J(u=a*n);for(h(t,"_d",{b:o,o:p,l:u,e:a,v:new Y(o)});ldocument.F=Object<\/script>"),t.close(),c=t.F;r--;)delete c.prototype[o[r]];return c()};t.exports=Object.create||function(t,n){var e;return null!==t?(a.prototype=r(t),e=new a,a.prototype=null,e[u]=t):e=c(),void 0===n?e:i(e,n)}},function(t,n,e){var r=e(97),i=e(70).concat("length","prototype");n.f=Object.getOwnPropertyNames||function(t){return r(t,i)}},function(t,n,e){"use strict";var r=e(2),i=e(8),o=e(7),u=e(5)("species");t.exports=function(t){var n=r[t];o&&n&&!n[u]&&i.f(n,u,{configurable:!0,get:function(){return this}})}},function(t,n){t.exports=function(t,n,e,r){if(!(t instanceof n)||void 0!==r&&r in t)throw TypeError(e+": incorrect invocation!");return t}},function(t,n,e){var r=e(19),i=e(110),o=e(82),u=e(1),a=e(6),c=e(84),s={},f={};(n=t.exports=function(t,n,e,l,h){var p,v,d,g,y=h?function(){return t}:c(t),m=r(e,l,n?2:1),b=0;if("function"!=typeof y)throw TypeError(t+" is not iterable!");if(o(y)){for(p=a(t.length);p>b;b++)if((g=n?m(u(v=t[b])[0],v[1]):m(t[b]))===s||g===f)return g}else for(d=y.call(t);!(v=d.next()).done;)if((g=i(d,m,v.value,n))===s||g===f)return g}).BREAK=s,n.RETURN=f},function(t,n,e){var r=e(12);t.exports=function(t,n,e){for(var i in n)r(t,i,n[i],e);return t}},function(t,n,e){var r=e(4);t.exports=function(t,n){if(!r(t)||t._t!==n)throw TypeError("Incompatible receiver, "+n+" required!");return t}},function(t,n,e){var r=e(8).f,i=e(14),o=e(5)("toStringTag");t.exports=function(t,n,e){t&&!i(t=e?t:t.prototype,o)&&r(t,o,{configurable:!0,value:n})}},function(t,n,e){var r=e(20),i=e(5)("toStringTag"),o="Arguments"==r(function(){return arguments}());t.exports=function(t){var n,e,u;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(e=function(t,n){try{return t[n]}catch(t){}}(n=Object(t),i))?e:o?r(n):"Object"==(u=r(n))&&"function"==typeof n.callee?"Arguments":u}},function(t,n,e){var r=e(0),i=e(24),o=e(3),u=e(73),a="["+u+"]",c=RegExp("^"+a+a+"*"),s=RegExp(a+a+"*$"),f=function(t,n,e){var i={},a=o((function(){return!!u[t]()||"​…"!="​…"[t]()})),c=i[t]=a?n(l):u[t];e&&(i[e]=c),r(r.P+r.F*a,"String",i)},l=f.trim=function(t,n){return t=String(i(t)),1&n&&(t=t.replace(c,"")),2&n&&(t=t.replace(s,"")),t};t.exports=f},function(t,n){t.exports={}},function(t,n,e){var r=e(18),i=e(2),o=i["__core-js_shared__"]||(i["__core-js_shared__"]={});(t.exports=function(t,n){return o[t]||(o[t]=void 0!==n?n:{})})("versions",[]).push({version:r.version,mode:e(29)?"pure":"global",copyright:"© 2019 Denis Pushkarev (zloirock.ru)"})},function(t,n,e){var r=e(20);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==r(t)?t.split(""):Object(t)}},function(t,n){n.f={}.propertyIsEnumerable},function(t,n,e){"use strict";var r=e(1);t.exports=function(){var t=r(this),n="";return t.global&&(n+="g"),t.ignoreCase&&(n+="i"),t.multiline&&(n+="m"),t.unicode&&(n+="u"),t.sticky&&(n+="y"),n}},function(t,n,e){var r=e(1),i=e(10),o=e(5)("species");t.exports=function(t,n){var e,u=r(t).constructor;return void 0===u||null==(e=r(u)[o])?n:i(e)}},function(t,n,e){var r=e(15),i=e(6),o=e(35);t.exports=function(t){return function(n,e,u){var a,c=r(n),s=i(c.length),f=o(u,s);if(t&&e!=e){for(;s>f;)if((a=c[f++])!=a)return!0}else for(;s>f;f++)if((t||f in c)&&c[f]===e)return t||f||0;return!t&&-1}}},function(t,n){n.f=Object.getOwnPropertySymbols},function(t,n,e){var r=e(20);t.exports=Array.isArray||function(t){return"Array"==r(t)}},function(t,n,e){var r=e(21),i=e(24);t.exports=function(t){return function(n,e){var o,u,a=String(i(n)),c=r(e),s=a.length;return c<0||c>=s?t?"":void 0:(o=a.charCodeAt(c))<55296||o>56319||c+1===s||(u=a.charCodeAt(c+1))<56320||u>57343?t?a.charAt(c):o:t?a.slice(c,c+2):u-56320+(o-55296<<10)+65536}}},function(t,n,e){var r=e(4),i=e(20),o=e(5)("match");t.exports=function(t){var n;return r(t)&&(void 0!==(n=t[o])?!!n:"RegExp"==i(t))}},function(t,n,e){var r=e(5)("iterator"),i=!1;try{var o=[7][r]();o.return=function(){i=!0},Array.from(o,(function(){throw 2}))}catch(t){}t.exports=function(t,n){if(!n&&!i)return!1;var e=!1;try{var o=[7],u=o[r]();u.next=function(){return{done:e=!0}},o[r]=function(){return u},t(o)}catch(t){}return e}},function(t,n,e){"use strict";var r=e(44),i=RegExp.prototype.exec;t.exports=function(t,n){var e=t.exec;if("function"==typeof e){var o=e.call(t,n);if("object"!=typeof o)throw new TypeError("RegExp exec method returned something other than an Object or null");return o}if("RegExp"!==r(t))throw new TypeError("RegExp#exec called on incompatible receiver");return i.call(t,n)}},function(t,n,e){"use strict";e(114);var r=e(12),i=e(11),o=e(3),u=e(24),a=e(5),c=e(88),s=a("species"),f=!o((function(){var t=/./;return t.exec=function(){var t=[];return t.groups={a:"7"},t},"7"!=="".replace(t,"$")})),l=function(){var t=/(?:)/,n=t.exec;t.exec=function(){return n.apply(this,arguments)};var e="ab".split(t);return 2===e.length&&"a"===e[0]&&"b"===e[1]}();t.exports=function(t,n,e){var h=a(t),p=!o((function(){var n={};return n[h]=function(){return 7},7!=""[t](n)})),v=p?!o((function(){var n=!1,e=/a/;return e.exec=function(){return n=!0,null},"split"===t&&(e.constructor={},e.constructor[s]=function(){return e}),e[h](""),!n})):void 0;if(!p||!v||"replace"===t&&!f||"split"===t&&!l){var d=/./[h],g=e(u,h,""[t],(function(t,n,e,r,i){return n.exec===c?p&&!i?{done:!0,value:d.call(n,e,r)}:{done:!0,value:t.call(e,n,r)}:{done:!1}})),y=g[0],m=g[1];r(String.prototype,t,y),i(RegExp.prototype,h,2==n?function(t,n){return m.call(t,this,n)}:function(t){return m.call(t,this)})}}},function(t,n,e){var r=e(2).navigator;t.exports=r&&r.userAgent||""},function(t,n,e){"use strict";var r=e(2),i=e(0),o=e(12),u=e(41),a=e(30),c=e(40),s=e(39),f=e(4),l=e(3),h=e(57),p=e(43),v=e(74);t.exports=function(t,n,e,d,g,y){var m=r[t],b=m,w=g?"set":"add",_=b&&b.prototype,x={},S=function(t){var n=_[t];o(_,t,"delete"==t||"has"==t?function(t){return!(y&&!f(t))&&n.call(this,0===t?0:t)}:"get"==t?function(t){return y&&!f(t)?void 0:n.call(this,0===t?0:t)}:"add"==t?function(t){return n.call(this,0===t?0:t),this}:function(t,e){return n.call(this,0===t?0:t,e),this})};if("function"==typeof b&&(y||_.forEach&&!l((function(){(new b).entries().next()})))){var A=new b,O=A[w](y?{}:-0,1)!=A,E=l((function(){A.has(1)})),P=h((function(t){new b(t)})),M=!y&&l((function(){for(var t=new b,n=5;n--;)t[w](n,n);return!t.has(-0)}));P||((b=n((function(n,e){s(n,b,t);var r=v(new m,n,b);return null!=e&&c(e,g,r[w],r),r}))).prototype=_,_.constructor=b),(E||M)&&(S("delete"),S("has"),g&&S("get")),(M||O)&&S(w),y&&_.clear&&delete _.clear}else b=d.getConstructor(n,t,g,w),u(b.prototype,e),a.NEED=!0;return p(b,t),x[t]=b,i(i.G+i.W+i.F*(b!=m),x),y||d.setStrong(b,t,g),b}},function(t,n,e){for(var r,i=e(2),o=e(11),u=e(33),a=u("typed_array"),c=u("view"),s=!(!i.ArrayBuffer||!i.DataView),f=s,l=0,h="Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array".split(",");l<9;)(r=i[h[l++]])?(o(r.prototype,a,!0),o(r.prototype,c,!0)):f=!1;t.exports={ABV:s,CONSTR:f,TYPED:a,VIEW:c}},function(t,n,e){"use strict";t.exports=e(29)||!e(3)((function(){var t=Math.random();__defineSetter__.call(null,t,(function(){})),delete e(2)[t]}))},function(t,n,e){"use strict";var r=e(0);t.exports=function(t){r(r.S,t,{of:function(){for(var t=arguments.length,n=new Array(t);t--;)n[t]=arguments[t];return new this(n)}})}},function(t,n,e){"use strict";var r=e(0),i=e(10),o=e(19),u=e(40);t.exports=function(t){r(r.S,t,{from:function(t){var n,e,r,a,c=arguments[1];return i(this),(n=void 0!==c)&&i(c),null==t?new this:(e=[],n?(r=0,a=o(c,arguments[2],2),u(t,!1,(function(t){e.push(a(t,r++))}))):u(t,!1,e.push,e),new this(e))}})}},function(t,n){var e;e=function(){return this}();try{e=e||new Function("return this")()}catch(t){"object"==typeof window&&(e=window)}t.exports=e},function(t,n,e){var r=e(4),i=e(2).document,o=r(i)&&r(i.createElement);t.exports=function(t){return o?i.createElement(t):{}}},function(t,n,e){var r=e(2),i=e(18),o=e(29),u=e(96),a=e(8).f;t.exports=function(t){var n=i.Symbol||(i.Symbol=o?{}:r.Symbol||{});"_"==t.charAt(0)||t in n||a(n,t,{value:u.f(t)})}},function(t,n,e){var r=e(47)("keys"),i=e(33);t.exports=function(t){return r[t]||(r[t]=i(t))}},function(t,n){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,n,e){var r=e(2).document;t.exports=r&&r.documentElement},function(t,n,e){var r=e(4),i=e(1),o=function(t,n){if(i(t),!r(n)&&null!==n)throw TypeError(n+": can't set as prototype!")};t.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(t,n,r){try{(r=e(19)(Function.call,e(16).f(Object.prototype,"__proto__").set,2))(t,[]),n=!(t instanceof Array)}catch(t){n=!0}return function(t,e){return o(t,e),n?t.__proto__=e:r(t,e),t}}({},!1):void 0),check:o}},function(t,n){t.exports="\t\n\v\f\r   ᠎              \u2028\u2029\ufeff"},function(t,n,e){var r=e(4),i=e(72).set;t.exports=function(t,n,e){var o,u=n.constructor;return u!==e&&"function"==typeof u&&(o=u.prototype)!==e.prototype&&r(o)&&i&&i(t,o),t}},function(t,n,e){"use strict";var r=e(21),i=e(24);t.exports=function(t){var n=String(i(this)),e="",o=r(t);if(o<0||o==1/0)throw RangeError("Count can't be negative");for(;o>0;(o>>>=1)&&(n+=n))1&o&&(e+=n);return e}},function(t,n){t.exports=Math.sign||function(t){return 0==(t=+t)||t!=t?t:t<0?-1:1}},function(t,n){var e=Math.expm1;t.exports=!e||e(10)>22025.465794806718||e(10)<22025.465794806718||-2e-17!=e(-2e-17)?function(t){return 0==(t=+t)?t:t>-1e-6&&t<1e-6?t+t*t/2:Math.exp(t)-1}:e},function(t,n,e){"use strict";var r=e(29),i=e(0),o=e(12),u=e(11),a=e(46),c=e(79),s=e(43),f=e(17),l=e(5)("iterator"),h=!([].keys&&"next"in[].keys()),p=function(){return this};t.exports=function(t,n,e,v,d,g,y){c(e,n,v);var m,b,w,_=function(t){if(!h&&t in O)return O[t];switch(t){case"keys":case"values":return function(){return new e(this,t)}}return function(){return new e(this,t)}},x=n+" Iterator",S="values"==d,A=!1,O=t.prototype,E=O[l]||O["@@iterator"]||d&&O[d],P=E||_(d),M=d?S?_("entries"):P:void 0,k="Array"==n&&O.entries||E;if(k&&(w=f(k.call(new t)))!==Object.prototype&&w.next&&(s(w,x,!0),r||"function"==typeof w[l]||u(w,l,p)),S&&E&&"values"!==E.name&&(A=!0,P=function(){return E.call(this)}),r&&!y||!h&&!A&&O[l]||u(O,l,P),a[n]=P,a[x]=p,d)if(m={values:S?P:_("values"),keys:g?P:_("keys"),entries:M},y)for(b in m)b in O||o(O,b,m[b]);else i(i.P+i.F*(h||A),n,m);return m}},function(t,n,e){"use strict";var r=e(36),i=e(32),o=e(43),u={};e(11)(u,e(5)("iterator"),(function(){return this})),t.exports=function(t,n,e){t.prototype=r(u,{next:i(1,e)}),o(t,n+" Iterator")}},function(t,n,e){var r=e(56),i=e(24);t.exports=function(t,n,e){if(r(n))throw TypeError("String#"+e+" doesn't accept regex!");return String(i(t))}},function(t,n,e){var r=e(5)("match");t.exports=function(t){var n=/./;try{"/./"[t](n)}catch(e){try{return n[r]=!1,!"/./"[t](n)}catch(t){}}return!0}},function(t,n,e){var r=e(46),i=e(5)("iterator"),o=Array.prototype;t.exports=function(t){return void 0!==t&&(r.Array===t||o[i]===t)}},function(t,n,e){"use strict";var r=e(8),i=e(32);t.exports=function(t,n,e){n in t?r.f(t,n,i(0,e)):t[n]=e}},function(t,n,e){var r=e(44),i=e(5)("iterator"),o=e(46);t.exports=e(18).getIteratorMethod=function(t){if(null!=t)return t[i]||t["@@iterator"]||o[r(t)]}},function(t,n,e){var r=e(224);t.exports=function(t,n){return new(r(t))(n)}},function(t,n,e){"use strict";var r=e(9),i=e(35),o=e(6);t.exports=function(t){for(var n=r(this),e=o(n.length),u=arguments.length,a=i(u>1?arguments[1]:void 0,e),c=u>2?arguments[2]:void 0,s=void 0===c?e:i(c,e);s>a;)n[a++]=t;return n}},function(t,n,e){"use strict";var r=e(31),i=e(113),o=e(46),u=e(15);t.exports=e(78)(Array,"Array",(function(t,n){this._t=u(t),this._i=0,this._k=n}),(function(){var t=this._t,n=this._k,e=this._i++;return!t||e>=t.length?(this._t=void 0,i(1)):i(0,"keys"==n?e:"values"==n?t[e]:[e,t[e]])}),"values"),o.Arguments=o.Array,r("keys"),r("values"),r("entries")},function(t,n,e){"use strict";var r,i,o=e(50),u=RegExp.prototype.exec,a=String.prototype.replace,c=u,s=(r=/a/,i=/b*/g,u.call(r,"a"),u.call(i,"a"),0!==r.lastIndex||0!==i.lastIndex),f=void 0!==/()??/.exec("")[1];(s||f)&&(c=function(t){var n,e,r,i,c=this;return f&&(e=new RegExp("^"+c.source+"$(?!\\s)",o.call(c))),s&&(n=c.lastIndex),r=u.call(c,t),s&&r&&(c.lastIndex=c.global?r.index+r[0].length:n),f&&r&&r.length>1&&a.call(r[0],e,(function(){for(i=1;ie;)n.push(arguments[e++]);return y[++g]=function(){a("function"==typeof t?t:Function(t),n)},r(g),g},p=function(t){delete y[t]},"process"==e(20)(l)?r=function(t){l.nextTick(u(m,t,1))}:d&&d.now?r=function(t){d.now(u(m,t,1))}:v?(o=(i=new v).port2,i.port1.onmessage=b,r=u(o.postMessage,o,1)):f.addEventListener&&"function"==typeof postMessage&&!f.importScripts?(r=function(t){f.postMessage(t+"","*")},f.addEventListener("message",b,!1)):r="onreadystatechange"in s("script")?function(t){c.appendChild(s("script")).onreadystatechange=function(){c.removeChild(this),m.call(t)}}:function(t){setTimeout(u(m,t,1),0)}),t.exports={set:h,clear:p}},function(t,n,e){var r=e(2),i=e(90).set,o=r.MutationObserver||r.WebKitMutationObserver,u=r.process,a=r.Promise,c="process"==e(20)(u);t.exports=function(){var t,n,e,s=function(){var r,i;for(c&&(r=u.domain)&&r.exit();t;){i=t.fn,t=t.next;try{i()}catch(r){throw t?e():n=void 0,r}}n=void 0,r&&r.enter()};if(c)e=function(){u.nextTick(s)};else if(!o||r.navigator&&r.navigator.standalone)if(a&&a.resolve){var f=a.resolve(void 0);e=function(){f.then(s)}}else e=function(){i.call(r,s)};else{var l=!0,h=document.createTextNode("");new o(s).observe(h,{characterData:!0}),e=function(){h.data=l=!l}}return function(r){var i={fn:r,next:void 0};n&&(n.next=i),t||(t=i,e()),n=i}}},function(t,n,e){"use strict";var r=e(10);function i(t){var n,e;this.promise=new t((function(t,r){if(void 0!==n||void 0!==e)throw TypeError("Bad Promise constructor");n=t,e=r})),this.resolve=r(n),this.reject=r(e)}t.exports.f=function(t){return new i(t)}},function(t,n,e){"use strict";var r=e(2),i=e(7),o=e(29),u=e(62),a=e(11),c=e(41),s=e(3),f=e(39),l=e(21),h=e(6),p=e(123),v=e(37).f,d=e(8).f,g=e(86),y=e(43),m=r.ArrayBuffer,b=r.DataView,w=r.Math,_=r.RangeError,x=r.Infinity,S=m,A=w.abs,O=w.pow,E=w.floor,P=w.log,M=w.LN2,k=i?"_b":"buffer",j=i?"_l":"byteLength",F=i?"_o":"byteOffset";function I(t,n,e){var r,i,o,u=new Array(e),a=8*e-n-1,c=(1<>1,f=23===n?O(2,-24)-O(2,-77):0,l=0,h=t<0||0===t&&1/t<0?1:0;for((t=A(t))!=t||t===x?(i=t!=t?1:0,r=c):(r=E(P(t)/M),t*(o=O(2,-r))<1&&(r--,o*=2),(t+=r+s>=1?f/o:f*O(2,1-s))*o>=2&&(r++,o/=2),r+s>=c?(i=0,r=c):r+s>=1?(i=(t*o-1)*O(2,n),r+=s):(i=t*O(2,s-1)*O(2,n),r=0));n>=8;u[l++]=255&i,i/=256,n-=8);for(r=r<0;u[l++]=255&r,r/=256,a-=8);return u[--l]|=128*h,u}function C(t,n,e){var r,i=8*e-n-1,o=(1<>1,a=i-7,c=e-1,s=t[c--],f=127&s;for(s>>=7;a>0;f=256*f+t[c],c--,a-=8);for(r=f&(1<<-a)-1,f>>=-a,a+=n;a>0;r=256*r+t[c],c--,a-=8);if(0===f)f=1-u;else{if(f===o)return r?NaN:s?-x:x;r+=O(2,n),f-=u}return(s?-1:1)*r*O(2,f-n)}function T(t){return t[3]<<24|t[2]<<16|t[1]<<8|t[0]}function R(t){return[255&t]}function L(t){return[255&t,t>>8&255]}function N(t){return[255&t,t>>8&255,t>>16&255,t>>24&255]}function D(t){return I(t,52,8)}function U(t){return I(t,23,4)}function B(t,n,e){d(t.prototype,n,{get:function(){return this[e]}})}function W(t,n,e,r){var i=p(+e);if(i+n>t[j])throw _("Wrong index!");var o=t[k]._b,u=i+t[F],a=o.slice(u,u+n);return r?a:a.reverse()}function V(t,n,e,r,i,o){var u=p(+e);if(u+n>t[j])throw _("Wrong index!");for(var a=t[k]._b,c=u+t[F],s=r(+i),f=0;fq;)(G=H[q++])in m||a(m,G,S[G]);o||(z.constructor=m)}var J=new b(new m(2)),Y=b.prototype.setInt8;J.setInt8(0,2147483648),J.setInt8(1,2147483649),!J.getInt8(0)&&J.getInt8(1)||c(b.prototype,{setInt8:function(t,n){Y.call(this,t,n<<24>>24)},setUint8:function(t,n){Y.call(this,t,n<<24>>24)}},!0)}else m=function(t){f(this,m,"ArrayBuffer");var n=p(t);this._b=g.call(new Array(n),0),this[j]=n},b=function(t,n,e){f(this,b,"DataView"),f(t,m,"DataView");var r=t[j],i=l(n);if(i<0||i>r)throw _("Wrong offset!");if(i+(e=void 0===e?r-i:h(e))>r)throw _("Wrong length!");this[k]=t,this[F]=i,this[j]=e},i&&(B(m,"byteLength","_l"),B(b,"buffer","_b"),B(b,"byteLength","_l"),B(b,"byteOffset","_o")),c(b.prototype,{getInt8:function(t){return W(this,1,t)[0]<<24>>24},getUint8:function(t){return W(this,1,t)[0]},getInt16:function(t){var n=W(this,2,t,arguments[1]);return(n[1]<<8|n[0])<<16>>16},getUint16:function(t){var n=W(this,2,t,arguments[1]);return n[1]<<8|n[0]},getInt32:function(t){return T(W(this,4,t,arguments[1]))},getUint32:function(t){return T(W(this,4,t,arguments[1]))>>>0},getFloat32:function(t){return C(W(this,4,t,arguments[1]),23,4)},getFloat64:function(t){return C(W(this,8,t,arguments[1]),52,8)},setInt8:function(t,n){V(this,1,t,R,n)},setUint8:function(t,n){V(this,1,t,R,n)},setInt16:function(t,n){V(this,2,t,L,n,arguments[2])},setUint16:function(t,n){V(this,2,t,L,n,arguments[2])},setInt32:function(t,n){V(this,4,t,N,n,arguments[2])},setUint32:function(t,n){V(this,4,t,N,n,arguments[2])},setFloat32:function(t,n){V(this,4,t,U,n,arguments[2])},setFloat64:function(t,n){V(this,8,t,D,n,arguments[2])}});y(m,"ArrayBuffer"),y(b,"DataView"),a(b.prototype,u.VIEW,!0),n.ArrayBuffer=m,n.DataView=b},function(t,n,e){"use strict";t.exports=e(334)},function(t,n,e){t.exports=!e(7)&&!e(3)((function(){return 7!=Object.defineProperty(e(67)("div"),"a",{get:function(){return 7}}).a}))},function(t,n,e){n.f=e(5)},function(t,n,e){var r=e(14),i=e(15),o=e(52)(!1),u=e(69)("IE_PROTO");t.exports=function(t,n){var e,a=i(t),c=0,s=[];for(e in a)e!=u&&r(a,e)&&s.push(e);for(;n.length>c;)r(a,e=n[c++])&&(~o(s,e)||s.push(e));return s}},function(t,n,e){var r=e(8),i=e(1),o=e(34);t.exports=e(7)?Object.defineProperties:function(t,n){i(t);for(var e,u=o(n),a=u.length,c=0;a>c;)r.f(t,e=u[c++],n[e]);return t}},function(t,n,e){var r=e(15),i=e(37).f,o={}.toString,u="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];t.exports.f=function(t){return u&&"[object Window]"==o.call(t)?function(t){try{return i(t)}catch(t){return u.slice()}}(t):i(r(t))}},function(t,n,e){"use strict";var r=e(7),i=e(34),o=e(53),u=e(49),a=e(9),c=e(48),s=Object.assign;t.exports=!s||e(3)((function(){var t={},n={},e=Symbol(),r="abcdefghijklmnopqrst";return t[e]=7,r.split("").forEach((function(t){n[t]=t})),7!=s({},t)[e]||Object.keys(s({},n)).join("")!=r}))?function(t,n){for(var e=a(t),s=arguments.length,f=1,l=o.f,h=u.f;s>f;)for(var p,v=c(arguments[f++]),d=l?i(v).concat(l(v)):i(v),g=d.length,y=0;g>y;)p=d[y++],r&&!h.call(v,p)||(e[p]=v[p]);return e}:s},function(t,n){t.exports=Object.is||function(t,n){return t===n?0!==t||1/t==1/n:t!=t&&n!=n}},function(t,n,e){"use strict";var r=e(10),i=e(4),o=e(103),u=[].slice,a={},c=function(t,n,e){if(!(n in a)){for(var r=[],i=0;i>>0||(u.test(e)?16:10))}:r},function(t,n,e){var r=e(2).parseFloat,i=e(45).trim;t.exports=1/r(e(73)+"-0")!=-1/0?function(t){var n=i(String(t),3),e=r(n);return 0===e&&"-"==n.charAt(0)?-0:e}:r},function(t,n,e){var r=e(20);t.exports=function(t,n){if("number"!=typeof t&&"Number"!=r(t))throw TypeError(n);return+t}},function(t,n,e){var r=e(4),i=Math.floor;t.exports=function(t){return!r(t)&&isFinite(t)&&i(t)===t}},function(t,n){t.exports=Math.log1p||function(t){return(t=+t)>-1e-8&&t<1e-8?t-t*t/2:Math.log(1+t)}},function(t,n,e){var r=e(76),i=Math.pow,o=i(2,-52),u=i(2,-23),a=i(2,127)*(2-u),c=i(2,-126);t.exports=Math.fround||function(t){var n,e,i=Math.abs(t),s=r(t);return ia||e!=e?s*(1/0):s*e}},function(t,n,e){var r=e(1);t.exports=function(t,n,e,i){try{return i?n(r(e)[0],e[1]):n(e)}catch(n){var o=t.return;throw void 0!==o&&r(o.call(t)),n}}},function(t,n,e){var r=e(10),i=e(9),o=e(48),u=e(6);t.exports=function(t,n,e,a,c){r(n);var s=i(t),f=o(s),l=u(s.length),h=c?l-1:0,p=c?-1:1;if(e<2)for(;;){if(h in f){a=f[h],h+=p;break}if(h+=p,c?h<0:l<=h)throw TypeError("Reduce of empty array with no initial value")}for(;c?h>=0:l>h;h+=p)h in f&&(a=n(a,f[h],h,s));return a}},function(t,n,e){"use strict";var r=e(9),i=e(35),o=e(6);t.exports=[].copyWithin||function(t,n){var e=r(this),u=o(e.length),a=i(t,u),c=i(n,u),s=arguments.length>2?arguments[2]:void 0,f=Math.min((void 0===s?u:i(s,u))-c,u-a),l=1;for(c0;)c in e?e[a]=e[c]:delete e[a],a+=l,c+=l;return e}},function(t,n){t.exports=function(t,n){return{value:n,done:!!t}}},function(t,n,e){"use strict";var r=e(88);e(0)({target:"RegExp",proto:!0,forced:r!==/./.exec},{exec:r})},function(t,n,e){e(7)&&"g"!=/./g.flags&&e(8).f(RegExp.prototype,"flags",{configurable:!0,get:e(50)})},function(t,n){t.exports=function(t){try{return{e:!1,v:t()}}catch(t){return{e:!0,v:t}}}},function(t,n,e){var r=e(1),i=e(4),o=e(92);t.exports=function(t,n){if(r(t),i(n)&&n.constructor===t)return n;var e=o.f(t);return(0,e.resolve)(n),e.promise}},function(t,n,e){"use strict";var r=e(119),i=e(42);t.exports=e(61)("Map",(function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}}),{get:function(t){var n=r.getEntry(i(this,"Map"),t);return n&&n.v},set:function(t,n){return r.def(i(this,"Map"),0===t?0:t,n)}},r,!0)},function(t,n,e){"use strict";var r=e(8).f,i=e(36),o=e(41),u=e(19),a=e(39),c=e(40),s=e(78),f=e(113),l=e(38),h=e(7),p=e(30).fastKey,v=e(42),d=h?"_s":"size",g=function(t,n){var e,r=p(n);if("F"!==r)return t._i[r];for(e=t._f;e;e=e.n)if(e.k==n)return e};t.exports={getConstructor:function(t,n,e,s){var f=t((function(t,r){a(t,f,n,"_i"),t._t=n,t._i=i(null),t._f=void 0,t._l=void 0,t[d]=0,null!=r&&c(r,e,t[s],t)}));return o(f.prototype,{clear:function(){for(var t=v(this,n),e=t._i,r=t._f;r;r=r.n)r.r=!0,r.p&&(r.p=r.p.n=void 0),delete e[r.i];t._f=t._l=void 0,t[d]=0},delete:function(t){var e=v(this,n),r=g(e,t);if(r){var i=r.n,o=r.p;delete e._i[r.i],r.r=!0,o&&(o.n=i),i&&(i.p=o),e._f==r&&(e._f=i),e._l==r&&(e._l=o),e[d]--}return!!r},forEach:function(t){v(this,n);for(var e,r=u(t,arguments.length>1?arguments[1]:void 0,3);e=e?e.n:this._f;)for(r(e.v,e.k,this);e&&e.r;)e=e.p},has:function(t){return!!g(v(this,n),t)}}),h&&r(f.prototype,"size",{get:function(){return v(this,n)[d]}}),f},def:function(t,n,e){var r,i,o=g(t,n);return o?o.v=e:(t._l=o={i:i=p(n,!0),k:n,v:e,p:r=t._l,n:void 0,r:!1},t._f||(t._f=o),r&&(r.n=o),t[d]++,"F"!==i&&(t._i[i]=o)),t},getEntry:g,setStrong:function(t,n,e){s(t,n,(function(t,e){this._t=v(t,n),this._k=e,this._l=void 0}),(function(){for(var t=this._k,n=this._l;n&&n.r;)n=n.p;return this._t&&(this._l=n=n?n.n:this._t._f)?f(0,"keys"==t?n.k:"values"==t?n.v:[n.k,n.v]):(this._t=void 0,f(1))}),e?"entries":"values",!e,!0),l(n)}}},function(t,n,e){"use strict";var r=e(119),i=e(42);t.exports=e(61)("Set",(function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}}),{add:function(t){return r.def(i(this,"Set"),t=0===t?0:t,t)}},r)},function(t,n,e){"use strict";var r,i=e(2),o=e(26)(0),u=e(12),a=e(30),c=e(100),s=e(122),f=e(4),l=e(42),h=e(42),p=!i.ActiveXObject&&"ActiveXObject"in i,v=a.getWeak,d=Object.isExtensible,g=s.ufstore,y=function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}},m={get:function(t){if(f(t)){var n=v(t);return!0===n?g(l(this,"WeakMap")).get(t):n?n[this._i]:void 0}},set:function(t,n){return s.def(l(this,"WeakMap"),t,n)}},b=t.exports=e(61)("WeakMap",y,m,s,!0,!0);h&&p&&(c((r=s.getConstructor(y,"WeakMap")).prototype,m),a.NEED=!0,o(["delete","has","get","set"],(function(t){var n=b.prototype,e=n[t];u(n,t,(function(n,i){if(f(n)&&!d(n)){this._f||(this._f=new r);var o=this._f[t](n,i);return"set"==t?this:o}return e.call(this,n,i)}))})))},function(t,n,e){"use strict";var r=e(41),i=e(30).getWeak,o=e(1),u=e(4),a=e(39),c=e(40),s=e(26),f=e(14),l=e(42),h=s(5),p=s(6),v=0,d=function(t){return t._l||(t._l=new g)},g=function(){this.a=[]},y=function(t,n){return h(t.a,(function(t){return t[0]===n}))};g.prototype={get:function(t){var n=y(this,t);if(n)return n[1]},has:function(t){return!!y(this,t)},set:function(t,n){var e=y(this,t);e?e[1]=n:this.a.push([t,n])},delete:function(t){var n=p(this.a,(function(n){return n[0]===t}));return~n&&this.a.splice(n,1),!!~n}},t.exports={getConstructor:function(t,n,e,o){var s=t((function(t,r){a(t,s,n,"_i"),t._t=n,t._i=v++,t._l=void 0,null!=r&&c(r,e,t[o],t)}));return r(s.prototype,{delete:function(t){if(!u(t))return!1;var e=i(t);return!0===e?d(l(this,n)).delete(t):e&&f(e,this._i)&&delete e[this._i]},has:function(t){if(!u(t))return!1;var e=i(t);return!0===e?d(l(this,n)).has(t):e&&f(e,this._i)}}),s},def:function(t,n,e){var r=i(o(n),!0);return!0===r?d(t).set(n,e):r[t._i]=e,t},ufstore:d}},function(t,n,e){var r=e(21),i=e(6);t.exports=function(t){if(void 0===t)return 0;var n=r(t),e=i(n);if(n!==e)throw RangeError("Wrong length!");return e}},function(t,n,e){var r=e(37),i=e(53),o=e(1),u=e(2).Reflect;t.exports=u&&u.ownKeys||function(t){var n=r.f(o(t)),e=i.f;return e?n.concat(e(t)):n}},function(t,n,e){"use strict";var r=e(54),i=e(4),o=e(6),u=e(19),a=e(5)("isConcatSpreadable");t.exports=function t(n,e,c,s,f,l,h,p){for(var v,d,g=f,y=0,m=!!h&&u(h,p,3);y0)g=t(n,e,v,o(v.length),g,l-1)-1;else{if(g>=9007199254740991)throw TypeError();n[g]=v}g++}y++}return g}},function(t,n,e){var r=e(6),i=e(75),o=e(24);t.exports=function(t,n,e,u){var a=String(o(t)),c=a.length,s=void 0===e?" ":String(e),f=r(n);if(f<=c||""==s)return a;var l=f-c,h=i.call(s,Math.ceil(l/s.length));return h.length>l&&(h=h.slice(0,l)),u?h+a:a+h}},function(t,n,e){var r=e(7),i=e(34),o=e(15),u=e(49).f;t.exports=function(t){return function(n){for(var e,a=o(n),c=i(a),s=c.length,f=0,l=[];s>f;)e=c[f++],r&&!u.call(a,e)||l.push(t?[e,a[e]]:a[e]);return l}}},function(t,n,e){var r=e(44),i=e(129);t.exports=function(t){return function(){if(r(this)!=t)throw TypeError(t+"#toJSON isn't generic");return i(this)}}},function(t,n,e){var r=e(40);t.exports=function(t,n){var e=[];return r(t,!1,e.push,e,n),e}},function(t,n){t.exports=Math.scale||function(t,n,e,r,i){return 0===arguments.length||t!=t||n!=n||e!=e||r!=r||i!=i?NaN:t===1/0||t===-1/0?t:(t-n)*(i-r)/(e-n)+r}},function(t,n,e){"use strict";var r=e(335),i=e(337);window.OfflineAudioContext=window.OfflineAudioContext||window.webkitOfflineAudioContext,window.AudioContext=window.AudioContext||window.webkitAudioContext;var o=new AudioContext,u=new r({context:o,cache:!1});t.exports=function(t,n,e){if(!t&&!n)return c("Error: First argument should be either a File, URL or AudioBuffer");var r=Object.prototype.toString.call(t);if("[object String]"!==r&&"[object File]"!==r&&"[object AudioBuffer]"!==r&&"[object Object]"!==r)return c("Error: First argument should be either a File, URL or AudioBuffer");if("number"!=typeof n||n>192e3||n<3e3)return c("Error: Second argument should be a numeric sample rate between 3000 and 192000");if("[object String]"===r||"[object File]"===r)console.log("Loading/decoding input",t),u.load(t,{onload:function(t,n){if(t)return c(t);s(n)}});else if("[object AudioBuffer]"===r)s(t);else{if("[object Object]"!==r||!t.leftBuffer||!t.sampleRate)return c("Error: Unknown input type");var a=t.rightBuffer?2:1;s(o.createBuffer(a,t.leftBuffer.length,t.sampleRate))}function c(t){console.error(t),"function"==typeof e&&e(new Error(t))}function s(t){var r=t.numberOfChannels,o=t.length*n/t.sampleRate,u=new OfflineAudioContext(r,o,n),a=u.createBufferSource();a.buffer=t,u.oncomplete=function(t){var n=t.renderedBuffer;console.log("Done Rendering"),"function"==typeof e&&e({getAudioBuffer:function(){return n},getFile:function(t){for(var e={sampleRate:n.sampleRate,channelData:[]},r=0;ri;)$(t,e=r[i++],n[e]);return t},X=function(t){var n=D.call(this,t=x(t,!0));return!(this===V&&i(B,t)&&!i(W,t))&&(!(n||!i(this,t)||!i(B,t)||i(this,L)&&this[L][t])||n)},Q=function(t,n){if(t=_(t),n=x(n,!0),t!==V||!i(B,n)||i(W,n)){var e=j(t,n);return!e||!i(B,n)||i(t,L)&&t[L][n]||(e.enumerable=!0),e}},Z=function(t){for(var n,e=I(_(t)),r=[],o=0;e.length>o;)i(B,n=e[o++])||n==L||n==c||r.push(n);return r},tt=function(t){for(var n,e=t===V,r=I(e?W:_(t)),o=[],u=0;r.length>u;)!i(B,n=r[u++])||e&&!i(V,n)||o.push(B[n]);return o};G||(a((C=function(){if(this instanceof C)throw TypeError("Symbol is not a constructor!");var t=h(arguments.length>0?arguments[0]:void 0),n=function(e){this===V&&n.call(W,e),i(this,L)&&i(this[L],t)&&(this[L][t]=!1),q(this,t,S(1,e))};return o&&H&&q(V,t,{configurable:!0,set:n}),J(t)}).prototype,"toString",(function(){return this._k})),E.f=Q,M.f=$,e(37).f=O.f=Z,e(49).f=X,P.f=tt,o&&!e(29)&&a(V,"propertyIsEnumerable",X,!0),v.f=function(t){return J(p(t))}),u(u.G+u.W+u.F*!G,{Symbol:C});for(var nt="hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables".split(","),et=0;nt.length>et;)p(nt[et++]);for(var rt=k(p.store),it=0;rt.length>it;)d(rt[it++]);u(u.S+u.F*!G,"Symbol",{for:function(t){return i(U,t+="")?U[t]:U[t]=C(t)},keyFor:function(t){if(!Y(t))throw TypeError(t+" is not a symbol!");for(var n in U)if(U[n]===t)return n},useSetter:function(){H=!0},useSimple:function(){H=!1}}),u(u.S+u.F*!G,"Object",{create:function(t,n){return void 0===n?A(t):K(A(t),n)},defineProperty:$,defineProperties:K,getOwnPropertyDescriptor:Q,getOwnPropertyNames:Z,getOwnPropertySymbols:tt});var ot=s((function(){P.f(1)}));u(u.S+u.F*ot,"Object",{getOwnPropertySymbols:function(t){return P.f(w(t))}}),T&&u(u.S+u.F*(!G||s((function(){var t=C();return"[null]"!=R([t])||"{}"!=R({a:t})||"{}"!=R(Object(t))}))),"JSON",{stringify:function(t){for(var n,e,r=[t],i=1;arguments.length>i;)r.push(arguments[i++]);if(e=n=r[1],(b(n)||void 0!==t)&&!Y(t))return y(n)||(n=function(t,n){if("function"==typeof e&&(n=e.call(this,t,n)),!Y(n))return n}),r[1]=n,R.apply(T,r)}}),C.prototype[N]||e(11)(C.prototype,N,C.prototype.valueOf),l(C,"Symbol"),l(Math,"Math",!0),l(r.JSON,"JSON",!0)},function(t,n,e){t.exports=e(47)("native-function-to-string",Function.toString)},function(t,n,e){var r=e(34),i=e(53),o=e(49);t.exports=function(t){var n=r(t),e=i.f;if(e)for(var u,a=e(t),c=o.f,s=0;a.length>s;)c.call(t,u=a[s++])&&n.push(u);return n}},function(t,n,e){var r=e(0);r(r.S,"Object",{create:e(36)})},function(t,n,e){var r=e(0);r(r.S+r.F*!e(7),"Object",{defineProperty:e(8).f})},function(t,n,e){var r=e(0);r(r.S+r.F*!e(7),"Object",{defineProperties:e(98)})},function(t,n,e){var r=e(15),i=e(16).f;e(25)("getOwnPropertyDescriptor",(function(){return function(t,n){return i(r(t),n)}}))},function(t,n,e){var r=e(9),i=e(17);e(25)("getPrototypeOf",(function(){return function(t){return i(r(t))}}))},function(t,n,e){var r=e(9),i=e(34);e(25)("keys",(function(){return function(t){return i(r(t))}}))},function(t,n,e){e(25)("getOwnPropertyNames",(function(){return e(99).f}))},function(t,n,e){var r=e(4),i=e(30).onFreeze;e(25)("freeze",(function(t){return function(n){return t&&r(n)?t(i(n)):n}}))},function(t,n,e){var r=e(4),i=e(30).onFreeze;e(25)("seal",(function(t){return function(n){return t&&r(n)?t(i(n)):n}}))},function(t,n,e){var r=e(4),i=e(30).onFreeze;e(25)("preventExtensions",(function(t){return function(n){return t&&r(n)?t(i(n)):n}}))},function(t,n,e){var r=e(4);e(25)("isFrozen",(function(t){return function(n){return!r(n)||!!t&&t(n)}}))},function(t,n,e){var r=e(4);e(25)("isSealed",(function(t){return function(n){return!r(n)||!!t&&t(n)}}))},function(t,n,e){var r=e(4);e(25)("isExtensible",(function(t){return function(n){return!!r(n)&&(!t||t(n))}}))},function(t,n,e){var r=e(0);r(r.S+r.F,"Object",{assign:e(100)})},function(t,n,e){var r=e(0);r(r.S,"Object",{is:e(101)})},function(t,n,e){var r=e(0);r(r.S,"Object",{setPrototypeOf:e(72).set})},function(t,n,e){"use strict";var r=e(44),i={};i[e(5)("toStringTag")]="z",i+""!="[object z]"&&e(12)(Object.prototype,"toString",(function(){return"[object "+r(this)+"]"}),!0)},function(t,n,e){var r=e(0);r(r.P,"Function",{bind:e(102)})},function(t,n,e){var r=e(8).f,i=Function.prototype,o=/^\s*function ([^ (]*)/;"name"in i||e(7)&&r(i,"name",{configurable:!0,get:function(){try{return(""+this).match(o)[1]}catch(t){return""}}})},function(t,n,e){"use strict";var r=e(4),i=e(17),o=e(5)("hasInstance"),u=Function.prototype;o in u||e(8).f(u,o,{value:function(t){if("function"!=typeof this||!r(t))return!1;if(!r(this.prototype))return t instanceof this;for(;t=i(t);)if(this.prototype===t)return!0;return!1}})},function(t,n,e){var r=e(0),i=e(104);r(r.G+r.F*(parseInt!=i),{parseInt:i})},function(t,n,e){var r=e(0),i=e(105);r(r.G+r.F*(parseFloat!=i),{parseFloat:i})},function(t,n,e){"use strict";var r=e(2),i=e(14),o=e(20),u=e(74),a=e(23),c=e(3),s=e(37).f,f=e(16).f,l=e(8).f,h=e(45).trim,p=r.Number,v=p,d=p.prototype,g="Number"==o(e(36)(d)),y="trim"in String.prototype,m=function(t){var n=a(t,!1);if("string"==typeof n&&n.length>2){var e,r,i,o=(n=y?n.trim():h(n,3)).charCodeAt(0);if(43===o||45===o){if(88===(e=n.charCodeAt(2))||120===e)return NaN}else if(48===o){switch(n.charCodeAt(1)){case 66:case 98:r=2,i=49;break;case 79:case 111:r=8,i=55;break;default:return+n}for(var u,c=n.slice(2),s=0,f=c.length;si)return NaN;return parseInt(c,r)}}return+n};if(!p(" 0o1")||!p("0b1")||p("+0x1")){p=function(t){var n=arguments.length<1?0:t,e=this;return e instanceof p&&(g?c((function(){d.valueOf.call(e)})):"Number"!=o(e))?u(new v(m(n)),e,p):m(n)};for(var b,w=e(7)?s(v):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger".split(","),_=0;w.length>_;_++)i(v,b=w[_])&&!i(p,b)&&l(p,b,f(v,b));p.prototype=d,d.constructor=p,e(12)(r,"Number",p)}},function(t,n,e){"use strict";var r=e(0),i=e(21),o=e(106),u=e(75),a=1..toFixed,c=Math.floor,s=[0,0,0,0,0,0],f="Number.toFixed: incorrect invocation!",l=function(t,n){for(var e=-1,r=n;++e<6;)r+=t*s[e],s[e]=r%1e7,r=c(r/1e7)},h=function(t){for(var n=6,e=0;--n>=0;)e+=s[n],s[n]=c(e/t),e=e%t*1e7},p=function(){for(var t=6,n="";--t>=0;)if(""!==n||0===t||0!==s[t]){var e=String(s[t]);n=""===n?e:n+u.call("0",7-e.length)+e}return n},v=function(t,n,e){return 0===n?e:n%2==1?v(t,n-1,e*t):v(t*t,n/2,e)};r(r.P+r.F*(!!a&&("0.000"!==8e-5.toFixed(3)||"1"!==.9.toFixed(0)||"1.25"!==1.255.toFixed(2)||"1000000000000000128"!==(0xde0b6b3a7640080).toFixed(0))||!e(3)((function(){a.call({})}))),"Number",{toFixed:function(t){var n,e,r,a,c=o(this,f),s=i(t),d="",g="0";if(s<0||s>20)throw RangeError(f);if(c!=c)return"NaN";if(c<=-1e21||c>=1e21)return String(c);if(c<0&&(d="-",c=-c),c>1e-21)if(e=(n=function(t){for(var n=0,e=t;e>=4096;)n+=12,e/=4096;for(;e>=2;)n+=1,e/=2;return n}(c*v(2,69,1))-69)<0?c*v(2,-n,1):c/v(2,n,1),e*=4503599627370496,(n=52-n)>0){for(l(0,e),r=s;r>=7;)l(1e7,0),r-=7;for(l(v(10,r,1),0),r=n-1;r>=23;)h(1<<23),r-=23;h(1<0?d+((a=g.length)<=s?"0."+u.call("0",s-a)+g:g.slice(0,a-s)+"."+g.slice(a-s)):d+g}})},function(t,n,e){"use strict";var r=e(0),i=e(3),o=e(106),u=1..toPrecision;r(r.P+r.F*(i((function(){return"1"!==u.call(1,void 0)}))||!i((function(){u.call({})}))),"Number",{toPrecision:function(t){var n=o(this,"Number#toPrecision: incorrect invocation!");return void 0===t?u.call(n):u.call(n,t)}})},function(t,n,e){var r=e(0);r(r.S,"Number",{EPSILON:Math.pow(2,-52)})},function(t,n,e){var r=e(0),i=e(2).isFinite;r(r.S,"Number",{isFinite:function(t){return"number"==typeof t&&i(t)}})},function(t,n,e){var r=e(0);r(r.S,"Number",{isInteger:e(107)})},function(t,n,e){var r=e(0);r(r.S,"Number",{isNaN:function(t){return t!=t}})},function(t,n,e){var r=e(0),i=e(107),o=Math.abs;r(r.S,"Number",{isSafeInteger:function(t){return i(t)&&o(t)<=9007199254740991}})},function(t,n,e){var r=e(0);r(r.S,"Number",{MAX_SAFE_INTEGER:9007199254740991})},function(t,n,e){var r=e(0);r(r.S,"Number",{MIN_SAFE_INTEGER:-9007199254740991})},function(t,n,e){var r=e(0),i=e(105);r(r.S+r.F*(Number.parseFloat!=i),"Number",{parseFloat:i})},function(t,n,e){var r=e(0),i=e(104);r(r.S+r.F*(Number.parseInt!=i),"Number",{parseInt:i})},function(t,n,e){var r=e(0),i=e(108),o=Math.sqrt,u=Math.acosh;r(r.S+r.F*!(u&&710==Math.floor(u(Number.MAX_VALUE))&&u(1/0)==1/0),"Math",{acosh:function(t){return(t=+t)<1?NaN:t>94906265.62425156?Math.log(t)+Math.LN2:i(t-1+o(t-1)*o(t+1))}})},function(t,n,e){var r=e(0),i=Math.asinh;r(r.S+r.F*!(i&&1/i(0)>0),"Math",{asinh:function t(n){return isFinite(n=+n)&&0!=n?n<0?-t(-n):Math.log(n+Math.sqrt(n*n+1)):n}})},function(t,n,e){var r=e(0),i=Math.atanh;r(r.S+r.F*!(i&&1/i(-0)<0),"Math",{atanh:function(t){return 0==(t=+t)?t:Math.log((1+t)/(1-t))/2}})},function(t,n,e){var r=e(0),i=e(76);r(r.S,"Math",{cbrt:function(t){return i(t=+t)*Math.pow(Math.abs(t),1/3)}})},function(t,n,e){var r=e(0);r(r.S,"Math",{clz32:function(t){return(t>>>=0)?31-Math.floor(Math.log(t+.5)*Math.LOG2E):32}})},function(t,n,e){var r=e(0),i=Math.exp;r(r.S,"Math",{cosh:function(t){return(i(t=+t)+i(-t))/2}})},function(t,n,e){var r=e(0),i=e(77);r(r.S+r.F*(i!=Math.expm1),"Math",{expm1:i})},function(t,n,e){var r=e(0);r(r.S,"Math",{fround:e(109)})},function(t,n,e){var r=e(0),i=Math.abs;r(r.S,"Math",{hypot:function(t,n){for(var e,r,o=0,u=0,a=arguments.length,c=0;u0?(r=e/c)*r:e;return c===1/0?1/0:c*Math.sqrt(o)}})},function(t,n,e){var r=e(0),i=Math.imul;r(r.S+r.F*e(3)((function(){return-5!=i(4294967295,5)||2!=i.length})),"Math",{imul:function(t,n){var e=+t,r=+n,i=65535&e,o=65535&r;return 0|i*o+((65535&e>>>16)*o+i*(65535&r>>>16)<<16>>>0)}})},function(t,n,e){var r=e(0);r(r.S,"Math",{log10:function(t){return Math.log(t)*Math.LOG10E}})},function(t,n,e){var r=e(0);r(r.S,"Math",{log1p:e(108)})},function(t,n,e){var r=e(0);r(r.S,"Math",{log2:function(t){return Math.log(t)/Math.LN2}})},function(t,n,e){var r=e(0);r(r.S,"Math",{sign:e(76)})},function(t,n,e){var r=e(0),i=e(77),o=Math.exp;r(r.S+r.F*e(3)((function(){return-2e-17!=!Math.sinh(-2e-17)})),"Math",{sinh:function(t){return Math.abs(t=+t)<1?(i(t)-i(-t))/2:(o(t-1)-o(-t-1))*(Math.E/2)}})},function(t,n,e){var r=e(0),i=e(77),o=Math.exp;r(r.S,"Math",{tanh:function(t){var n=i(t=+t),e=i(-t);return n==1/0?1:e==1/0?-1:(n-e)/(o(t)+o(-t))}})},function(t,n,e){var r=e(0);r(r.S,"Math",{trunc:function(t){return(t>0?Math.floor:Math.ceil)(t)}})},function(t,n,e){var r=e(0),i=e(35),o=String.fromCharCode,u=String.fromCodePoint;r(r.S+r.F*(!!u&&1!=u.length),"String",{fromCodePoint:function(t){for(var n,e=[],r=arguments.length,u=0;r>u;){if(n=+arguments[u++],i(n,1114111)!==n)throw RangeError(n+" is not a valid code point");e.push(n<65536?o(n):o(55296+((n-=65536)>>10),n%1024+56320))}return e.join("")}})},function(t,n,e){var r=e(0),i=e(15),o=e(6);r(r.S,"String",{raw:function(t){for(var n=i(t.raw),e=o(n.length),r=arguments.length,u=[],a=0;e>a;)u.push(String(n[a++])),a=n.length?{value:void 0,done:!0}:(t=r(n,e),this._i+=t.length,{value:t,done:!1})}))},function(t,n,e){"use strict";var r=e(0),i=e(55)(!1);r(r.P,"String",{codePointAt:function(t){return i(this,t)}})},function(t,n,e){"use strict";var r=e(0),i=e(6),o=e(80),u="".endsWith;r(r.P+r.F*e(81)("endsWith"),"String",{endsWith:function(t){var n=o(this,t,"endsWith"),e=arguments.length>1?arguments[1]:void 0,r=i(n.length),a=void 0===e?r:Math.min(i(e),r),c=String(t);return u?u.call(n,c,a):n.slice(a-c.length,a)===c}})},function(t,n,e){"use strict";var r=e(0),i=e(80);r(r.P+r.F*e(81)("includes"),"String",{includes:function(t){return!!~i(this,t,"includes").indexOf(t,arguments.length>1?arguments[1]:void 0)}})},function(t,n,e){var r=e(0);r(r.P,"String",{repeat:e(75)})},function(t,n,e){"use strict";var r=e(0),i=e(6),o=e(80),u="".startsWith;r(r.P+r.F*e(81)("startsWith"),"String",{startsWith:function(t){var n=o(this,t,"startsWith"),e=i(Math.min(arguments.length>1?arguments[1]:void 0,n.length)),r=String(t);return u?u.call(n,r,e):n.slice(e,e+r.length)===r}})},function(t,n,e){"use strict";e(13)("anchor",(function(t){return function(n){return t(this,"a","name",n)}}))},function(t,n,e){"use strict";e(13)("big",(function(t){return function(){return t(this,"big","","")}}))},function(t,n,e){"use strict";e(13)("blink",(function(t){return function(){return t(this,"blink","","")}}))},function(t,n,e){"use strict";e(13)("bold",(function(t){return function(){return t(this,"b","","")}}))},function(t,n,e){"use strict";e(13)("fixed",(function(t){return function(){return t(this,"tt","","")}}))},function(t,n,e){"use strict";e(13)("fontcolor",(function(t){return function(n){return t(this,"font","color",n)}}))},function(t,n,e){"use strict";e(13)("fontsize",(function(t){return function(n){return t(this,"font","size",n)}}))},function(t,n,e){"use strict";e(13)("italics",(function(t){return function(){return t(this,"i","","")}}))},function(t,n,e){"use strict";e(13)("link",(function(t){return function(n){return t(this,"a","href",n)}}))},function(t,n,e){"use strict";e(13)("small",(function(t){return function(){return t(this,"small","","")}}))},function(t,n,e){"use strict";e(13)("strike",(function(t){return function(){return t(this,"strike","","")}}))},function(t,n,e){"use strict";e(13)("sub",(function(t){return function(){return t(this,"sub","","")}}))},function(t,n,e){"use strict";e(13)("sup",(function(t){return function(){return t(this,"sup","","")}}))},function(t,n,e){var r=e(0);r(r.S,"Date",{now:function(){return(new Date).getTime()}})},function(t,n,e){"use strict";var r=e(0),i=e(9),o=e(23);r(r.P+r.F*e(3)((function(){return null!==new Date(NaN).toJSON()||1!==Date.prototype.toJSON.call({toISOString:function(){return 1}})})),"Date",{toJSON:function(t){var n=i(this),e=o(n);return"number"!=typeof e||isFinite(e)?n.toISOString():null}})},function(t,n,e){var r=e(0),i=e(213);r(r.P+r.F*(Date.prototype.toISOString!==i),"Date",{toISOString:i})},function(t,n,e){"use strict";var r=e(3),i=Date.prototype.getTime,o=Date.prototype.toISOString,u=function(t){return t>9?t:"0"+t};t.exports=r((function(){return"0385-07-25T07:06:39.999Z"!=o.call(new Date(-5e13-1))}))||!r((function(){o.call(new Date(NaN))}))?function(){if(!isFinite(i.call(this)))throw RangeError("Invalid time value");var t=this,n=t.getUTCFullYear(),e=t.getUTCMilliseconds(),r=n<0?"-":n>9999?"+":"";return r+("00000"+Math.abs(n)).slice(r?-6:-4)+"-"+u(t.getUTCMonth()+1)+"-"+u(t.getUTCDate())+"T"+u(t.getUTCHours())+":"+u(t.getUTCMinutes())+":"+u(t.getUTCSeconds())+"."+(e>99?e:"0"+u(e))+"Z"}:o},function(t,n,e){var r=Date.prototype,i=r.toString,o=r.getTime;new Date(NaN)+""!="Invalid Date"&&e(12)(r,"toString",(function(){var t=o.call(this);return t==t?i.call(this):"Invalid Date"}))},function(t,n,e){var r=e(5)("toPrimitive"),i=Date.prototype;r in i||e(11)(i,r,e(216))},function(t,n,e){"use strict";var r=e(1),i=e(23);t.exports=function(t){if("string"!==t&&"number"!==t&&"default"!==t)throw TypeError("Incorrect hint");return i(r(this),"number"!=t)}},function(t,n,e){var r=e(0);r(r.S,"Array",{isArray:e(54)})},function(t,n,e){"use strict";var r=e(19),i=e(0),o=e(9),u=e(110),a=e(82),c=e(6),s=e(83),f=e(84);i(i.S+i.F*!e(57)((function(t){Array.from(t)})),"Array",{from:function(t){var n,e,i,l,h=o(t),p="function"==typeof this?this:Array,v=arguments.length,d=v>1?arguments[1]:void 0,g=void 0!==d,y=0,m=f(h);if(g&&(d=r(d,v>2?arguments[2]:void 0,2)),null==m||p==Array&&a(m))for(e=new p(n=c(h.length));n>y;y++)s(e,y,g?d(h[y],y):h[y]);else for(l=m.call(h),e=new p;!(i=l.next()).done;y++)s(e,y,g?u(l,d,[i.value,y],!0):i.value);return e.length=y,e}})},function(t,n,e){"use strict";var r=e(0),i=e(83);r(r.S+r.F*e(3)((function(){function t(){}return!(Array.of.call(t)instanceof t)})),"Array",{of:function(){for(var t=0,n=arguments.length,e=new("function"==typeof this?this:Array)(n);n>t;)i(e,t,arguments[t++]);return e.length=n,e}})},function(t,n,e){"use strict";var r=e(0),i=e(15),o=[].join;r(r.P+r.F*(e(48)!=Object||!e(22)(o)),"Array",{join:function(t){return o.call(i(this),void 0===t?",":t)}})},function(t,n,e){"use strict";var r=e(0),i=e(71),o=e(20),u=e(35),a=e(6),c=[].slice;r(r.P+r.F*e(3)((function(){i&&c.call(i)})),"Array",{slice:function(t,n){var e=a(this.length),r=o(this);if(n=void 0===n?e:n,"Array"==r)return c.call(this,t,n);for(var i=u(t,e),s=u(n,e),f=a(s-i),l=new Array(f),h=0;h1&&(r=Math.min(r,o(arguments[1]))),r<0&&(r=e+r);r>=0;r--)if(r in n&&n[r]===t)return r||0;return-1}})},function(t,n,e){var r=e(0);r(r.P,"Array",{copyWithin:e(112)}),e(31)("copyWithin")},function(t,n,e){var r=e(0);r(r.P,"Array",{fill:e(86)}),e(31)("fill")},function(t,n,e){"use strict";var r=e(0),i=e(26)(5),o=!0;"find"in[]&&Array(1).find((function(){o=!1})),r(r.P+r.F*o,"Array",{find:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}}),e(31)("find")},function(t,n,e){"use strict";var r=e(0),i=e(26)(6),o="findIndex",u=!0;o in[]&&Array(1)[o]((function(){u=!1})),r(r.P+r.F*u,"Array",{findIndex:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}}),e(31)(o)},function(t,n,e){e(38)("Array")},function(t,n,e){var r=e(2),i=e(74),o=e(8).f,u=e(37).f,a=e(56),c=e(50),s=r.RegExp,f=s,l=s.prototype,h=/a/g,p=/a/g,v=new s(h)!==h;if(e(7)&&(!v||e(3)((function(){return p[e(5)("match")]=!1,s(h)!=h||s(p)==p||"/a/i"!=s(h,"i")})))){s=function(t,n){var e=this instanceof s,r=a(t),o=void 0===n;return!e&&r&&t.constructor===s&&o?t:i(v?new f(r&&!o?t.source:t,n):f((r=t instanceof s)?t.source:t,r&&o?c.call(t):n),e?this:l,s)};for(var d=function(t){t in s||o(s,t,{configurable:!0,get:function(){return f[t]},set:function(n){f[t]=n}})},g=u(f),y=0;g.length>y;)d(g[y++]);l.constructor=s,s.prototype=l,e(12)(r,"RegExp",s)}e(38)("RegExp")},function(t,n,e){"use strict";e(115);var r=e(1),i=e(50),o=e(7),u=/./.toString,a=function(t){e(12)(RegExp.prototype,"toString",t,!0)};e(3)((function(){return"/a/b"!=u.call({source:"a",flags:"b"})}))?a((function(){var t=r(this);return"/".concat(t.source,"/","flags"in t?t.flags:!o&&t instanceof RegExp?i.call(t):void 0)})):"toString"!=u.name&&a((function(){return u.call(this)}))},function(t,n,e){"use strict";var r=e(1),i=e(6),o=e(89),u=e(58);e(59)("match",1,(function(t,n,e,a){return[function(e){var r=t(this),i=null==e?void 0:e[n];return void 0!==i?i.call(e,r):new RegExp(e)[n](String(r))},function(t){var n=a(e,t,this);if(n.done)return n.value;var c=r(t),s=String(this);if(!c.global)return u(c,s);var f=c.unicode;c.lastIndex=0;for(var l,h=[],p=0;null!==(l=u(c,s));){var v=String(l[0]);h[p]=v,""===v&&(c.lastIndex=o(s,i(c.lastIndex),f)),p++}return 0===p?null:h}]}))},function(t,n,e){"use strict";var r=e(1),i=e(9),o=e(6),u=e(21),a=e(89),c=e(58),s=Math.max,f=Math.min,l=Math.floor,h=/\$([$&`']|\d\d?|<[^>]*>)/g,p=/\$([$&`']|\d\d?)/g;e(59)("replace",2,(function(t,n,e,v){return[function(r,i){var o=t(this),u=null==r?void 0:r[n];return void 0!==u?u.call(r,o,i):e.call(String(o),r,i)},function(t,n){var i=v(e,t,this,n);if(i.done)return i.value;var l=r(t),h=String(this),p="function"==typeof n;p||(n=String(n));var g=l.global;if(g){var y=l.unicode;l.lastIndex=0}for(var m=[];;){var b=c(l,h);if(null===b)break;if(m.push(b),!g)break;""===String(b[0])&&(l.lastIndex=a(h,o(l.lastIndex),y))}for(var w,_="",x=0,S=0;S=x&&(_+=h.slice(x,O)+j,x=O+A.length)}return _+h.slice(x)}];function d(t,n,r,o,u,a){var c=r+t.length,s=o.length,f=p;return void 0!==u&&(u=i(u),f=h),e.call(a,f,(function(e,i){var a;switch(i.charAt(0)){case"$":return"$";case"&":return t;case"`":return n.slice(0,r);case"'":return n.slice(c);case"<":a=u[i.slice(1,-1)];break;default:var f=+i;if(0===f)return e;if(f>s){var h=l(f/10);return 0===h?e:h<=s?void 0===o[h-1]?i.charAt(1):o[h-1]+i.charAt(1):e}a=o[f-1]}return void 0===a?"":a}))}}))},function(t,n,e){"use strict";var r=e(1),i=e(101),o=e(58);e(59)("search",1,(function(t,n,e,u){return[function(e){var r=t(this),i=null==e?void 0:e[n];return void 0!==i?i.call(e,r):new RegExp(e)[n](String(r))},function(t){var n=u(e,t,this);if(n.done)return n.value;var a=r(t),c=String(this),s=a.lastIndex;i(s,0)||(a.lastIndex=0);var f=o(a,c);return i(a.lastIndex,s)||(a.lastIndex=s),null===f?-1:f.index}]}))},function(t,n,e){"use strict";var r=e(56),i=e(1),o=e(51),u=e(89),a=e(6),c=e(58),s=e(88),f=e(3),l=Math.min,h=[].push,p=!f((function(){RegExp(4294967295,"y")}));e(59)("split",2,(function(t,n,e,f){var v;return v="c"=="abbc".split(/(b)*/)[1]||4!="test".split(/(?:)/,-1).length||2!="ab".split(/(?:ab)*/).length||4!=".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length?function(t,n){var i=String(this);if(void 0===t&&0===n)return[];if(!r(t))return e.call(i,t,n);for(var o,u,a,c=[],f=(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.unicode?"u":"")+(t.sticky?"y":""),l=0,p=void 0===n?4294967295:n>>>0,v=new RegExp(t.source,f+"g");(o=s.call(v,i))&&!((u=v.lastIndex)>l&&(c.push(i.slice(l,o.index)),o.length>1&&o.index=p));)v.lastIndex===o.index&&v.lastIndex++;return l===i.length?!a&&v.test("")||c.push(""):c.push(i.slice(l)),c.length>p?c.slice(0,p):c}:"0".split(void 0,0).length?function(t,n){return void 0===t&&0===n?[]:e.call(this,t,n)}:e,[function(e,r){var i=t(this),o=null==e?void 0:e[n];return void 0!==o?o.call(e,i,r):v.call(String(i),e,r)},function(t,n){var r=f(v,t,this,n,v!==e);if(r.done)return r.value;var s=i(t),h=String(this),d=o(s,RegExp),g=s.unicode,y=(s.ignoreCase?"i":"")+(s.multiline?"m":"")+(s.unicode?"u":"")+(p?"y":"g"),m=new d(p?s:"^(?:"+s.source+")",y),b=void 0===n?4294967295:n>>>0;if(0===b)return[];if(0===h.length)return null===c(m,h)?[h]:[];for(var w=0,_=0,x=[];_o;)u(e[o++]);t._c=[],t._n=!1,n&&!t._h&&T(t)}))}},T=function(t){y.call(c,(function(){var n,e,r,i=t._v,o=R(t);if(o&&(n=w((function(){M?A.emit("unhandledRejection",i,t):(e=c.onunhandledrejection)?e({promise:t,reason:i}):(r=c.console)&&r.error&&r.error("Unhandled promise rejection",i)})),t._h=M||R(t)?2:1),t._a=void 0,o&&n.e)throw n.v}))},R=function(t){return 1!==t._h&&0===(t._a||t._c).length},L=function(t){y.call(c,(function(){var n;M?A.emit("rejectionHandled",t):(n=c.onrejectionhandled)&&n({promise:t,reason:t._v})}))},N=function(t){var n=this;n._d||(n._d=!0,(n=n._w||n)._v=t,n._s=2,n._a||(n._a=n._c.slice()),C(n,!0))},D=function(t){var n,e=this;if(!e._d){e._d=!0,e=e._w||e;try{if(e===t)throw S("Promise can't be resolved itself");(n=I(t))?m((function(){var r={_w:e,_d:!1};try{n.call(t,s(D,r,1),s(N,r,1))}catch(t){N.call(r,t)}})):(e._v=t,e._s=1,C(e,!1))}catch(t){N.call({_w:e,_d:!1},t)}}};F||(P=function(t){v(this,P,"Promise","_h"),p(t),r.call(this);try{t(s(D,this,1),s(N,this,1))}catch(t){N.call(this,t)}},(r=function(t){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1}).prototype=e(41)(P.prototype,{then:function(t,n){var e=j(g(this,P));return e.ok="function"!=typeof t||t,e.fail="function"==typeof n&&n,e.domain=M?A.domain:void 0,this._c.push(e),this._a&&this._a.push(e),this._s&&C(this,!1),e.promise},catch:function(t){return this.then(void 0,t)}}),o=function(){var t=new r;this.promise=t,this.resolve=s(D,t,1),this.reject=s(N,t,1)},b.f=j=function(t){return t===P||t===u?new o(t):i(t)}),l(l.G+l.W+l.F*!F,{Promise:P}),e(43)(P,"Promise"),e(38)("Promise"),u=e(18).Promise,l(l.S+l.F*!F,"Promise",{reject:function(t){var n=j(this);return(0,n.reject)(t),n.promise}}),l(l.S+l.F*(a||!F),"Promise",{resolve:function(t){return x(a&&this===u?P:this,t)}}),l(l.S+l.F*!(F&&e(57)((function(t){P.all(t).catch(k)}))),"Promise",{all:function(t){var n=this,e=j(n),r=e.resolve,i=e.reject,o=w((function(){var e=[],o=0,u=1;d(t,!1,(function(t){var a=o++,c=!1;e.push(void 0),u++,n.resolve(t).then((function(t){c||(c=!0,e[a]=t,--u||r(e))}),i)})),--u||r(e)}));return o.e&&i(o.v),e.promise},race:function(t){var n=this,e=j(n),r=e.reject,i=w((function(){d(t,!1,(function(t){n.resolve(t).then(e.resolve,r)}))}));return i.e&&r(i.v),e.promise}})},function(t,n,e){"use strict";var r=e(122),i=e(42);e(61)("WeakSet",(function(t){return function(){return t(this,arguments.length>0?arguments[0]:void 0)}}),{add:function(t){return r.def(i(this,"WeakSet"),t,!0)}},r,!1,!0)},function(t,n,e){"use strict";var r=e(0),i=e(62),o=e(93),u=e(1),a=e(35),c=e(6),s=e(4),f=e(2).ArrayBuffer,l=e(51),h=o.ArrayBuffer,p=o.DataView,v=i.ABV&&f.isView,d=h.prototype.slice,g=i.VIEW;r(r.G+r.W+r.F*(f!==h),{ArrayBuffer:h}),r(r.S+r.F*!i.CONSTR,"ArrayBuffer",{isView:function(t){return v&&v(t)||s(t)&&g in t}}),r(r.P+r.U+r.F*e(3)((function(){return!new h(2).slice(1,void 0).byteLength})),"ArrayBuffer",{slice:function(t,n){if(void 0!==d&&void 0===n)return d.call(u(this),t);for(var e=u(this).byteLength,r=a(t,e),i=a(void 0===n?e:n,e),o=new(l(this,h))(c(i-r)),s=new p(this),f=new p(o),v=0;r=n.length)return{value:void 0,done:!0}}while(!((t=n[this._i++])in this._t));return{value:t,done:!1}})),r(r.S,"Reflect",{enumerate:function(t){return new o(t)}})},function(t,n,e){var r=e(16),i=e(17),o=e(14),u=e(0),a=e(4),c=e(1);u(u.S,"Reflect",{get:function t(n,e){var u,s,f=arguments.length<3?n:arguments[2];return c(n)===f?n[e]:(u=r.f(n,e))?o(u,"value")?u.value:void 0!==u.get?u.get.call(f):void 0:a(s=i(n))?t(s,e,f):void 0}})},function(t,n,e){var r=e(16),i=e(0),o=e(1);i(i.S,"Reflect",{getOwnPropertyDescriptor:function(t,n){return r.f(o(t),n)}})},function(t,n,e){var r=e(0),i=e(17),o=e(1);r(r.S,"Reflect",{getPrototypeOf:function(t){return i(o(t))}})},function(t,n,e){var r=e(0);r(r.S,"Reflect",{has:function(t,n){return n in t}})},function(t,n,e){var r=e(0),i=e(1),o=Object.isExtensible;r(r.S,"Reflect",{isExtensible:function(t){return i(t),!o||o(t)}})},function(t,n,e){var r=e(0);r(r.S,"Reflect",{ownKeys:e(124)})},function(t,n,e){var r=e(0),i=e(1),o=Object.preventExtensions;r(r.S,"Reflect",{preventExtensions:function(t){i(t);try{return o&&o(t),!0}catch(t){return!1}}})},function(t,n,e){var r=e(8),i=e(16),o=e(17),u=e(14),a=e(0),c=e(32),s=e(1),f=e(4);a(a.S,"Reflect",{set:function t(n,e,a){var l,h,p=arguments.length<4?n:arguments[3],v=i.f(s(n),e);if(!v){if(f(h=o(n)))return t(h,e,a,p);v=c(0)}if(u(v,"value")){if(!1===v.writable||!f(p))return!1;if(l=i.f(p,e)){if(l.get||l.set||!1===l.writable)return!1;l.value=a,r.f(p,e,l)}else r.f(p,e,c(0,a));return!0}return void 0!==v.set&&(v.set.call(p,a),!0)}})},function(t,n,e){var r=e(0),i=e(72);i&&r(r.S,"Reflect",{setPrototypeOf:function(t,n){i.check(t,n);try{return i.set(t,n),!0}catch(t){return!1}}})},function(t,n,e){"use strict";var r=e(0),i=e(52)(!0);r(r.P,"Array",{includes:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0)}}),e(31)("includes")},function(t,n,e){"use strict";var r=e(0),i=e(125),o=e(9),u=e(6),a=e(10),c=e(85);r(r.P,"Array",{flatMap:function(t){var n,e,r=o(this);return a(t),n=u(r.length),e=c(r,0),i(e,r,r,n,0,1,t,arguments[1]),e}}),e(31)("flatMap")},function(t,n,e){"use strict";var r=e(0),i=e(125),o=e(9),u=e(6),a=e(21),c=e(85);r(r.P,"Array",{flatten:function(){var t=arguments[0],n=o(this),e=u(n.length),r=c(n,0);return i(r,n,n,e,0,void 0===t?1:a(t)),r}}),e(31)("flatten")},function(t,n,e){"use strict";var r=e(0),i=e(55)(!0);r(r.P,"String",{at:function(t){return i(this,t)}})},function(t,n,e){"use strict";var r=e(0),i=e(126),o=e(60),u=/Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(o);r(r.P+r.F*u,"String",{padStart:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0,!0)}})},function(t,n,e){"use strict";var r=e(0),i=e(126),o=e(60),u=/Version\/10\.\d+(\.\d+)?( Mobile\/\w+)? Safari\//.test(o);r(r.P+r.F*u,"String",{padEnd:function(t){return i(this,t,arguments.length>1?arguments[1]:void 0,!1)}})},function(t,n,e){"use strict";e(45)("trimLeft",(function(t){return function(){return t(this,1)}}),"trimStart")},function(t,n,e){"use strict";e(45)("trimRight",(function(t){return function(){return t(this,2)}}),"trimEnd")},function(t,n,e){"use strict";var r=e(0),i=e(24),o=e(6),u=e(56),a=e(50),c=RegExp.prototype,s=function(t,n){this._r=t,this._s=n};e(79)(s,"RegExp String",(function(){var t=this._r.exec(this._s);return{value:t,done:null===t}})),r(r.P,"String",{matchAll:function(t){if(i(this),!u(t))throw TypeError(t+" is not a regexp!");var n=String(this),e="flags"in c?String(t.flags):a.call(t),r=new RegExp(t.source,~e.indexOf("g")?e:"g"+e);return r.lastIndex=o(t.lastIndex),new s(r,n)}})},function(t,n,e){e(68)("asyncIterator")},function(t,n,e){e(68)("observable")},function(t,n,e){var r=e(0),i=e(124),o=e(15),u=e(16),a=e(83);r(r.S,"Object",{getOwnPropertyDescriptors:function(t){for(var n,e,r=o(t),c=u.f,s=i(r),f={},l=0;s.length>l;)void 0!==(e=c(r,n=s[l++]))&&a(f,n,e);return f}})},function(t,n,e){var r=e(0),i=e(127)(!1);r(r.S,"Object",{values:function(t){return i(t)}})},function(t,n,e){var r=e(0),i=e(127)(!0);r(r.S,"Object",{entries:function(t){return i(t)}})},function(t,n,e){"use strict";var r=e(0),i=e(9),o=e(10),u=e(8);e(7)&&r(r.P+e(63),"Object",{__defineGetter__:function(t,n){u.f(i(this),t,{get:o(n),enumerable:!0,configurable:!0})}})},function(t,n,e){"use strict";var r=e(0),i=e(9),o=e(10),u=e(8);e(7)&&r(r.P+e(63),"Object",{__defineSetter__:function(t,n){u.f(i(this),t,{set:o(n),enumerable:!0,configurable:!0})}})},function(t,n,e){"use strict";var r=e(0),i=e(9),o=e(23),u=e(17),a=e(16).f;e(7)&&r(r.P+e(63),"Object",{__lookupGetter__:function(t){var n,e=i(this),r=o(t,!0);do{if(n=a(e,r))return n.get}while(e=u(e))}})},function(t,n,e){"use strict";var r=e(0),i=e(9),o=e(23),u=e(17),a=e(16).f;e(7)&&r(r.P+e(63),"Object",{__lookupSetter__:function(t){var n,e=i(this),r=o(t,!0);do{if(n=a(e,r))return n.set}while(e=u(e))}})},function(t,n,e){var r=e(0);r(r.P+r.R,"Map",{toJSON:e(128)("Map")})},function(t,n,e){var r=e(0);r(r.P+r.R,"Set",{toJSON:e(128)("Set")})},function(t,n,e){e(64)("Map")},function(t,n,e){e(64)("Set")},function(t,n,e){e(64)("WeakMap")},function(t,n,e){e(64)("WeakSet")},function(t,n,e){e(65)("Map")},function(t,n,e){e(65)("Set")},function(t,n,e){e(65)("WeakMap")},function(t,n,e){e(65)("WeakSet")},function(t,n,e){var r=e(0);r(r.G,{global:e(2)})},function(t,n,e){var r=e(0);r(r.S,"System",{global:e(2)})},function(t,n,e){var r=e(0),i=e(20);r(r.S,"Error",{isError:function(t){return"Error"===i(t)}})},function(t,n,e){var r=e(0);r(r.S,"Math",{clamp:function(t,n,e){return Math.min(e,Math.max(n,t))}})},function(t,n,e){var r=e(0);r(r.S,"Math",{DEG_PER_RAD:Math.PI/180})},function(t,n,e){var r=e(0),i=180/Math.PI;r(r.S,"Math",{degrees:function(t){return t*i}})},function(t,n,e){var r=e(0),i=e(130),o=e(109);r(r.S,"Math",{fscale:function(t,n,e,r,u){return o(i(t,n,e,r,u))}})},function(t,n,e){var r=e(0);r(r.S,"Math",{iaddh:function(t,n,e,r){var i=t>>>0,o=e>>>0;return(n>>>0)+(r>>>0)+((i&o|(i|o)&~(i+o>>>0))>>>31)|0}})},function(t,n,e){var r=e(0);r(r.S,"Math",{isubh:function(t,n,e,r){var i=t>>>0,o=e>>>0;return(n>>>0)-(r>>>0)-((~i&o|~(i^o)&i-o>>>0)>>>31)|0}})},function(t,n,e){var r=e(0);r(r.S,"Math",{imulh:function(t,n){var e=+t,r=+n,i=65535&e,o=65535&r,u=e>>16,a=r>>16,c=(u*o>>>0)+(i*o>>>16);return u*a+(c>>16)+((i*a>>>0)+(65535&c)>>16)}})},function(t,n,e){var r=e(0);r(r.S,"Math",{RAD_PER_DEG:180/Math.PI})},function(t,n,e){var r=e(0),i=Math.PI/180;r(r.S,"Math",{radians:function(t){return t*i}})},function(t,n,e){var r=e(0);r(r.S,"Math",{scale:e(130)})},function(t,n,e){var r=e(0);r(r.S,"Math",{umulh:function(t,n){var e=+t,r=+n,i=65535&e,o=65535&r,u=e>>>16,a=r>>>16,c=(u*o>>>0)+(i*o>>>16);return u*a+(c>>>16)+((i*a>>>0)+(65535&c)>>>16)}})},function(t,n,e){var r=e(0);r(r.S,"Math",{signbit:function(t){return(t=+t)!=t?t:0==t?1/t==1/0:t>0}})},function(t,n,e){"use strict";var r=e(0),i=e(18),o=e(2),u=e(51),a=e(117);r(r.P+r.R,"Promise",{finally:function(t){var n=u(this,i.Promise||o.Promise),e="function"==typeof t;return this.then(e?function(e){return a(n,t()).then((function(){return e}))}:t,e?function(e){return a(n,t()).then((function(){throw e}))}:t)}})},function(t,n,e){"use strict";var r=e(0),i=e(92),o=e(116);r(r.S,"Promise",{try:function(t){var n=i.f(this),e=o(t);return(e.e?n.reject:n.resolve)(e.v),n.promise}})},function(t,n,e){var r=e(28),i=e(1),o=r.key,u=r.set;r.exp({defineMetadata:function(t,n,e,r){u(t,n,i(e),o(r))}})},function(t,n,e){var r=e(28),i=e(1),o=r.key,u=r.map,a=r.store;r.exp({deleteMetadata:function(t,n){var e=arguments.length<3?void 0:o(arguments[2]),r=u(i(n),e,!1);if(void 0===r||!r.delete(t))return!1;if(r.size)return!0;var c=a.get(n);return c.delete(e),!!c.size||a.delete(n)}})},function(t,n,e){var r=e(28),i=e(1),o=e(17),u=r.has,a=r.get,c=r.key,s=function(t,n,e){if(u(t,n,e))return a(t,n,e);var r=o(n);return null!==r?s(t,r,e):void 0};r.exp({getMetadata:function(t,n){return s(t,i(n),arguments.length<3?void 0:c(arguments[2]))}})},function(t,n,e){var r=e(120),i=e(129),o=e(28),u=e(1),a=e(17),c=o.keys,s=o.key,f=function(t,n){var e=c(t,n),o=a(t);if(null===o)return e;var u=f(o,n);return u.length?e.length?i(new r(e.concat(u))):u:e};o.exp({getMetadataKeys:function(t){return f(u(t),arguments.length<2?void 0:s(arguments[1]))}})},function(t,n,e){var r=e(28),i=e(1),o=r.get,u=r.key;r.exp({getOwnMetadata:function(t,n){return o(t,i(n),arguments.length<3?void 0:u(arguments[2]))}})},function(t,n,e){var r=e(28),i=e(1),o=r.keys,u=r.key;r.exp({getOwnMetadataKeys:function(t){return o(i(t),arguments.length<2?void 0:u(arguments[1]))}})},function(t,n,e){var r=e(28),i=e(1),o=e(17),u=r.has,a=r.key,c=function(t,n,e){if(u(t,n,e))return!0;var r=o(n);return null!==r&&c(t,r,e)};r.exp({hasMetadata:function(t,n){return c(t,i(n),arguments.length<3?void 0:a(arguments[2]))}})},function(t,n,e){var r=e(28),i=e(1),o=r.has,u=r.key;r.exp({hasOwnMetadata:function(t,n){return o(t,i(n),arguments.length<3?void 0:u(arguments[2]))}})},function(t,n,e){var r=e(28),i=e(1),o=e(10),u=r.key,a=r.set;r.exp({metadata:function(t,n){return function(e,r){a(t,n,(void 0!==r?i:o)(e),u(r))}}})},function(t,n,e){var r=e(0),i=e(91)(),o=e(2).process,u="process"==e(20)(o);r(r.G,{asap:function(t){var n=u&&o.domain;i(n?n.bind(t):t)}})},function(t,n,e){"use strict";var r=e(0),i=e(2),o=e(18),u=e(91)(),a=e(5)("observable"),c=e(10),s=e(1),f=e(39),l=e(41),h=e(11),p=e(40),v=p.RETURN,d=function(t){return null==t?void 0:c(t)},g=function(t){var n=t._c;n&&(t._c=void 0,n())},y=function(t){return void 0===t._o},m=function(t){y(t)||(t._o=void 0,g(t))},b=function(t,n){s(t),this._c=void 0,this._o=t,t=new w(this);try{var e=n(t),r=e;null!=e&&("function"==typeof e.unsubscribe?e=function(){r.unsubscribe()}:c(e),this._c=e)}catch(n){return void t.error(n)}y(this)&&g(this)};b.prototype=l({},{unsubscribe:function(){m(this)}});var w=function(t){this._s=t};w.prototype=l({},{next:function(t){var n=this._s;if(!y(n)){var e=n._o;try{var r=d(e.next);if(r)return r.call(e,t)}catch(t){try{m(n)}finally{throw t}}}},error:function(t){var n=this._s;if(y(n))throw t;var e=n._o;n._o=void 0;try{var r=d(e.error);if(!r)throw t;t=r.call(e,t)}catch(t){try{g(n)}finally{throw t}}return g(n),t},complete:function(t){var n=this._s;if(!y(n)){var e=n._o;n._o=void 0;try{var r=d(e.complete);t=r?r.call(e,t):void 0}catch(t){try{g(n)}finally{throw t}}return g(n),t}}});var _=function(t){f(this,_,"Observable","_f")._f=c(t)};l(_.prototype,{subscribe:function(t){return new b(t,this._f)},forEach:function(t){var n=this;return new(o.Promise||i.Promise)((function(e,r){c(t);var i=n.subscribe({next:function(n){try{return t(n)}catch(t){r(t),i.unsubscribe()}},error:r,complete:e})}))}}),l(_,{from:function(t){var n="function"==typeof this?this:_,e=d(s(t)[a]);if(e){var r=s(e.call(t));return r.constructor===n?r:new n((function(t){return r.subscribe(t)}))}return new n((function(n){var e=!1;return u((function(){if(!e){try{if(p(t,!1,(function(t){if(n.next(t),e)return v}))===v)return}catch(t){if(e)throw t;return void n.error(t)}n.complete()}})),function(){e=!0}}))},of:function(){for(var t=0,n=arguments.length,e=new Array(n);t2,i=!!r&&u.call(arguments,2);return t(r?function(){("function"==typeof n?n:Function(n)).apply(this,i)}:n,e)}};i(i.G+i.B+i.F*a,{setTimeout:c(r.setTimeout),setInterval:c(r.setInterval)})},function(t,n,e){var r=e(0),i=e(90);r(r.G+r.B,{setImmediate:i.set,clearImmediate:i.clear})},function(t,n,e){for(var r=e(87),i=e(34),o=e(12),u=e(2),a=e(11),c=e(46),s=e(5),f=s("iterator"),l=s("toStringTag"),h=c.Array,p={CSSRuleList:!0,CSSStyleDeclaration:!1,CSSValueList:!1,ClientRectList:!1,DOMRectList:!1,DOMStringList:!1,DOMTokenList:!0,DataTransferItemList:!1,FileList:!1,HTMLAllCollection:!1,HTMLCollection:!1,HTMLFormElement:!1,HTMLSelectElement:!1,MediaList:!0,MimeTypeArray:!1,NamedNodeMap:!1,NodeList:!0,PaintRequestList:!1,Plugin:!1,PluginArray:!1,SVGLengthList:!1,SVGNumberList:!1,SVGPathSegList:!1,SVGPointList:!1,SVGStringList:!1,SVGTransformList:!1,SourceBufferList:!1,StyleSheetList:!0,TextTrackCueList:!1,TextTrackList:!1,TouchList:!1},v=i(p),d=0;d=0;--i){var o=this.tryEntries[i],u=o.completion;if("root"===o.tryLoc)return e("end");if(o.tryLoc<=this.prev){var a=r.call(o,"catchLoc"),c=r.call(o,"finallyLoc");if(a&&c){if(this.prev=0;--e){var i=this.tryEntries[e];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--n){var e=this.tryEntries[n];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),A(e),f}},catch:function(t){for(var n=this.tryEntries.length-1;n>=0;--n){var e=this.tryEntries[n];if(e.tryLoc===t){var r=e.completion;if("throw"===r.type){var i=r.arg;A(e)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,e){return this.delegate={iterator:E(t),resultName:n,nextLoc:e},"next"===this.method&&(this.arg=void 0),f}}}function d(t,n,e,r){var i=n&&n.prototype instanceof y?n:y,o=Object.create(i.prototype),u=new O(r||[]);return o._invoke=function(t,n,e){var r="suspendedStart";return function(i,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw o;return P()}for(e.method=i,e.arg=o;;){var u=e.delegate;if(u){var a=x(u,e);if(a){if(a===f)continue;return a}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if("suspendedStart"===r)throw r="completed",e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);r="executing";var c=g(t,n,e);if("normal"===c.type){if(r=e.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:e.done}}"throw"===c.type&&(r="completed",e.method="throw",e.arg=c.arg)}}}(t,e,u),o}function g(t,n,e){try{return{type:"normal",arg:t.call(n,e)}}catch(t){return{type:"throw",arg:t}}}function y(){}function m(){}function b(){}function w(t){["next","throw","return"].forEach((function(n){t[n]=function(t){return this._invoke(n,t)}}))}function _(t){function e(n,i,o,u){var a=g(t[n],t,i);if("throw"!==a.type){var c=a.arg,s=c.value;return s&&"object"==typeof s&&r.call(s,"__await")?Promise.resolve(s.__await).then((function(t){e("next",t,o,u)}),(function(t){e("throw",t,o,u)})):Promise.resolve(s).then((function(t){c.value=t,o(c)}),u)}u(a.arg)}var i;"object"==typeof n.process&&n.process.domain&&(e=n.process.domain.bind(e)),this._invoke=function(t,n){function r(){return new Promise((function(r,i){e(t,n,r,i)}))}return i=i?i.then(r,r):r()}}function x(t,n){var e=t.iterator[n.method];if(void 0===e){if(n.delegate=null,"throw"===n.method){if(t.iterator.return&&(n.method="return",n.arg=void 0,x(t,n),"throw"===n.method))return f;n.method="throw",n.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var r=g(e,t.iterator,n.arg);if("throw"===r.type)return n.method="throw",n.arg=r.arg,n.delegate=null,f;var i=r.arg;return i?i.done?(n[t.resultName]=i.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=void 0),n.delegate=null,f):i:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,f)}function S(t){var n={tryLoc:t[0]};1 in t&&(n.catchLoc=t[1]),2 in t&&(n.finallyLoc=t[2],n.afterLoc=t[3]),this.tryEntries.push(n)}function A(t){var n=t.completion||{};n.type="normal",delete n.arg,t.completion=n}function O(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0)}function E(t){if(t){var n=t[o];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var e=-1,i=function n(){for(;++en.maxAge:t._maxAge&&e>t._maxAge}function c(t){for(;t._lrut._max;)f(t,t._lruList[t._lru])}function s(t,n){for(delete t._lruList[n.lu];t._lruthis._max&&c(this)},get:function(){return this._max},enumerable:!0}),Object.defineProperty(o.prototype,"lengthCalculator",{set:function(t){if("function"!=typeof t)for(var n in this._lengthCalculator=e,this._length=this._itemCount,this._cache)this._cache[n].length=1;else for(var n in this._lengthCalculator=t,this._length=0,this._cache)this._cache[n].length=this._lengthCalculator(this._cache[n].value),this._length+=this._cache[n].length;this._length>this._max&&c(this)},get:function(){return this._lengthCalculator},enumerable:!0}),Object.defineProperty(o.prototype,"length",{get:function(){return this._length},enumerable:!0}),Object.defineProperty(o.prototype,"itemCount",{get:function(){return this._itemCount},enumerable:!0}),o.prototype.forEach=function(t,n){n=n||this;for(var e=0,r=this._itemCount,i=this._mru-1;i>=0&&e=0&&n=0&&n=0&&nthis._max?(f(this,this._cache[t]),!1):(this._dispose&&this._dispose(t,this._cache[t].value),this._cache[t].now=o,this._cache[t].maxAge=r,this._cache[t].value=e,this._length+=u-this._cache[t].length,this._cache[t].length=u,this.get(t),this._length>this._max&&c(this),!0);var a=new l(t,e,this._mru++,u,o,r);return a.length>this._max?(this._dispose&&this._dispose(t,e),!1):(this._length+=a.length,this._lruList[a.lu]=this._cache[t]=a,this._itemCount++,this._length>this._max&&c(this),!0)},o.prototype.has=function(t){return i(t),!!n(this._cache,t)&&!a(this,this._cache[t])},o.prototype.get=function(t){return i(t),u(this,t,!0)},o.prototype.peek=function(t){return i(t),u(this,t,!1)},o.prototype.pop=function(){var t=this._lruList[this._lru];return f(this,t),t||null},o.prototype.del=function(t){i(t),f(this,this._cache[t])},o.prototype.load=function(t){this.reset();for(var n=Date.now(),e=t.length-1;e>=0;e--){var r=t[e];i(r.k);var o=r.e||0;if(0===o)this.set(r.k,r.v);else{var u=o-n;u>0&&this.set(r.k,r.v,u)}}}}()},function(t,n,e){"use strict";var r,i=(r=e(338))&&r.__esModule?r.default:r;t.exports=i},function(t,n,e){"use strict";var r=function(t){return t&&t.__esModule?t.default:t},i=function(){function t(t,n){for(var e in n){var r=n[e];r.configurable=!0,r.value&&(r.writable=!0)}Object.defineProperties(t,n)}return function(n,e,r){return e&&t(n.prototype,e),r&&t(n,r),n}}(),o=function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")},u=r(e(94)),a=r(e(339)),c=function(){function t(){var n=this,e=void 0===arguments[0]?{}:arguments[0];o(this,t),this.format={floatingPoint:!!e.floatingPoint,bitDepth:0|e.bitDepth||16},this._worker=new u(a,a.self),this._worker.onmessage=function(t){var e=n._callbacks[t.data.callbackId];e&&("encoded"===t.data.type?e.resolve(t.data.buffer):e.reject(new Error(t.data.message))),n._callbacks[t.data.callbackId]=null},this._callbacks=[]}return i(t,{canProcess:{value:function(n){return t.canProcess(n)}},encode:{value:function(t,n){var e=this;return null!=n&&"object"==typeof n||(n=this.format),new Promise((function(r,i){var o=e._callbacks.length;e._callbacks.push({resolve:r,reject:i});var u=t.channelData.length,a=t.channelData[0].length,c=t.sampleRate,s=t.channelData.map((function(t){return t.buffer}));t={numberOfChannels:u,length:a,sampleRate:c,buffers:s},e._worker.postMessage({type:"encode",audioData:t,format:n,callbackId:o},t.buffers)}))}}},{canProcess:{value:function(t){return!t||"wav"!==t&&"wav"!==t.type?"":"maybe"}},encode:{value:function(n,e){return new t(e).encode(n)}}}),t}();t.exports=c},function(t,n,e){"use strict";var r={};function i(){function t(t){this.buffer=new ArrayBuffer(t),this.view=new DataView(this.buffer),this.length=t,this.pos=0}r.onmessage=function(t){switch(t.data.type){case"encode":r.encode(t.data.audioData,t.data.format).then((function(n){var e={type:"encoded",callbackId:t.data.callbackId,buffer:n};r.postMessage(e,[n])}),(function(n){var e={type:"error",callbackId:t.data.callbackId,message:n.message};r.postMessage(e)}))}},r.encode=function(n,e){return e.floatingPoint=!!e.floatingPoint,e.bitDepth=0|e.bitDepth||16,new Promise((function(r){var i=n.numberOfChannels,o=n.sampleRate,u=e.bitDepth>>3,a=n.length*i*u,c=new t(44+a);c.writeString("RIFF"),c.writeUint32(c.length-8),c.writeString("WAVE"),c.writeString("fmt "),c.writeUint32(16),c.writeUint16(e.floatingPoint?3:1),c.writeUint16(i),c.writeUint32(o),c.writeUint32(o*i*u),c.writeUint16(i*u),c.writeUint16(e.bitDepth),c.writeString("data"),c.writeUint32(a);var s=n.buffers.map((function(t){return new Float32Array(t)}));c.writePCM(s,e),r(c.toArrayBuffer())}))},t.prototype.writeUint8=function(t){this.view.setUint8(this.pos,t),this.pos+=1},t.prototype.writeUint16=function(t){this.view.setUint16(this.pos,t,!0),this.pos+=2},t.prototype.writeUint32=function(t){this.view.setUint32(this.pos,t,!0),this.pos+=4},t.prototype.writeString=function(t){for(var n=0;n>0&255),this.view.setUint8(this.pos+1,t>>8&255),this.view.setUint8(this.pos+2,t>>16&255),this.pos+=3},t.prototype.writePCM32=function(t){t=0|Math.max(-2147483648,Math.min(2147483648*t,2147483647)),this.view.setInt32(this.pos,t,!0),this.pos+=4},t.prototype.writePCM32F=function(t){this.view.setFloat32(this.pos,t,!0),this.pos+=4},t.prototype.writePCM64F=function(t){this.view.setFloat64(this.pos,t,!0),this.pos+=8},t.prototype.writePCM=function(t,n){var e=t[0].length,r=t.length,i="writePCM"+n.bitDepth;if(n.floatingPoint&&(i+="F"),!this[i])throw new Error("not suppoerted bit depth "+n.bitDepth);for(var o=0;odiv{padding:.75rem 1.25rem;margin:1rem 0;border:1px solid #f5c6cb;border-radius:.25rem;background-color:#f8d7da;color:#721c24}.AssemblyAIHelper--listening .ais-VoiceSearch-button{background-color:#E74C3C;animation:assemblyaihelper-pulse 1s infinite}.AssemblyAIHelper--listening .ais-VoiceSearch-button:hover,.AssemblyAIHelper--listening .ais-VoiceSearch-button:active,.AssemblyAIHelper--listening .ais-VoiceSearch-button:focus{background-color:#E74C3C}@keyframes assemblyaihelper-pulse{0%{box-shadow:0 0 0 0px rgba(0,0,0,0.2)}100%{box-shadow:0 0 0 10px rgba(0,0,0,0)}}\n",""]),t.exports=n},function(t,n,e){"use strict";t.exports=function(t){var n=[];return n.toString=function(){return this.map((function(n){var e=function(t,n){var e=t[1]||"",r=t[3];if(!r)return e;if(n&&"function"==typeof btoa){var i=(u=r,a=btoa(unescape(encodeURIComponent(JSON.stringify(u)))),c="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(a),"/*# ".concat(c," */")),o=r.sources.map((function(t){return"/*# sourceURL=".concat(r.sourceRoot||"").concat(t," */")}));return[e].concat(o).concat([i]).join("\n")}var u,a,c;return[e].join("\n")}(n,t);return n[2]?"@media ".concat(n[2]," {").concat(e,"}"):e})).join("")},n.i=function(t,e,r){"string"==typeof t&&(t=[[null,t,""]]);var i={};if(r)for(var o=0;othis.energy_threshold_pos?this.voiceTrend=this.voiceTrend+1>this.voiceTrendMax?this.voiceTrendMax:this.voiceTrend+1:n<-this.energy_threshold_neg?this.voiceTrend=this.voiceTrend-10?this.voiceTrend--:this.voiceTrend<0&&this.voiceTrend++;var e=!1,r=!1;this.voiceTrend>this.voiceTrendStart?e=!0:this.voiceTrend0||!r?i:10*i,this.energy_offset=this.energy_offset<0?0:this.energy_offset,this.energy_threshold_pos=this.energy_offset*this.options.energy_threshold_ratio_pos,this.energy_threshold_neg=this.energy_offset*this.options.energy_threshold_ratio_neg,e&&!this.vadState&&(this.vadState=!0,this.options.voice_start()),r&&this.vadState&&(this.vadState=!1,this.options.voice_stop()),this.log("e: "+t+" | e_of: "+this.energy_offset+" | e+_th: "+this.energy_threshold_pos+" | e-_th: "+this.energy_threshold_neg+" | signal: "+n+" | int: "+i+" | voiceTrend: "+this.voiceTrend+" | start: "+e+" | end: "+r),n}}function i(t,n){return n=n||{},new Promise((function(e,r){var i=new XMLHttpRequest,o=[],u=[],a={};for(var c in i.open(n.method||"get",t,!0),i.onload=function(){i.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,(function(t,n,e){o.push(n=n.toLowerCase()),u.push([n,e]),a[n]=a[n]?"".concat(a[n],",").concat(e):e}));var t=function t(){return{ok:2==(i.status/100|0),statusText:i.statusText,status:i.status,url:i.responseURL,text:function(){return Promise.resolve(i.responseText)},json:function(){return Promise.resolve(i.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([i.response]))},clone:t,headers:{keys:function(){return o},entries:function(){return u},get:function(t){return a[t.toLowerCase()]},has:function(t){return t.toLowerCase()in a}}}}();if(!t.ok)return r(JSON.parse(i.responseText));e(t)},i.onerror=r,i.withCredentials="include"==n.credentials,n.headers)i.setRequestHeader(c,n.headers[c]);i.send(n.body||null)}))}var o=e(94),u=e.n(o);function a(t,n){for(var e=0;e1&&void 0!==arguments[1]?arguments[1]:{};l(this,t),this.config=Object.assign({},p,e),this.audioContext=n,this.audioInput=null,this.realAudioInput=null,this.inputPoint=null,this.audioRecorder=null,this.rafID=null,this.analyserContext=null,this.recIndex=0,this.stream=null,this.microphoneConfig=v.reduce((function(t,n){return e[n]&&(t[n]=e[n]),t}),{}),this.updateAnalysers=this.updateAnalysers.bind(this)}var n,e,r;return n=t,(e=[{key:"init",value:function(t){var n=this;return new Promise((function(e){n.inputPoint=n.audioContext.createGain(),n.stream=t,n.realAudioInput=n.audioContext.createMediaStreamSource(t),n.audioInput=n.realAudioInput,n.audioInput.connect(n.inputPoint),n.analyserNode=n.audioContext.createAnalyser(),n.analyserNode.fftSize=512,n.analyserNode.smoothingTimeConstant=.99,n.inputPoint.connect(n.analyserNode),n.audioRecorder=new f(n.inputPoint,n.microphoneConfig);var r=n.audioContext.createGain();r.gain.value=0,n.inputPoint.connect(r),r.connect(n.audioContext.destination),n.updateAnalysers(),e()}))}},{key:"start",value:function(){var t=this;return new Promise((function(n,e){t.audioRecorder?(t.audioRecorder.clear(),t.audioRecorder.record(),n(t.stream)):e("Not currently recording")}))}},{key:"stop",value:function(){var t=this;return new Promise((function(n){t.audioRecorder.stop(),t.audioRecorder.getBuffer((function(e){t.audioRecorder.exportWAV((function(t){return n({buffer:e,blob:t})}))}))}))}},{key:"updateAnalysers",value:function(){if(this.config.onAnalysed){requestAnimationFrame(this.updateAnalysers);var t=new Uint8Array(this.analyserNode.frequencyBinCount);this.analyserNode.getByteFrequencyData(t);for(var n,e=new Array(255),r=0,i=0;i<255;i+=1)0!=(n=Math.floor(t[i])-Math.floor(t[i])%5)&&(r=i),e[i]=n;this.config.onAnalysed({data:e,lineTo:r})}}},{key:"setOnAnalysed",value:function(t){this.config.onAnalysed=t}}])&&h(n.prototype,e),r&&h(n,r),t}();d.download=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"audio";f.forceDownload(t,"".concat(n,".wav"))};var g=d,y=e(131),m=e.n(y);function b(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable}))),e.push.apply(e,r)}return e}function w(t){for(var n=1;n1&&void 0!==arguments[1]?arguments[1]:{};x(this,t),this.token=n;var i=navigator&&/^((?!chrome|android).)*safari/i.test(navigator.userAgent);this.PCM_DATA_SAMPLE_RATE=i?44100:16e3,console.log("Running on Safari: ".concat(i)),this.callbacks={start:function(){},stop:function(){},complete:function(){},error:function(){}};var o={};if(r.word_boost){if(r.word_boost.length>100)return void setTimeout((function(){e.callbacks.error({error:"The word_boost parameter can be a max of 100 terms"})}),4);if(!r.word_boost.every((function(t){return"string"==typeof t})))return void setTimeout((function(){e.callbacks.error({error:"The word_boost parameter only accepts string terms"})}),4);o.word_boost=r.word_boost}if(void 0!==r.format_text){if("boolean"!=typeof r.format_text)return void setTimeout((function(){e.callbacks.error({error:"The format_text parameter only accepts boolean values (true / false)"})}),4);o.format_text=r.format_text}this.params=o}var n,e,o;return n=t,(e=[{key:"start",value:function(){var t=this;return this.source&&this.source.context&&"function"==typeof this.source.context.resume&&this.source.context.resume(),Promise.resolve().then((function(){if(!t.recorder){var n,e=new(window.AudioContext||window.webkitAudioContext);return new r({context:e,onaudioprocess:function(t){n=t},voice_stop:function(){t.isRecording&&t.stop()}}),t.recorder=new g(e,{onAnalysed:function(t){var e=t.data;return n&&n(e)}}),navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1,channelCount:1}}).then((function(n){t.recorder.init(n),t.recordingTimer=setTimeout((function(){console.log("AssemblyAI: Recording stopped because it has reached the limit of 15 seconds."),t.stop()}),15e3)})).catch((function(n){t.callbacks.error(n)}))}})).then((function(){t.recorder.start().then((function(){t.isRecording=!0,t.callbacks.start()}))}))}},{key:"stop",value:function(){var t=this;this.isRecording=!1,this.callbacks.stop(),this.recordingTimer&&clearTimeout(this.recordingTimer);var n=function(){t.source&&t.source.mediaStream&&"function"==typeof t.source.mediaStream.getTracks&&(t.source.mediaStream.getTracks().forEach((function(t){return t.stop()})),t.recorder=void 0)};return Promise.resolve().then((function(){if(t.recorder)return t.recorder.stop();throw new Error("no recorder")})).then((function(n){var e=n.buffer,r=new(window.AudioContext||window.webkitAudioContext),i=r.createBuffer(1,e[0].length,r.sampleRate);return i.getChannelData(0).set(e[0]),t.resample(i)})).then((function(n){console.log("audio",n);var e=t._createWaveFileData(n);return t._transcribe(btoa(t._uint8ToString(e)))})).then(n).catch((function(t){return console.log(t),n()}))}},{key:"on",value:function(t,n){switch(t){case"start":this.callbacks.start=n;break;case"stop":this.callbacks.stop=n;break;case"complete":this.callbacks.complete=n;break;case"error":this.callbacks.error=n;break;default:console.error("Event ".concat(t," does not exist."))}}},{key:"_transcribe",value:function(t){var n=this;return i("https://api.assemblyai.com/v2/stream/avs",{method:"POST",body:JSON.stringify(w({audio_data:t,sample_rate:this.PCM_DATA_SAMPLE_RATE},this.params)),headers:{authorization:this.token,"Content-Type":"application/json; charset=utf-8"}}).then((function(t){return t.json()})).then((function(t){if(!t.text)return n.callbacks.error({error:"No speech detected. Please try again"});n.callbacks.complete(t)})).catch((function(t){n.callbacks.error(t)}))}},{key:"resample",value:function(t){var n=this;return 44100===this.PCM_DATA_SAMPLE_RATE?Promise.resolve(t):new Promise((function(e){m()(t,n.PCM_DATA_SAMPLE_RATE,(function(t){var n=t.getAudioBuffer;e(n())}))}))}},{key:"_uint8ToString",value:function(t){return Array.prototype.map.call(t,(function(t){return String.fromCharCode(t)})).join("")}},{key:"_createWaveFileData",value:function(t){var n=t.length,e=t.numberOfChannels,r=t.sampleRate,i=r*e*16/8,o=16*e/8,u=n*e*2,a=new Uint8Array(44+u),c=u,s=28+(8+c);return this._writeString("RIFF",a,0),this._writeInt32(s,a,4),this._writeString("WAVE",a,8),this._writeString("fmt ",a,12),this._writeInt32(16,a,16),this._writeInt16(1,a,20),this._writeInt16(e,a,22),this._writeInt32(r,a,24),this._writeInt32(i,a,28),this._writeInt16(o,a,32),this._writeInt32(16,a,34),this._writeString("data",a,36),this._writeInt32(c,a,40),this._writeAudioBuffer(t,a,44),a}},{key:"_writeString",value:function(t,n,e){for(var r=0;r>8&255}},{key:"_writeInt32",value:function(t,n,e){t=Math.floor(t),n[e+0]=255&t,n[e+1]=t>>8&255,n[e+2]=t>>16&255,n[e+3]=t>>24&255}},{key:"_writeAudioBuffer",value:function(t,n,e){for(var r=t.length,i=t.numberOfChannels,o=0;o32767&&(a=32767),this._writeInt16(a,n,e),e+=2}}}])&&S(n.prototype,e),o&&S(n,o),t}();e(340);function O(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable}))),e.push.apply(e,r)}return e}function E(t){for(var n=1;n0&&void 0!==arguments[0]?arguments[0]:{},n=t.text;f({transcript:n}),i(n)}));var s=function(){return"askingPermission"===a.status||"recognizing"===a.status},f=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};a=E({},a,{},t),document.querySelector(".AssemblyAIHelper")&&(s()?document.querySelector(".AssemblyAIHelper").classList.add("AssemblyAIHelper--listening"):document.querySelector(".AssemblyAIHelper").classList.remove("AssemblyAIHelper--listening")),o()},l=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"initial";f(u(t))};return{getState:function(){return a},isBrowserSupported:function(){return Boolean(window.AudioContext||window.webkitAudioContext)&&Boolean(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia)},isListening:s,startListening:function(){c&&(l("askingPermission"),c.start())},stopListening:function(){c.stop(),l("finished")},dispose:function(){c&&(c.stop(),c=void function(t){throw new Error('"'+t+'" is read-only')}("assembly"))}}}}}]).assemblyAIHelper; -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 10 | 14 | AssemblyAI Voice Search 15 | 16 | 36 | 37 | 38 | 39 |
40 |

Algolia Voice Search

41 | 42 |
43 | 44 |
45 |
46 |
47 | 48 |
49 |
50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /public/main.js: -------------------------------------------------------------------------------- 1 | window.onload = () => { 2 | const search = instantsearch({ 3 | indexName: 'movies', 4 | searchClient: algoliasearch('latency', 'algolia-api-token') 5 | }); 6 | 7 | search.addWidgets([ 8 | instantsearch.widgets.configure({ 9 | hitsPerPage: 12 10 | }), 11 | instantsearch.widgets.hits({ 12 | container: '#hits', 13 | templates: { 14 | empty: 'No results', 15 | item: `{{{title}}} ({{{year}}})` 16 | } 17 | }), 18 | instantsearch.widgets.searchBox({ 19 | container: '#searchbox' 20 | }), 21 | instantsearch.widgets.voiceSearch({ 22 | container: '#voicesearch', 23 | // TODO: this requires https://github.com/algolia/instantsearch.js/pull/4363 24 | createVoiceSearchHelper: window.assemblyAIHelper( 25 | 'assemblyai-api-token' 26 | ), 27 | cssClasses: { 28 | root: ['AssemblyAIHelper'] // Add AssemblyAI stylings or use your own 29 | }, 30 | templates: { 31 | status: ({errorCode}) => Boolean(errorCode) ? `
${errorCode}
` : '' 32 | } 33 | }), 34 | instantsearch.widgets.pagination({ 35 | container: '#pagination' 36 | }), 37 | instantsearch.widgets.stats({ 38 | container: '#stats' 39 | }) 40 | ]); 41 | 42 | search.start(); 43 | }; 44 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import 'babel-polyfill'; 2 | import AssemblyAI from './lib/assemblyai'; 3 | 4 | import './scss/main.scss'; 5 | 6 | export const assemblyAIHelper = (token, params) => ({ 7 | // language, 8 | searchAsYouSpeak, 9 | onQueryChange, 10 | onStateChange 11 | }) => { 12 | if (searchAsYouSpeak) { 13 | console.warn( 14 | "the assemblyAI voice helper doesn't support searchAsYouSpeak" 15 | ); 16 | } 17 | 18 | const getDefaultState = status => ({ 19 | status, 20 | transcript: '', 21 | isSpeechFinal: false, 22 | errorCode: undefined 23 | }); 24 | let state = getDefaultState('initial'); 25 | const assembly = new AssemblyAI(token, params); 26 | 27 | // TODO: can be done? 28 | // if (language) { 29 | // assembly.lang = language; 30 | // } 31 | 32 | assembly.on('start', () => { 33 | setState({ 34 | status: 'recognizing' 35 | }); 36 | }); 37 | 38 | assembly.on('error', event => { 39 | setState({ 40 | status: 'error', 41 | errorCode: event.error || 'Something went wrong' 42 | }); 43 | }); 44 | 45 | assembly.on('stop', () => { 46 | setState({ 47 | status: 'finished' 48 | }); 49 | }); 50 | 51 | assembly.on('complete', ({ text } = {}) => { 52 | setState({ 53 | transcript: text 54 | }); 55 | onQueryChange(text); 56 | }); 57 | 58 | const isBrowserSupported = () => 59 | Boolean(window.AudioContext || window.webkitAudioContext) && 60 | Boolean(navigator.mediaDevices && navigator.mediaDevices.getUserMedia); 61 | 62 | const isListening = () => 63 | state.status === 'askingPermission' || state.status === 'recognizing'; 64 | 65 | const setState = (newState = {}) => { 66 | state = { ...state, ...newState }; 67 | 68 | if (document.querySelector('.AssemblyAIHelper')) { 69 | if (isListening()) { 70 | document 71 | .querySelector('.AssemblyAIHelper') 72 | .classList.add('AssemblyAIHelper--listening'); 73 | } else { 74 | document 75 | .querySelector('.AssemblyAIHelper') 76 | .classList.remove('AssemblyAIHelper--listening'); 77 | } 78 | } 79 | 80 | onStateChange(); 81 | }; 82 | 83 | const resetState = (status = 'initial') => { 84 | setState(getDefaultState(status)); 85 | }; 86 | 87 | const getState = () => state; 88 | 89 | const startListening = () => { 90 | if (!assembly) { 91 | return; 92 | } 93 | 94 | resetState('askingPermission'); 95 | 96 | assembly.start(); 97 | }; 98 | 99 | const dispose = () => { 100 | if (!assembly) { 101 | return; 102 | } 103 | assembly.stop(); 104 | 105 | assembly = undefined; 106 | }; 107 | 108 | const stopListening = () => { 109 | assembly.stop(); 110 | // Because `dispose` removes event listeners, `end` listener is not called. 111 | // So we're setting the `status` as `finished` here. 112 | // If we don't do it, it will be still `waiting` or `recognizing`. 113 | resetState('finished'); 114 | }; 115 | 116 | return { 117 | getState, 118 | isBrowserSupported, 119 | isListening, 120 | startListening, 121 | stopListening, 122 | dispose 123 | }; 124 | }; 125 | -------------------------------------------------------------------------------- /src/lib/assemblyai.js: -------------------------------------------------------------------------------- 1 | import VAD from './vad'; 2 | import { request } from './request'; 3 | import Recorder from './recorder'; 4 | import resampler from 'audio-resampler'; 5 | 6 | const API_ENDPOINT = 'https://api.assemblyai.com/v2/stream/avs'; 7 | 8 | export default class AssemblyAI { 9 | constructor(token, params = {}) { 10 | this.token = token; 11 | 12 | const browser = navigator && /^((?!chrome|android).)*safari/i.test(navigator.userAgent); 13 | 14 | this.PCM_DATA_SAMPLE_RATE = browser ? 44100 : 16000; 15 | 16 | console.log(`Running on Safari: ${browser}`); 17 | 18 | // Default callbacks 19 | this.callbacks = { 20 | start: () => {}, 21 | stop: () => {}, 22 | complete: () => {}, 23 | error: () => {} 24 | }; 25 | 26 | const _params = {}; 27 | 28 | if(params.word_boost){ 29 | if(params.word_boost.length > 100){ 30 | setTimeout(() => { 31 | this.callbacks.error({error: 'The word_boost parameter can be a max of 100 terms'}); 32 | }, 4); 33 | return; 34 | } 35 | if(!params.word_boost.every(v => typeof v === 'string')){ 36 | setTimeout(() => { 37 | this.callbacks.error({error: 'The word_boost parameter only accepts string terms'}); 38 | }, 4); 39 | return; 40 | } 41 | _params['word_boost'] = params.word_boost; 42 | } 43 | 44 | if(params.format_text !== undefined){ 45 | if(typeof params.format_text !== 'boolean'){ 46 | setTimeout(() => { 47 | this.callbacks.error({error: 'The format_text parameter only accepts boolean values (true / false)'}); 48 | }, 4); 49 | return; 50 | } 51 | 52 | _params['format_text'] = params.format_text; 53 | } 54 | 55 | this.params = _params; 56 | } 57 | 58 | /** 59 | * Function that starts the recording 60 | */ 61 | start() { 62 | if ( 63 | this.source && 64 | this.source.context && 65 | typeof this.source.context.resume === 'function' 66 | ) { 67 | this.source.context.resume(); 68 | } 69 | 70 | return Promise.resolve() 71 | .then(() => { 72 | if (!this.recorder) { 73 | const audioContext = new (window.AudioContext || 74 | window.webkitAudioContext)(); 75 | 76 | let onaudioprocess; 77 | 78 | new VAD({ 79 | context: audioContext, 80 | onaudioprocess: (func) => { 81 | onaudioprocess = func; 82 | }, 83 | voice_stop: () => { 84 | if (this.isRecording) { 85 | this.stop(); 86 | } 87 | } 88 | }); 89 | 90 | this.recorder = new Recorder(audioContext, { 91 | onAnalysed: ({data}) => onaudioprocess && onaudioprocess(data) 92 | }); 93 | 94 | return navigator.mediaDevices 95 | .getUserMedia({ 96 | audio: { 97 | echoCancellation: false, 98 | noiseSuppression: false, 99 | autoGainControl: false, 100 | channelCount: 1 101 | } 102 | }) 103 | .then(stream => { 104 | this.recorder.init(stream); 105 | 106 | this.recordingTimer = setTimeout(() => { 107 | console.log('AssemblyAI: Recording stopped because it has reached the limit of 15 seconds.'); 108 | this.stop(); 109 | }, 15000); 110 | }) 111 | .catch(err => { 112 | this.callbacks.error(err); 113 | }); 114 | } 115 | }) 116 | .then(() => { 117 | this.recorder.start().then(() => { 118 | this.isRecording = true; 119 | this.callbacks.start(); 120 | }); 121 | }); 122 | } 123 | 124 | /** 125 | * Function that stops the recording 126 | */ 127 | stop() { 128 | this.isRecording = false; 129 | this.callbacks.stop(); 130 | 131 | if(this.recordingTimer){ 132 | clearTimeout(this.recordingTimer); 133 | } 134 | 135 | const stopRecording = () => { 136 | if ( 137 | this.source && 138 | this.source.mediaStream && 139 | typeof this.source.mediaStream.getTracks === 'function' 140 | ) { 141 | const tracks = this.source.mediaStream.getTracks(); 142 | // we need to make a new recorder for every time the user presses the button, 143 | // otherwise we keep recording. 144 | tracks.forEach(track => track.stop()); 145 | this.recorder = undefined; 146 | } 147 | }; 148 | 149 | return Promise.resolve() 150 | .then(() => { 151 | if (this.recorder) { 152 | return this.recorder.stop(); 153 | } 154 | throw new Error('no recorder'); 155 | }) 156 | .then(({ buffer }) => { 157 | const audioContext = new (window.AudioContext || window.webkitAudioContext)(); 158 | const newBuffer = audioContext.createBuffer( 1, buffer[0].length, audioContext.sampleRate ); 159 | newBuffer.getChannelData(0).set(buffer[0]); 160 | 161 | return this.resample(newBuffer); 162 | }) 163 | .then((buffer) => { 164 | console.log('audio', buffer); 165 | const wav = this._createWaveFileData(buffer); 166 | 167 | return this._transcribe(btoa(this._uint8ToString(wav))); 168 | }) 169 | .then(stopRecording) 170 | .catch(e => { 171 | console.log(e); 172 | 173 | return stopRecording(); 174 | }); 175 | } 176 | 177 | /** 178 | * Function that registers event listeners. 179 | * @param {string} event Event name. Valid options: start, stop, complete, error. 180 | * @param {function} callback Function that will be called when event is fired. 181 | */ 182 | on(event, callback) { 183 | switch (event) { 184 | case 'start': { 185 | this.callbacks.start = callback; 186 | break; 187 | } 188 | case 'stop': { 189 | this.callbacks.stop = callback; 190 | break; 191 | } 192 | case 'complete': { 193 | this.callbacks.complete = callback; 194 | break; 195 | } 196 | case 'error': { 197 | this.callbacks.error = callback; 198 | break; 199 | } 200 | default: { 201 | console.error(`Event ${event} does not exist.`); 202 | } 203 | } 204 | } 205 | 206 | /** 207 | * Function that gets a transcript from AssemblyAI API. 208 | * @param {base64} audio_data Audio recording. 209 | */ 210 | _transcribe(audio_data) { 211 | return request(API_ENDPOINT, { 212 | method: 'POST', 213 | body: JSON.stringify({ audio_data, sample_rate: this.PCM_DATA_SAMPLE_RATE, ...this.params}), 214 | headers: { 215 | authorization: this.token, 216 | 'Content-Type': 'application/json; charset=utf-8' 217 | } 218 | }) 219 | .then(res => res.json()) 220 | .then(data => { 221 | if(!data.text){ 222 | return this.callbacks.error({error: 'No speech detected. Please try again'}); 223 | } 224 | 225 | this.callbacks.complete(data); 226 | }) 227 | .catch((e) => { 228 | this.callbacks.error(e); 229 | }); 230 | } 231 | 232 | resample(buffer){ 233 | if(this.PCM_DATA_SAMPLE_RATE === 44100){ 234 | return Promise.resolve(buffer); 235 | } 236 | 237 | return new Promise((resolve) => { 238 | resampler( 239 | buffer, 240 | this.PCM_DATA_SAMPLE_RATE, 241 | ({ getAudioBuffer }) => { 242 | resolve(getAudioBuffer()); 243 | } 244 | ); 245 | }) 246 | } 247 | 248 | _uint8ToString(buf) { 249 | return Array.prototype.map.call(buf, i => String.fromCharCode(i)).join(''); 250 | } 251 | 252 | _createWaveFileData(audioBuffer) { 253 | const frameLength = audioBuffer.length; 254 | const numberOfChannels = audioBuffer.numberOfChannels; 255 | const sampleRate = audioBuffer.sampleRate; 256 | const bitsPerSample = 16; 257 | const byteRate = (sampleRate * numberOfChannels * bitsPerSample) / 8; 258 | const blockAlign = (numberOfChannels * bitsPerSample) / 8; 259 | const wavDataByteLength = frameLength * numberOfChannels * 2; // 16-bit audio 260 | const headerByteLength = 44; 261 | const totalLength = headerByteLength + wavDataByteLength; 262 | 263 | const waveFileData = new Uint8Array(totalLength); 264 | 265 | const subChunk1Size = 16; // for linear PCM 266 | const subChunk2Size = wavDataByteLength; 267 | const chunkSize = 4 + (8 + subChunk1Size) + (8 + subChunk2Size); 268 | 269 | this._writeString('RIFF', waveFileData, 0); 270 | this._writeInt32(chunkSize, waveFileData, 4); 271 | this._writeString('WAVE', waveFileData, 8); 272 | this._writeString('fmt ', waveFileData, 12); 273 | 274 | this._writeInt32(subChunk1Size, waveFileData, 16); // SubChunk1Size (4) 275 | this._writeInt16(1, waveFileData, 20); // AudioFormat (2) 276 | this._writeInt16(numberOfChannels, waveFileData, 22); // NumChannels (2) 277 | this._writeInt32(sampleRate, waveFileData, 24); // SampleRate (4) 278 | this._writeInt32(byteRate, waveFileData, 28); // ByteRate (4) 279 | this._writeInt16(blockAlign, waveFileData, 32); // BlockAlign (2) 280 | this._writeInt32(bitsPerSample, waveFileData, 34); // BitsPerSample (4) 281 | 282 | this._writeString('data', waveFileData, 36); 283 | this._writeInt32(subChunk2Size, waveFileData, 40); // SubChunk2Size (4) 284 | 285 | // Write actual audio data starting at offset 44. 286 | this._writeAudioBuffer(audioBuffer, waveFileData, 44); 287 | 288 | return waveFileData; 289 | } 290 | 291 | _writeString(s, a, offset) { 292 | for (let i = 0; i < s.length; ++i) { 293 | a[offset + i] = s.charCodeAt(i); 294 | } 295 | } 296 | 297 | _writeInt16(n, a, offset) { 298 | n = Math.floor(n); 299 | 300 | a[offset + 0] = n & 255; 301 | a[offset + 1] = (n >> 8) & 255; 302 | } 303 | 304 | _writeInt32(n, a, offset) { 305 | n = Math.floor(n); 306 | 307 | a[offset + 0] = n & 255; 308 | a[offset + 1] = (n >> 8) & 255; 309 | a[offset + 2] = (n >> 16) & 255; 310 | a[offset + 3] = (n >> 24) & 255; 311 | } 312 | 313 | _writeAudioBuffer(audioBuffer, a, offset) { 314 | let n = audioBuffer.length; 315 | let channels = audioBuffer.numberOfChannels; 316 | 317 | for (let i = 0; i < n; ++i) { 318 | for (let k = 0; k < channels; ++k) { 319 | let buffer = audioBuffer.getChannelData(k); 320 | let sample = buffer[i] * 32768.0; 321 | 322 | // Clip samples to the limitations of 16-bit. 323 | // If we don't do this then we'll get nasty wrap-around distortion. 324 | if (sample < -32768) sample = -32768; 325 | if (sample > 32767) sample = 32767; 326 | 327 | this._writeInt16(sample, a, offset); 328 | offset += 2; 329 | } 330 | } 331 | } 332 | } -------------------------------------------------------------------------------- /src/lib/microphone.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | /** 3 | * License (MIT) 4 | * 5 | * Copyright © 2013 Matt Diamond 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a 8 | * copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the 12 | * Software is furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included 15 | * in all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | * 24 | */ 25 | import InlineWorker from 'inline-worker'; 26 | 27 | const defaultConfig = { 28 | bufferLen: 4096, 29 | numChannels: 2, 30 | mimeType: 'audio/wav', 31 | }; 32 | 33 | class Microphone { 34 | constructor(source, config) { 35 | this.config = Object.assign({}, defaultConfig, config); 36 | 37 | this.recording = false; 38 | 39 | this.callbacks = { 40 | getBuffer: [], 41 | exportWAV: [] 42 | }; 43 | 44 | this.context = source.context; 45 | this.node = (this.context.createScriptProcessor || 46 | this.context.createJavaScriptNode).call(this.context, 47 | this.config.bufferLen, this.config.numChannels, this.config.numChannels); 48 | 49 | this.node.onaudioprocess = (e) => { 50 | if (!this.recording) return; 51 | 52 | var buffer = []; 53 | for (var channel = 0; channel < this.config.numChannels; channel++) { 54 | buffer.push(e.inputBuffer.getChannelData(channel)); 55 | } 56 | this.worker.postMessage({ 57 | command: 'record', 58 | buffer: buffer 59 | }); 60 | }; 61 | 62 | source.connect(this.node); 63 | this.node.connect(this.context.destination); //this should not be necessary 64 | 65 | let self = {}; 66 | this.worker = new InlineWorker(function () { 67 | let recLength = 0, 68 | recBuffers = [], 69 | sampleRate, 70 | numChannels; 71 | 72 | this.onmessage = function (e) { 73 | switch (e.data.command) { 74 | case 'init': 75 | init(e.data.config); 76 | break; 77 | case 'record': 78 | record(e.data.buffer); 79 | break; 80 | case 'exportWAV': 81 | exportWAV(e.data.type); 82 | break; 83 | case 'getBuffer': 84 | getBuffer(); 85 | break; 86 | case 'clear': 87 | clear(); 88 | break; 89 | } 90 | }; 91 | 92 | function init(config) { 93 | sampleRate = config.sampleRate; 94 | numChannels = config.numChannels; 95 | initBuffers(); 96 | } 97 | 98 | function record(inputBuffer) { 99 | for (var channel = 0; channel < numChannels; channel++) { 100 | recBuffers[channel].push(inputBuffer[channel]); 101 | } 102 | recLength += inputBuffer[0].length; 103 | } 104 | 105 | function exportWAV(type) { 106 | let buffers = []; 107 | for (let channel = 0; channel < numChannels; channel++) { 108 | buffers.push(mergeBuffers(recBuffers[channel], recLength)); 109 | } 110 | let interleaved; 111 | if (numChannels === 2) { 112 | interleaved = interleave(buffers[0], buffers[1]); 113 | } else { 114 | interleaved = buffers[0]; 115 | } 116 | let dataview = encodeWAV(interleaved); 117 | let audioBlob = new Blob([dataview], {type: type}); 118 | 119 | this.postMessage({command: 'exportWAV', data: audioBlob}); 120 | } 121 | 122 | function getBuffer() { 123 | let buffers = []; 124 | for (let channel = 0; channel < numChannels; channel++) { 125 | buffers.push(mergeBuffers(recBuffers[channel], recLength)); 126 | } 127 | this.postMessage({command: 'getBuffer', data: buffers}); 128 | } 129 | 130 | function clear() { 131 | recLength = 0; 132 | recBuffers = []; 133 | initBuffers(); 134 | } 135 | 136 | function initBuffers() { 137 | for (let channel = 0; channel < numChannels; channel++) { 138 | recBuffers[channel] = []; 139 | } 140 | } 141 | 142 | function mergeBuffers(recBuffers, recLength) { 143 | let result = new Float32Array(recLength); 144 | let offset = 0; 145 | for (let i = 0; i < recBuffers.length; i++) { 146 | result.set(recBuffers[i], offset); 147 | offset += recBuffers[i].length; 148 | } 149 | return result; 150 | } 151 | 152 | function interleave(inputL, inputR) { 153 | let length = inputL.length + inputR.length; 154 | let result = new Float32Array(length); 155 | 156 | let index = 0, 157 | inputIndex = 0; 158 | 159 | while (index < length) { 160 | result[index++] = inputL[inputIndex]; 161 | result[index++] = inputR[inputIndex]; 162 | inputIndex++; 163 | } 164 | return result; 165 | } 166 | 167 | function floatTo16BitPCM(output, offset, input) { 168 | for (let i = 0; i < input.length; i++, offset += 2) { 169 | let s = Math.max(-1, Math.min(1, input[i])); 170 | output.setInt16(offset, s < 0 ? s * 0x8000 : s * 0x7FFF, true); 171 | } 172 | } 173 | 174 | function writeString(view, offset, string) { 175 | for (let i = 0; i < string.length; i += 1) { 176 | view.setUint8(offset + i, string.charCodeAt(i)); 177 | } 178 | } 179 | 180 | function encodeWAV(samples) { 181 | const buffer = new ArrayBuffer(44 + (samples.length * 2)); 182 | const view = new DataView(buffer); 183 | 184 | /* RIFF identifier */ 185 | writeString(view, 0, 'RIFF'); 186 | /* RIFF chunk length */ 187 | view.setUint32(4, 36 + (samples.length * 2), true); 188 | /* RIFF type */ 189 | writeString(view, 8, 'WAVE'); 190 | /* format chunk identifier */ 191 | writeString(view, 12, 'fmt '); 192 | /* format chunk length */ 193 | view.setUint32(16, 16, true); 194 | /* sample format (raw) */ 195 | view.setUint16(20, 1, true); 196 | /* channel count */ 197 | view.setUint16(22, numChannels, true); 198 | /* sample rate */ 199 | view.setUint32(24, sampleRate, true); 200 | /* byte rate (sample rate * block align) */ 201 | view.setUint32(28, sampleRate * 4, true); 202 | /* block align (channel count * bytes per sample) */ 203 | view.setUint16(32, numChannels * 2, true); 204 | /* bits per sample */ 205 | view.setUint16(34, 16, true); 206 | /* data chunk identifier */ 207 | writeString(view, 36, 'data'); 208 | /* data chunk length */ 209 | view.setUint32(40, samples.length * 2, true); 210 | 211 | floatTo16BitPCM(view, 44, samples); 212 | 213 | return view; 214 | } 215 | }, self); 216 | 217 | this.worker.postMessage({ 218 | command: 'init', 219 | config: { 220 | sampleRate: this.context.sampleRate, 221 | numChannels: this.config.numChannels, 222 | }, 223 | }); 224 | 225 | this.worker.onmessage = (e) => { 226 | const cb = this.callbacks[e.data.command].pop(); 227 | if (typeof cb === 'function') { 228 | cb(e.data.data); 229 | } 230 | }; 231 | } 232 | 233 | 234 | record() { 235 | this.recording = true; 236 | } 237 | 238 | stop() { 239 | this.recording = false; 240 | } 241 | 242 | clear() { 243 | this.worker.postMessage({command: 'clear'}); 244 | } 245 | 246 | getBuffer(cb) { 247 | cb = cb || this.config.callback; 248 | 249 | if (!cb) throw new Error('Callback not set'); 250 | 251 | this.callbacks.getBuffer.push(cb); 252 | 253 | this.worker.postMessage({command: 'getBuffer'}); 254 | } 255 | 256 | exportWAV(cb, mimeType) { 257 | mimeType = mimeType || this.config.mimeType; 258 | cb = cb || this.config.callback; 259 | 260 | if (!cb) throw new Error('Callback not set'); 261 | 262 | this.callbacks.exportWAV.push(cb); 263 | 264 | this.worker.postMessage({ 265 | command: 'exportWAV', 266 | type: mimeType, 267 | }); 268 | } 269 | } 270 | 271 | Microphone.forceDownload = function forceDownload(blob, filename) { 272 | const a = document.createElement('a'); 273 | 274 | a.style = 'display: none'; 275 | document.body.appendChild(a); 276 | 277 | var url = window.URL.createObjectURL(blob); 278 | 279 | a.href = url; 280 | a.download = filename; 281 | a.click(); 282 | 283 | window.URL.revokeObjectURL(url); 284 | 285 | document.body.removeChild(a); 286 | }; 287 | 288 | export default Microphone; -------------------------------------------------------------------------------- /src/lib/recorder.js: -------------------------------------------------------------------------------- 1 | import Microphone from './microphone'; 2 | 3 | const defaultConfig = { 4 | nFrequencyBars: 255, 5 | onAnalysed: null, 6 | }; 7 | 8 | const microphoneConfigOptions = ['bufferLen', 'numChannels', 'mimeType']; 9 | 10 | class Recorder { 11 | constructor(audioContext, config = {}) { 12 | this.config = Object.assign({}, defaultConfig, config); 13 | 14 | this.audioContext = audioContext; 15 | this.audioInput = null; 16 | this.realAudioInput = null; 17 | this.inputPoint = null; 18 | this.audioRecorder = null; 19 | this.rafID = null; 20 | this.analyserContext = null; 21 | this.recIndex = 0; 22 | this.stream = null; 23 | 24 | this.microphoneConfig = microphoneConfigOptions.reduce((a, c) => { 25 | if (config[c]) { 26 | a[c] = config[c]; 27 | } 28 | return a; 29 | }, {}); 30 | 31 | this.updateAnalysers = this.updateAnalysers.bind(this); 32 | } 33 | 34 | init(stream) { 35 | return new Promise((resolve) => { 36 | this.inputPoint = this.audioContext.createGain(); 37 | 38 | this.stream = stream; 39 | 40 | this.realAudioInput = this.audioContext.createMediaStreamSource(stream); 41 | this.audioInput = this.realAudioInput; 42 | this.audioInput.connect(this.inputPoint); 43 | 44 | this.analyserNode = this.audioContext.createAnalyser(); 45 | this.analyserNode.fftSize = 512; 46 | this.analyserNode.smoothingTimeConstant = 0.99; 47 | this.inputPoint.connect(this.analyserNode); 48 | 49 | this.audioRecorder = new Microphone(this.inputPoint, this.microphoneConfig); 50 | 51 | const zeroGain = this.audioContext.createGain(); 52 | zeroGain.gain.value = 0.0; 53 | 54 | this.inputPoint.connect(zeroGain); 55 | zeroGain.connect(this.audioContext.destination); 56 | 57 | this.updateAnalysers(); 58 | 59 | resolve(); 60 | }); 61 | } 62 | 63 | start() { 64 | return new Promise((resolve, reject) => { 65 | if (!this.audioRecorder) { 66 | reject('Not currently recording'); 67 | return; 68 | } 69 | 70 | this.audioRecorder.clear(); 71 | this.audioRecorder.record(); 72 | 73 | resolve(this.stream); 74 | }); 75 | } 76 | 77 | stop() { 78 | return new Promise((resolve) => { 79 | this.audioRecorder.stop(); 80 | 81 | this.audioRecorder.getBuffer((buffer) => { 82 | this.audioRecorder.exportWAV(blob => resolve({buffer, blob})); 83 | }); 84 | }); 85 | } 86 | 87 | updateAnalysers() { 88 | if (this.config.onAnalysed) { 89 | requestAnimationFrame(this.updateAnalysers); 90 | 91 | const freqByteData = new Uint8Array(this.analyserNode.frequencyBinCount); 92 | 93 | this.analyserNode.getByteFrequencyData(freqByteData); 94 | 95 | const data = new Array(255); 96 | let lastNonZero = 0; 97 | let datum; 98 | 99 | for (let idx = 0; idx < 255; idx += 1) { 100 | datum = Math.floor(freqByteData[idx]) - (Math.floor(freqByteData[idx]) % 5); 101 | 102 | if (datum !== 0) { 103 | lastNonZero = idx; 104 | } 105 | 106 | data[idx] = datum; 107 | } 108 | 109 | this.config.onAnalysed({data, lineTo: lastNonZero}); 110 | } 111 | } 112 | 113 | setOnAnalysed(handler) { 114 | this.config.onAnalysed = handler; 115 | } 116 | } 117 | 118 | Recorder.download = function download(blob, filename = 'audio') { 119 | Microphone.forceDownload(blob, `${filename}.wav`); 120 | }; 121 | 122 | export default Recorder; -------------------------------------------------------------------------------- /src/lib/request.js: -------------------------------------------------------------------------------- 1 | // orig. developit/unfetch 2 | export function request(url, options) { 3 | options = options || {}; 4 | return new Promise((resolve, reject) => { 5 | const request = new XMLHttpRequest(); 6 | 7 | const keys = []; 8 | const all = []; 9 | const headers = {}; 10 | 11 | const response = () => ({ 12 | ok: ((request.status / 100) | 0) == 2, // 200-299 13 | statusText: request.statusText, 14 | status: request.status, 15 | url: request.responseURL, 16 | text: () => Promise.resolve(request.responseText), 17 | json: () => Promise.resolve(request.responseText).then(JSON.parse), 18 | blob: () => Promise.resolve(new Blob([request.response])), 19 | clone: response, 20 | headers: { 21 | keys: () => keys, 22 | entries: () => all, 23 | get: n => headers[n.toLowerCase()], 24 | has: n => n.toLowerCase() in headers 25 | } 26 | }); 27 | 28 | request.open(options.method || 'get', url, true); 29 | 30 | request.onload = () => { 31 | request 32 | .getAllResponseHeaders() 33 | .replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm, (m, key, value) => { 34 | keys.push((key = key.toLowerCase())); 35 | all.push([key, value]); 36 | headers[key] = headers[key] ? `${headers[key]},${value}` : value; 37 | }); 38 | const res = response(); 39 | 40 | if(!res.ok){ 41 | return reject(JSON.parse(request.responseText)); 42 | } 43 | 44 | resolve(res); 45 | }; 46 | 47 | request.onerror = reject; 48 | 49 | request.withCredentials = options.credentials == 'include'; 50 | 51 | for (const i in options.headers) { 52 | request.setRequestHeader(i, options.headers[i]); 53 | } 54 | 55 | request.send(options.body || null); 56 | }); 57 | } 58 | -------------------------------------------------------------------------------- /src/lib/vad.js: -------------------------------------------------------------------------------- 1 | export default function VAD(options) { 2 | // Default options 3 | this.options = { 4 | fftSize: 512, 5 | bufferLen: 512, 6 | voice_stop: function() {}, 7 | voice_start: function() {}, 8 | smoothingTimeConstant: 0.99, 9 | energy_offset: 1e-8, // The initial offset. 10 | energy_threshold_ratio_pos: 2, // Signal must be twice the offset 11 | energy_threshold_ratio_neg: 0.5, // Signal must be half the offset 12 | energy_integration: 1, // Size of integration change compared to the signal per second. 13 | filter: [ 14 | { f: 200, v: 0 }, // 0 -> 200 is 0 15 | { f: 2000, v: 1 } // 200 -> 2k is 1 16 | ], 17 | source: null, 18 | context: null 19 | }; 20 | 21 | // User options 22 | for (var option in options) { 23 | if (options.hasOwnProperty(option)) { 24 | this.options[option] = options[option]; 25 | } 26 | } 27 | 28 | // Calculate time relationships 29 | this.hertzPerBin = this.options.context.sampleRate / this.options.fftSize; 30 | this.iterationFrequency = 31 | this.options.context.sampleRate / this.options.bufferLen; 32 | this.iterationPeriod = 1 / this.iterationFrequency; 33 | 34 | var DEBUG = true; 35 | if (DEBUG) 36 | console.log( 37 | 'Vad' + 38 | ' | sampleRate: ' + 39 | this.options.context.sampleRate + 40 | ' | hertzPerBin: ' + 41 | this.hertzPerBin + 42 | ' | iterationFrequency: ' + 43 | this.iterationFrequency + 44 | ' | iterationPeriod: ' + 45 | this.iterationPeriod 46 | ); 47 | 48 | this.setFilter = function(shape) { 49 | this.filter = []; 50 | for (var i = 0, iLen = this.options.fftSize / 2; i < iLen; i++) { 51 | this.filter[i] = 0; 52 | for (var j = 0, jLen = shape.length; j < jLen; j++) { 53 | if (i * this.hertzPerBin < shape[j].f) { 54 | this.filter[i] = shape[j].v; 55 | break; // Exit j loop 56 | } 57 | } 58 | } 59 | }; 60 | 61 | this.setFilter(this.options.filter); 62 | 63 | this.ready = {}; 64 | this.vadState = false; // True when Voice Activity Detected 65 | 66 | // Energy detector props 67 | this.energy_offset = this.options.energy_offset; 68 | this.energy_threshold_pos = 69 | this.energy_offset * this.options.energy_threshold_ratio_pos; 70 | this.energy_threshold_neg = 71 | this.energy_offset * this.options.energy_threshold_ratio_neg; 72 | 73 | this.voiceTrend = 0; 74 | this.voiceTrendMax = 10; 75 | this.voiceTrendMin = -10; 76 | this.voiceTrendStart = 5; 77 | this.voiceTrendEnd = -5; 78 | 79 | this.floatFrequencyData = new Float32Array(255); 80 | 81 | // Setup local storage of the Linear FFT data 82 | this.floatFrequencyDataLinear = new Float32Array(255); 83 | 84 | // Create callback to update/analyze floatFrequencyData 85 | options.onaudioprocess((data) => { 86 | this.floatFrequencyData = data; 87 | this.update(); 88 | this.monitor(); 89 | }) 90 | 91 | // log stuff 92 | this.logging = false; 93 | this.log_i = 0; 94 | this.log_limit = 100; 95 | 96 | this.triggerLog = function(limit) { 97 | this.logging = true; 98 | this.log_i = 0; 99 | this.log_limit = typeof limit === 'number' ? limit : this.log_limit; 100 | }; 101 | 102 | this.log = function(msg) { 103 | if (this.logging && this.log_i < this.log_limit) { 104 | this.log_i++; 105 | console.log(msg); 106 | } else { 107 | this.logging = false; 108 | } 109 | }; 110 | 111 | this.update = function() { 112 | // Update the local version of the Linear FFT 113 | var fft = this.floatFrequencyData; 114 | for (var i = 0, iLen = fft.length; i < iLen; i++) { 115 | this.floatFrequencyDataLinear[i] = Math.pow(10, fft[i] / 10); 116 | } 117 | this.ready = {}; 118 | }; 119 | 120 | this.getEnergy = function() { 121 | if (this.ready.energy) { 122 | return this.energy; 123 | } 124 | 125 | var energy = 0; 126 | var fft = this.floatFrequencyDataLinear; 127 | 128 | for (var i = 0, iLen = fft.length; i < iLen; i++) { 129 | energy += this.filter[i] * fft[i] * fft[i]; 130 | } 131 | 132 | this.energy = energy; 133 | this.ready.energy = true; 134 | 135 | return energy; 136 | }; 137 | 138 | this.monitor = function() { 139 | var energy = this.getEnergy(); 140 | var signal = energy - this.energy_offset; 141 | 142 | if (signal > this.energy_threshold_pos) { 143 | this.voiceTrend = 144 | this.voiceTrend + 1 > this.voiceTrendMax 145 | ? this.voiceTrendMax 146 | : this.voiceTrend + 1; 147 | } else if (signal < -this.energy_threshold_neg) { 148 | this.voiceTrend = 149 | this.voiceTrend - 1 < this.voiceTrendMin 150 | ? this.voiceTrendMin 151 | : this.voiceTrend - 1; 152 | } else { 153 | // voiceTrend gets smaller 154 | if (this.voiceTrend > 0) { 155 | this.voiceTrend--; 156 | } else if (this.voiceTrend < 0) { 157 | this.voiceTrend++; 158 | } 159 | } 160 | 161 | var start = false, 162 | end = false; 163 | if (this.voiceTrend > this.voiceTrendStart) { 164 | // Start of speech detected 165 | start = true; 166 | } else if (this.voiceTrend < this.voiceTrendEnd) { 167 | // End of speech detected 168 | end = true; 169 | } 170 | 171 | // Integration brings in the real-time aspect through the relationship with the frequency this functions is called. 172 | var integration = 173 | signal * this.iterationPeriod * this.options.energy_integration; 174 | 175 | // Idea?: The integration is affected by the voiceTrend magnitude? - Not sure. Not doing atm. 176 | 177 | // The !end limits the offset delta boost till after the end is detected. 178 | if (integration > 0 || !end) { 179 | this.energy_offset += integration; 180 | } else { 181 | this.energy_offset += integration * 10; 182 | } 183 | this.energy_offset = this.energy_offset < 0 ? 0 : this.energy_offset; 184 | this.energy_threshold_pos = 185 | this.energy_offset * this.options.energy_threshold_ratio_pos; 186 | this.energy_threshold_neg = 187 | this.energy_offset * this.options.energy_threshold_ratio_neg; 188 | 189 | // Broadcast the messages 190 | if (start && !this.vadState) { 191 | this.vadState = true; 192 | this.options.voice_start(); 193 | } 194 | if (end && this.vadState) { 195 | this.vadState = false; 196 | this.options.voice_stop(); 197 | } 198 | 199 | this.log( 200 | 'e: ' + 201 | energy + 202 | ' | e_of: ' + 203 | this.energy_offset + 204 | ' | e+_th: ' + 205 | this.energy_threshold_pos + 206 | ' | e-_th: ' + 207 | this.energy_threshold_neg + 208 | ' | signal: ' + 209 | signal + 210 | ' | int: ' + 211 | integration + 212 | ' | voiceTrend: ' + 213 | this.voiceTrend + 214 | ' | start: ' + 215 | start + 216 | ' | end: ' + 217 | end 218 | ); 219 | 220 | return signal; 221 | }; 222 | } 223 | -------------------------------------------------------------------------------- /src/scss/main.scss: -------------------------------------------------------------------------------- 1 | .AssemblyAIHelper{ 2 | .ais-VoiceSearch{ 3 | &-button{ 4 | width: 140px; 5 | display: inline-block; 6 | font-weight: 400; 7 | background-color: #3392FE; 8 | color: white; 9 | text-align: center; 10 | white-space: nowrap; 11 | vertical-align: middle; 12 | -webkit-user-select: none; 13 | -moz-user-select: none; 14 | -ms-user-select: none; 15 | user-select: none; 16 | border: 1px solid transparent; 17 | padding: .375rem .75rem; 18 | font-size: 1rem; 19 | line-height: 1.5; 20 | border-radius: .25rem; 21 | transition: background-color .15s ease-in-out; 22 | cursor: pointer; 23 | 24 | &:active, &:focus, &:hover{ 25 | outline: none; 26 | background-color: #2E80DC; 27 | } 28 | } 29 | 30 | &-status > div{ 31 | padding: .75rem 1.25rem; 32 | margin: 1rem 0; 33 | border: 1px solid #f5c6cb; 34 | border-radius: .25rem; 35 | background-color: #f8d7da; 36 | color: #721c24; 37 | } 38 | } 39 | 40 | &--listening{ 41 | .ais-VoiceSearch-button{ 42 | background-color: #E74C3C; 43 | 44 | animation: assemblyaihelper-pulse 1s infinite; 45 | 46 | &:hover, &:active, &:focus{ 47 | background-color: #E74C3C; 48 | } 49 | } 50 | } 51 | } 52 | 53 | @keyframes assemblyaihelper-pulse{ 54 | 0% { 55 | box-shadow: 0 0 0 0px rgba(0, 0, 0, 0.2); 56 | } 57 | 100% { 58 | box-shadow: 0 0 0 10px rgba(0, 0, 0, 0); 59 | } 60 | } -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = { 4 | mode: 'development', 5 | entry: './src/index.js', 6 | output: { 7 | path: path.resolve(__dirname, 'public'), 8 | filename: 'assemblyai-voice-helper.js', 9 | library: 'assemblyAIHelper', 10 | libraryTarget: 'var', 11 | libraryExport: 'assemblyAIHelper' 12 | }, 13 | module: { 14 | rules: [ 15 | { 16 | test: /\.(s*)css$/, 17 | use: ['style-loader', 'css-loader', 'sass-loader'] 18 | }, 19 | { 20 | test: /\.m?js$/, 21 | exclude: /(node_modules|bower_components)/, 22 | use: [ 23 | { 24 | loader: 'babel-loader', 25 | options: { 26 | presets: ['@babel/preset-env'] 27 | } 28 | } 29 | ] 30 | } 31 | ] 32 | }, 33 | devServer: { 34 | contentBase: path.join(__dirname, 'public'), 35 | compress: true, 36 | port: 3000 37 | } 38 | }; 39 | --------------------------------------------------------------------------------