@speechly/browser-client
Advanced tools
Comparing version 0.1.4 to 0.2.0
{ | ||
"name": "@speechly/browser-client", | ||
"version": "0.1.4", | ||
"version": "0.2.0", | ||
"description": "Browser client for Speechly API", | ||
@@ -5,0 +5,0 @@ "private": false, |
@@ -5,2 +5,3 @@ # <a href="https://speechly.com/"><img src="https://www.speechly.com/images/logo.png" height="100" alt="Speechly"></a> | ||
![Release build](https://github.com/speechly/browser-client/workflows/Release%20build/badge.svg?branch=master&event=release) | ||
[![npm version](https://badge.fury.io/js/%40speechly%2Fbrowser-client.svg)](https://badge.fury.io/js/%40speechly%2Fbrowser-client) | ||
@@ -7,0 +8,0 @@ |
/** | ||
* A callback that receives an ArrayBuffer representing a frame of audio. | ||
* @public | ||
*/ | ||
export declare type AudioCallback = (audioBuffer: ArrayBuffer) => void; | ||
/** | ||
* Microphone implementation for the browser. Uses getUserMedia and Web Audio API. | ||
* @public | ||
*/ | ||
export declare class BrowserMicrophone implements Microphone { | ||
private readonly sampleRate; | ||
private onAudioCb; | ||
private audioTrack?; | ||
private mediaStream?; | ||
private audioProcessor?; | ||
private audioContext?; | ||
private downsampler?; | ||
constructor(sampleRate: number); | ||
onAudio(cb: AudioCallback): void; | ||
initialize(cb: ErrorCallback): void; | ||
close(cb: ErrorCallback): void; | ||
mute(): void; | ||
unmute(): void; | ||
private initializeAudioContext; | ||
} | ||
/** | ||
* A client for Speechly Spoken Language Understanding (SLU) API. The client handles initializing the microphone | ||
@@ -121,2 +148,6 @@ * and websocket connection to Speechly API, passing control events and audio stream to the API, reading the responses | ||
debug?: boolean; | ||
/** | ||
* Microphone instance. | ||
*/ | ||
microphone?: Microphone; | ||
} | ||
@@ -152,2 +183,8 @@ | ||
/** | ||
* Default sample rate for microphone streams. | ||
* @public | ||
*/ | ||
export declare const DefaultSampleRate = 16000; | ||
/** | ||
* A single entity detected by the SLU API. | ||
@@ -186,2 +223,26 @@ * @public | ||
/** | ||
* Error to be thrown when the initialize method of a Microphone instance is called more than once. | ||
* @public | ||
*/ | ||
export declare const ErrAlreadyInitialized: Error; | ||
/** | ||
* Error to be thrown when the device does not support the Microphone instance's target audio APIs. | ||
* @public | ||
*/ | ||
export declare const ErrDeviceNotSupported: Error; | ||
/** | ||
* Error to be thrown when user did not give consent to the application to record audio. | ||
* @public | ||
*/ | ||
export declare const ErrNoAudioConsent: Error; | ||
/** | ||
* Error to be thrown when the microphone was accessed before it was initialized. | ||
* @public | ||
*/ | ||
export declare const ErrNotInitialized: Error; | ||
/** | ||
* A callback that receives an optional error. | ||
@@ -214,2 +275,14 @@ * @public | ||
/** | ||
* An interface for a microphone. | ||
* @public | ||
*/ | ||
export declare interface Microphone { | ||
onAudio(cb: AudioCallback): void; | ||
initialize(cb: ErrorCallback): void; | ||
close(cb: ErrorCallback): void; | ||
mute(): void; | ||
unmute(): void; | ||
} | ||
/** | ||
* The smallest component of SLU API, defined by an intent. | ||
@@ -216,0 +289,0 @@ * @public |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.speechly=t():e.speechly=t()}(window,(function(){return function(e){var t={};function n(a){if(t[a])return t[a].exports;var i=t[a]={i:a,l:!1,exports:{}};return e[a].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,a){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(a,i,function(t){return e[t]}.bind(null,i));return a},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=27)}([function(e,t,n){var a=n(2),i=n(6);e.exports=function(e,t,n){i(e,(function(i,r){if(a(e,r))return t.call(n,e[r],r,e)}))}},function(e,t,n){var a=n(34),i=n(15),r=n(16);e.exports=function(e,t){if(null==e)return a;switch(typeof e){case"function":return void 0!==t?function(n,a,i){return e.call(t,n,a,i)}:e;case"object":return function(t){return r(t,e)};case"string":case"number":return i(e)}}},function(e,t){e.exports=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},function(e,t){e.exports=function(e,t,n){var a=e.length;t=null==t?0:t<0?Math.max(a+t,0):Math.min(t,a),n=null==n?a:n<0?Math.max(a+n,0):Math.min(n,a);for(var i=[];t<n;)i.push(e[t++]);return i}},function(e,t){e.exports=function(e){return!!e&&"object"==typeof e&&e.constructor===Object}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.Failed=0]="Failed",e[e.NoBrowserSupport=1]="NoBrowserSupport",e[e.NoAudioConsent=2]="NoAudioConsent",e[e.Disconnected=3]="Disconnected",e[e.Disconnecting=4]="Disconnecting",e[e.Connecting=5]="Connecting",e[e.Connected=6]="Connected",e[e.Starting=7]="Starting",e[e.Stopping=8]="Stopping",e[e.Recording=9]="Recording"}(t.ClientState||(t.ClientState={}))},function(e,t,n){var a,i,r=n(2);function o(e,t,n,a){return e.call(a,t[n],n,t)}e.exports=function(e,t,n){var s,u=0;for(s in null==a&&function(){for(var e in i=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],a=!0,{toString:null})a=!1}(),e)if(!1===o(t,e,s,n))break;if(a)for(var c=e.constructor,l=!!c&&e===c.prototype;(s=i[u++])&&("constructor"===s&&(l||!r(e,s))||e[s]===Object.prototype[s]||!1!==o(t,e,s,n)););}},function(e,t){e.exports=function(e,t,n){if(null!=e)for(var a=-1,i=e.length;++a<i&&!1!==t.call(n,e[a],a,e););}},function(e,t,n){var a=n(0),i=n(1);e.exports=function(e,t,n){t=i(t,n);var r=!1;return a(e,(function(n,a){if(t(n,a,e))return r=!0,!1})),r}},function(e,t,n){var a=n(10);e.exports=function(e,t){return a(e)===t}},function(e,t){var n=/^\[object (.*)\]$/,a=Object.prototype.toString;e.exports=function(e){return null===e?"Null":void 0===e?"Undefined":n.exec(a.call(e))[1]}},function(e,t,n){var a=n(0);e.exports=function(e){var t=[];return a(e,(function(e,n){t.push(e)})),t}},function(e,t,n){(function(){var t,a,i;a=n(30),t=function(){function e(){}return e.prototype.getCountry=function(t){return e.prototype.countries[t]},e.prototype.getCode=function(t){var n,i;return i=null,null!=t&&-1!==(n=a.values(e.prototype.countries).indexOf(t))&&(i=Object.keys(e.prototype.countries)[n]),i},e.prototype.getCountries=function(){return a.values(e.prototype.countries)},e.prototype.getCodes=function(){return Object.keys(e.prototype.countries)},e.prototype.getData=function(){return e.prototype.countries},e.prototype.countries={AF:"Afghanistan",AX:"Åland Islands",AL:"Albania",DZ:"Algeria",AS:"American Samoa",AD:"Andorra",AO:"Angola",AI:"Anguilla",AQ:"Antarctica",AG:"Antigua and Barbuda",AR:"Argentina",AM:"Armenia",AW:"Aruba",AU:"Australia",AT:"Austria",AZ:"Azerbaijan",BS:"Bahamas",BH:"Bahrain",BD:"Bangladesh",BB:"Barbados",BY:"Belarus",BE:"Belgium",BZ:"Belize",BJ:"Benin",BM:"Bermuda",BT:"Bhutan",BO:"Bolivia, Plurinational State of",BQ:"Bonaire, Sint Eustatius and Saba",BA:"Bosnia and Herzegovina",BW:"Botswana",BV:"Bouvet Island",BR:"Brazil",IO:"British Indian Ocean Territory",BN:"Brunei Darussalam",BG:"Bulgaria",BF:"Burkina Faso",BI:"Burundi",KH:"Cambodia",CM:"Cameroon",CA:"Canada",CV:"Cape Verde",KY:"Cayman Islands",CF:"Central African Republic",TD:"Chad",CL:"Chile",CN:"China",CX:"Christmas Island",CC:"Cocos (Keeling) Islands",CO:"Colombia",KM:"Comoros",CG:"Congo",CD:"Congo, the Democratic Republic of the",CK:"Cook Islands",CR:"Costa Rica",CI:"Côte d'Ivoire",HR:"Croatia",CU:"Cuba",CW:"Curaçao",CY:"Cyprus",CZ:"Czech Republic",DK:"Denmark",DJ:"Djibouti",DM:"Dominica",DO:"Dominican Republic",EC:"Ecuador",EG:"Egypt",SV:"El Salvador",GQ:"Equatorial Guinea",ER:"Eritrea",EE:"Estonia",ET:"Ethiopia",FK:"Falkland Islands (Malvinas)",FO:"Faroe Islands",FJ:"Fiji",FI:"Finland",FR:"France",GF:"French Guiana",PF:"French Polynesia",TF:"French Southern Territories",GA:"Gabon",GM:"Gambia",GE:"Georgia",DE:"Germany",GH:"Ghana",GI:"Gibraltar",GR:"Greece",GL:"Greenland",GD:"Grenada",GP:"Guadeloupe",GU:"Guam",GT:"Guatemala",GG:"Guernsey",GN:"Guinea",GW:"Guinea-Bissau",GY:"Guyana",HT:"Haiti",HM:"Heard Island and McDonald Mcdonald Islands",VA:"Holy See (Vatican City State)",HN:"Honduras",HK:"Hong Kong",HU:"Hungary",IS:"Iceland",IN:"India",ID:"Indonesia",IR:"Iran, Islamic Republic of",IQ:"Iraq",IE:"Ireland",IM:"Isle of Man",IL:"Israel",IT:"Italy",JM:"Jamaica",JP:"Japan",JE:"Jersey",JO:"Jordan",KZ:"Kazakhstan",KE:"Kenya",KI:"Kiribati",KP:"Korea, Democratic People's Republic of",KR:"Korea, Republic of",KW:"Kuwait",KG:"Kyrgyzstan",LA:"Lao People's Democratic Republic",LV:"Latvia",LB:"Lebanon",LS:"Lesotho",LR:"Liberia",LY:"Libya",LI:"Liechtenstein",LT:"Lithuania",LU:"Luxembourg",MO:"Macao",MK:"Macedonia, the Former Yugoslav Republic of",MG:"Madagascar",MW:"Malawi",MY:"Malaysia",MV:"Maldives",ML:"Mali",MT:"Malta",MH:"Marshall Islands",MQ:"Martinique",MR:"Mauritania",MU:"Mauritius",YT:"Mayotte",MX:"Mexico",FM:"Micronesia, Federated States of",MD:"Moldova, Republic of",MC:"Monaco",MN:"Mongolia",ME:"Montenegro",MS:"Montserrat",MA:"Morocco",MZ:"Mozambique",MM:"Myanmar",NA:"Namibia",NR:"Nauru",NP:"Nepal",NL:"Netherlands",NC:"New Caledonia",NZ:"New Zealand",NI:"Nicaragua",NE:"Niger",NG:"Nigeria",NU:"Niue",NF:"Norfolk Island",MP:"Northern Mariana Islands",NO:"Norway",OM:"Oman",PK:"Pakistan",PW:"Palau",PS:"Palestine, State of",PA:"Panama",PG:"Papua New Guinea",PY:"Paraguay",PE:"Peru",PH:"Philippines",PN:"Pitcairn",PL:"Poland",PT:"Portugal",PR:"Puerto Rico",QA:"Qatar",RE:"Réunion",RO:"Romania",RU:"Russian Federation",RW:"Rwanda",BL:"Saint Barthélemy",SH:"Saint Helena, Ascension and Tristan da Cunha",KN:"Saint Kitts and Nevis",LC:"Saint Lucia",MF:"Saint Martin (French part)",PM:"Saint Pierre and Miquelon",VC:"Saint Vincent and the Grenadines",WS:"Samoa",SM:"San Marino",ST:"Sao Tome and Principe",SA:"Saudi Arabia",SN:"Senegal",RS:"Serbia",SC:"Seychelles",SL:"Sierra Leone",SG:"Singapore",SX:"Sint Maarten (Dutch part)",SK:"Slovakia",SI:"Slovenia",SB:"Solomon Islands",SO:"Somalia",ZA:"South Africa",GS:"South Georgia and the South Sandwich Islands",SS:"South Sudan",ES:"Spain",LK:"Sri Lanka",SD:"Sudan",SR:"Suriname",SJ:"Svalbard and Jan Mayen",SZ:"Swaziland",SE:"Sweden",CH:"Switzerland",SY:"Syrian Arab Republic",TW:"Taiwan, Province of China",TJ:"Tajikistan",TZ:"Tanzania, United Republic of",TH:"Thailand",TL:"Timor-Leste",TG:"Togo",TK:"Tokelau",TO:"Tonga",TT:"Trinidad and Tobago",TN:"Tunisia",TR:"Turkey",TM:"Turkmenistan",TC:"Turks and Caicos Islands",TV:"Tuvalu",UG:"Uganda",UA:"Ukraine",AE:"United Arab Emirates",GB:"United Kingdom",US:"United States",UM:"United States Minor Outlying Islands",UY:"Uruguay",UZ:"Uzbekistan",VU:"Vanuatu",VE:"Venezuela, Bolivarian Republic of",VN:"Viet Nam",VG:"Virgin Islands, British",VI:"Virgin Islands, U.S.",WF:"Wallis and Futuna",EH:"Western Sahara",YE:"Yemen",ZM:"Zambia",ZW:"Zimbabwe"},e}(),i=null,e.exports=null!=i?i:i=new t}).call(this)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=n(5);t.stateToString=function(e){var t;return null!=(t=r.get(e))?t:i};const i="Unknown",r=new Map([[a.ClientState.Failed,"Failed"],[a.ClientState.NoBrowserSupport,"NoBrowserSupport"],[a.ClientState.NoAudioConsent,"NoAudioConsent"],[a.ClientState.Disconnecting,"Disconnecting"],[a.ClientState.Disconnected,"Disconnected"],[a.ClientState.Connecting,"Connecting"],[a.ClientState.Connected,"Connected"],[a.ClientState.Starting,"Starting"],[a.ClientState.Stopping,"Stopping"],[a.ClientState.Recording,"Recording"]])},function(e,t,n){var a=n(6);e.exports=function(e){var t=[];return a(e,(function(e,n){"function"==typeof e&&t.push(n)})),t.sort()}},function(e,t){e.exports=function(e){return function(t){return t[e]}}},function(e,t,n){var a=n(0),i=n(35);function r(e,t){for(var n=-1,a=e.length;++n<a;)if(o(e[n],t))return!0;return!1}function o(e,t){return e&&"object"==typeof e?i(e)&&i(t)?function(e,t){for(var n=-1,a=t.length;++n<a;)if(!r(e,t[n]))return!1;return!0}(e,t):function(e,t){var n=!0;return a(t,(function(t,a){if(!o(e[a],t))return n=!1})),n}(e,t):e===t}e.exports=o},function(e,t,n){var a=n(0),i=n(1);e.exports=function(e,t,n){t=i(t,n);var r=!0;return a(e,(function(n,a){if(!t(n,a,e))return r=!1,!1})),r}},function(e,t,n){var a=n(9);e.exports=function(e){return a(e,"Object")}},function(e,t,n){var a=n(0),i=n(1);e.exports=function(e,t,n){t=i(t,n);var r={};return a(e,(function(e,n,a){t(e,n,a)&&(r[n]=e)})),r}},function(e,t,n){n(43);e.exports=function(e,t){for(var n=t.split("."),a=n.pop();t=n.shift();)if(null==(e=e[t]))return;return e[a]}},function(e,t,n){var a=n(20);e.exports=function(e,t){return void 0!==a(e,t)}},function(e,t,n){var a=n(0),i=n(1);e.exports=function(e,t,n){t=i(t,n);var r={};return a(e,(function(e,n,a){r[n]=t(e,n,a)})),r}},function(e,t,n){var a=n(0);function i(e,t){this[t]=e}e.exports=function(e,t){for(var n,r=0,o=arguments.length;++r<o;)null!=(n=arguments[r])&&a(n,i,e);return e}},function(e,t,n){var a=n(7);e.exports=function(e,t){return t?(a(t.split("."),(function(t){e[t]||(e[t]={}),e=e[t]})),e):e}},function(e,t,n){var a=n(0);e.exports=function(e){var t=0;return a(e,(function(){t++})),t}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.Started="started",e.Stopped="stopped",e.SegmentEnd="segment_end",e.Transcript="transcript",e.Entity="entity",e.Intent="intent",e.TentativeTranscript="tentative_transcript",e.TentativeEntities="tentative_entities",e.TentativeIntent="tentative_intent"}(t.WebsocketResponseType||(t.WebsocketResponseType={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}(n(28))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}(n(5));var a=n(13);t.stateToString=a.stateToString;var i=n(29);t.Client=i.Client},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=n(70),i=n(64),r=n(66),o=n(13),s=n(68),u=n(69),c=n(5);t.Client=class{constructor(e){var t,n,o,h,v;if(this.activeContexts=new Map,this.state=c.ClientState.Disconnected,this.reconnectAttemptCount=d,this.nextReconnectDelay=m,this.stateChangeCb=()=>{},this.segmentChangeCb=()=>{},this.tentativeTranscriptCb=()=>{},this.tentativeEntitiesCb=()=>{},this.tentativeIntentCb=()=>{},this.transcriptCb=()=>{},this.entityCb=()=>{},this.intentCb=()=>{},this.handleWebsocketResponse=e=>{this.debug&&console.log("[SpeechlyClient]","Received response",e);const{audio_context:t,segment_id:n,type:a}=e;let{data:i}=e,o=this.activeContexts.get(t);if(void 0!==o){switch(a){case r.WebsocketResponseType.TentativeTranscript:i=i;const e=u.parseTentativeTranscript(i);this.tentativeTranscriptCb(t,n,e,i.transcript),o=o.updateTranscript(e);break;case r.WebsocketResponseType.Transcript:i=i;const a=u.parseTranscript(i);this.transcriptCb(t,n,a),o=o.updateTranscript([a]);break;case r.WebsocketResponseType.TentativeEntities:i=i;const s=u.parseTentativeEntities(i);this.tentativeEntitiesCb(t,n,s),o=o.updateEntities(s);break;case r.WebsocketResponseType.Entity:i=i;const c=u.parseEntity(i);this.entityCb(t,n,c),o=o.updateEntities([c]);break;case r.WebsocketResponseType.TentativeIntent:i=i;const l=u.parseIntent(i,!1);this.tentativeIntentCb(t,n,l),o=o.updateIntent(l);break;case r.WebsocketResponseType.Intent:i=i;const m=u.parseIntent(i,!0);this.intentCb(t,n,m),o=o.updateIntent(m);break;case r.WebsocketResponseType.SegmentEnd:o=o.finalize()}this.segmentChangeCb(o.toSegment()),o.isFinalized?this.activeContexts.set(t,new s.SegmentState(t,o.id+1)):this.activeContexts.set(t,o)}else console.warn("[SpeechlyClient]","Received response for non-existent context",t)},this.handleWebsocketClosure=e=>{this.debug&&console.error("[SpeechlyClient]","Server connection closed",e),this.reconnectWebsocket()},this.handleMicrophoneAudio=e=>{this.state===c.ClientState.Recording&&(this.debug&&console.log("[SpeechlyClient]","Sending audio data",e),this.websocket.send(e))},!a.default.validate(e.language))throw Error(`[SpeechlyClient] Invalid language "${e.language}"`);this.debug=null!=(t=e.debug)&&t,this.microphone=new i.Microphone(null!=(n=e.sampleRate)?n:i.DefaultSampleRate),this.websocket=new r.Websocket(null!=(o=e.url)?o:l,e.appId,e.language,null!=(h=e.deviceId)?h:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}),null!=(v=e.sampleRate)?v:i.DefaultSampleRate),this.microphone.onAudio(this.handleMicrophoneAudio),this.websocket.onResponse(this.handleWebsocketResponse),this.websocket.onClose(this.handleWebsocketClosure)}initialize(e=(()=>{})){if(this.state!==c.ClientState.Disconnected)return e(new Error("Cannot initialize client - client is not in Disconnected state"));this.setState(c.ClientState.Connecting),this.microphone.initialize(t=>{if(void 0!==t){switch(t){case i.ErrNoBrowserSupport:this.setState(c.ClientState.NoBrowserSupport);break;case i.ErrNoAudioConsent:this.setState(c.ClientState.NoAudioConsent);break;default:this.setState(c.ClientState.Failed)}return e(t)}this.websocket.initialize(t=>void 0!==t?(this.reconnectWebsocket(),e()):(this.setState(c.ClientState.Connected),e()))})}close(e=(()=>{})){this.microphone.close(t=>{const n=[];void 0!==t&&n.push(t.message);const a=this.websocket.close(1e3,"client disconnecting");return void 0!==a&&n.push(a.message),this.activeContexts.clear(),n.length>0?e(Error(n.join(","))):e()})}startContext(e=(()=>{})){if(this.state!==c.ClientState.Connected)return e(Error("Cannot start context - client is not connected"));this.reconnectAttemptCount=d,this.nextReconnectDelay=m,this.setState(c.ClientState.Starting),this.websocket.start((t,n)=>{if(void 0!==t)return this.setState(c.ClientState.Connected),e(t);const a=n;return this.setState(c.ClientState.Recording),this.microphone.unmute(),this.activeContexts.set(a,new s.SegmentState(a,1)),e(void 0,n)})}stopContext(e=(()=>{})){if(this.state!==c.ClientState.Recording)return e(new Error("Cannot stop context - client is not recording"));this.setState(c.ClientState.Stopping),this.microphone.mute(),this.websocket.stop((t,n)=>{if(void 0!==t)return this.setState(c.ClientState.Failed),e(t);const a=n;return this.setState(c.ClientState.Connected),this.activeContexts.delete(a)||console.warn("[SpeechlyClient]","Attempted to remove non-existent context",a),e()})}onStateChange(e){this.stateChangeCb=e}onSegmentChange(e){this.segmentChangeCb=e}onTentativeTranscript(e){this.tentativeTranscriptCb=e}onTranscript(e){this.transcriptCb=e}onTentativeEntities(e){this.tentativeEntitiesCb=e}onEntity(e){this.entityCb=e}onTentativeIntent(e){this.tentativeIntentCb=e}onIntent(e){this.intentCb=e}reconnectWebsocket(){if(this.reconnectAttemptCount<1)return this.setState(c.ClientState.Disconnected);this.state!==c.ClientState.Connecting&&this.setState(c.ClientState.Connecting),this.debug&&console.log("[SpeechlyClient]",`Attempting to re-connect to the server in ${this.nextReconnectDelay.toString()}ms`),setTimeout(()=>{this.reconnectAttemptCount=this.reconnectAttemptCount-1,this.nextReconnectDelay=2*this.nextReconnectDelay,this.websocket.initialize(e=>{if(void 0!==e)return this.reconnectWebsocket();this.setState(c.ClientState.Connected)})},this.nextReconnectDelay)}setState(e){this.state!==e&&(this.debug&&console.log("[SpeechlyClient]","State transition",o.stateToString(this.state),o.stateToString(e)),this.state=e,this.stateChangeCb(e))}};const l="wss://api.speechly.com/ws",m=1e3,d=5},function(e,t,n){e.exports={bindAll:n(31),contains:n(33),deepFillIn:n(36),deepMatches:n(16),deepMixIn:n(37),equals:n(38),every:n(17),fillIn:n(40),filter:n(19),find:n(41),flatten:n(42),forIn:n(6),forOwn:n(0),functions:n(14),get:n(20),has:n(21),hasOwn:n(2),keys:n(44),map:n(22),matches:n(45),max:n(46),merge:n(48),min:n(51),mixIn:n(23),namespace:n(24),omit:n(53),pick:n(56),pluck:n(57),reduce:n(58),reject:n(59),result:n(60),set:n(62),size:n(25),some:n(8),unset:n(63),values:n(11)}},function(e,t,n){var a=n(14),i=n(32),r=n(7),o=n(3);e.exports=function(e,t){var n=arguments.length>1?o(arguments,1):a(e);r(n,(function(t){e[t]=i(e[t],e)}))}},function(e,t,n){var a=n(3);e.exports=function(e,t,n){var i=a(arguments,2);return function(){return e.apply(t,i.concat(a(arguments)))}}},function(e,t,n){var a=n(8);e.exports=function(e,t){return a(e,(function(e){return e===t}))}},function(e,t){e.exports=function(e){return e}},function(e,t,n){var a=n(9),i=Array.isArray||function(e){return a(e,"Array")};e.exports=i},function(e,t,n){var a=n(0),i=n(4);e.exports=function e(t,n){for(var r,o=0,s=arguments.length;++o<s;)(r=arguments[o])&&a(r,(function(n,a){var r=t[a];null==r?t[a]=n:i(r)&&i(n)&&e(r,n)}));return t}},function(e,t,n){var a=n(0),i=n(4);function r(e,t){for(var n,i=0,r=arguments.length;++i<r;)(n=arguments[i])&&a(n,o,e);return e}function o(e,t){var n=this[t];i(e)&&i(n)?r(n,e):this[t]=e}e.exports=r},function(e,t,n){var a=n(2),i=n(17),r=n(18),o=n(39);function s(e,t){return a(this,t)}e.exports=function(e,t,n){return n=n||o,r(e)&&r(t)?i(e,function(e){return function(t,n){return a(this,n)&&e(t,this[n])}}(n),t)&&i(t,s,e):n(e,t)}},function(e,t){e.exports=function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}},function(e,t,n){var a=n(7),i=n(3),r=n(0);e.exports=function(e,t){return a(i(arguments,1),(function(t){r(t,(function(t,n){null==e[n]&&(e[n]=t)}))})),e}},function(e,t,n){var a=n(8),i=n(1);e.exports=function(e,t,n){var r;return t=i(t,n),a(e,(function(e,n,a){if(t(e,n,a))return r=e,!0})),r}},function(e,t,n){var a=n(0),i=n(4);e.exports=function(e,t){return null==e?{}:function e(t,n,r,o){return a(t,(function(t,a){var s=r?r+"."+a:a;0!==o&&i(t)?e(t,n,s,o-1):n[s]=t})),n}(e,{},"",t=null==t?-1:t)}},function(e,t){e.exports=function(e){switch(typeof e){case"string":case"number":case"boolean":return!0}return null==e}},function(e,t,n){var a=n(0),i=Object.keys||function(e){var t=[];return a(e,(function(e,n){t.push(n)})),t};e.exports=i},function(e,t,n){var a=n(0);e.exports=function(e,t){var n=!0;return a(t,(function(t,a){if(e[a]!==t)return n=!1})),n}},function(e,t,n){var a=n(47),i=n(11);e.exports=function(e,t){return a(i(e),t)}},function(e,t,n){var a=n(1);e.exports=function(e,t,n){if(null!=e&&e.length){if(e.length&&!t)return Math.max.apply(Math,e);t=a(t,n);for(var i,r,o,s=-1/0,u=-1,c=e.length;++u<c;)(o=t(r=e[u],u,e))>s&&(s=o,i=r);return i}return 1/0}},function(e,t,n){var a=n(2),i=n(49),r=n(18);e.exports=function e(){var t,n,o,s,u=1;for(s=i(arguments[0]);o=arguments[u++];)for(t in o)a(o,t)&&(n=o[t],r(n)&&r(s[t])?s[t]=e(s[t],n):s[t]=i(n));return s}},function(e,t,n){var a=n(50),i=n(0),r=n(10),o=n(4);function s(e,t){switch(r(e)){case"Object":return function(e,t){if(o(e)){var n={};return i(e,(function(e,n){this[n]=s(e,t)}),n),n}return t?t(e):e}(e,t);case"Array":return function(e,t){var n=[],a=-1,i=e.length;for(;++a<i;)n[a]=s(e[a],t);return n}(e,t);default:return a(e)}}e.exports=s},function(e,t,n){var a=n(10),i=n(4),r=n(23);e.exports=function(e){switch(a(e)){case"Object":return i(o=e)?r({},o):o;case"Array":return e.slice();case"RegExp":return n="",n+=(t=e).multiline?"m":"",n+=t.global?"g":"",n+=t.ignoreCase?"i":"",new RegExp(t.source,n);case"Date":return new Date(+e);default:return e}var t,n,o}},function(e,t,n){var a=n(52),i=n(11);e.exports=function(e,t){return a(i(e),t)}},function(e,t,n){var a=n(1);e.exports=function(e,t,n){if(null!=e&&e.length){if(e.length&&!t)return Math.min.apply(Math,e);t=a(t,n);for(var i,r,o,s=1/0,u=-1,c=e.length;++u<c;)(o=t(r=e[u],u,e))<s&&(s=o,i=r);return i}return-1/0}},function(e,t,n){var a=n(3),i=n(54);e.exports=function(e,t){var n="string"!=typeof arguments[1]?arguments[1]:a(arguments,1),r={};for(var o in e)e.hasOwnProperty(o)&&!i(n,o)&&(r[o]=e[o]);return r}},function(e,t,n){var a=n(55);e.exports=function(e,t){return-1!==a(e,t)}},function(e,t){e.exports=function(e,t,n){if(n=n||0,null==e)return-1;for(var a=e.length,i=n<0?a+n:n;i<a;){if(e[i]===t)return i;i++}return-1}},function(e,t,n){var a=n(3);e.exports=function(e,t){for(var n,i="string"!=typeof arguments[1]?arguments[1]:a(arguments,1),r={},o=0;n=i[o++];)r[n]=e[n];return r}},function(e,t,n){var a=n(22),i=n(15);e.exports=function(e,t){return a(e,i(t))}},function(e,t,n){var a=n(0),i=n(25);e.exports=function(e,t,n,r){var o=arguments.length>2;if(!i(e)&&!o)throw new Error("reduce of empty object with no initial value");return a(e,(function(e,a,i){o?n=t.call(r,n,e,a,i):(n=e,o=!0)})),n}},function(e,t,n){var a=n(19),i=n(1);e.exports=function(e,t,n){return t=i(t,n),a(e,(function(e,n,a){return!t(e,n,a)}),n)}},function(e,t,n){var a=n(61);e.exports=function(e,t){var n=e[t];if(void 0!==n)return a(n)?n.call(e):n}},function(e,t,n){var a=n(9);e.exports=function(e){return a(e,"Function")}},function(e,t,n){var a=n(24);e.exports=function(e,t,n){var i=/^(.+)\.(.+)$/.exec(t);i?a(e,i[1])[i[2]]=n:e[t]=n}},function(e,t,n){var a=n(21);e.exports=function(e,t){if(a(e,t)){for(var n=t.split("."),i=n.pop();t=n.shift();)e=e[t];return delete e[i]}return!0}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=n(65);t.DefaultSampleRate=16e3,t.ErrNotInitialized=new Error("Microphone is not initialized"),t.ErrAlreadyInitialized=new Error("Microphone is already initialized"),t.ErrNoBrowserSupport=new Error("Current browser does not support audio API"),t.ErrNoAudioConsent=new Error("Microphone consent is no given");t.Microphone=class{constructor(e){this.onAudioCb=()=>{},this.sampleRate=e}onAudio(e){this.onAudioCb=e}initialize(e){var n;return void 0!==this.audioTrack?e(t.ErrAlreadyInitialized):void 0===(null===(n=window.navigator)||void 0===n?void 0:n.mediaDevices)?e(t.ErrNoBrowserSupport):void window.navigator.mediaDevices.getUserMedia({audio:!0,video:!1}).then(t=>{this.mediaStream=t,this.audioTrack=this.mediaStream.getAudioTracks()[0],this.audioTrack.enabled=!1,e()}).catch(()=>{e(t.ErrNoAudioConsent)})}close(e){if(void 0===this.mediaStream)return e(t.ErrNotInitialized);if(this.mute(),this.mediaStream.getTracks().forEach(e=>e.stop()),void 0!==this.audioProcessor&&this.audioProcessor.disconnect(),void 0===this.audioContext)return e();const n=t=>(this.mediaStream=void 0,this.audioTrack=void 0,this.audioContext=void 0,this.downsampler=void 0,this.audioProcessor=void 0,void 0!==t?e(t):e());this.audioContext.close().then(n).catch(n)}mute(){void 0!==this.audioTrack&&(this.audioTrack.enabled=!1)}unmute(){void 0!==this.audioTrack&&(this.audioTrack.enabled=!0,void 0===this.audioContext&&this.initializeAudioContext())}initializeAudioContext(){if(void 0===this.mediaStream)throw Error("Microphone media stream is not initialized");if(void 0!==this.audioContext)throw Error("Microphone audio context is already initialized");if(void 0!==window.AudioContext)this.audioContext=new window.AudioContext;else{if(void 0===window.webkitAudioContext)throw Error("Microphone functionality is not supported in your browser");this.audioContext=new window.webkitAudioContext}this.downsampler=a.generateDownsampler(this.audioContext.sampleRate,this.sampleRate),this.audioProcessor=this.audioContext.createScriptProcessor(4096,1,1),this.audioContext.createMediaStreamSource(this.mediaStream).connect(this.audioProcessor),this.audioProcessor.connect(this.audioContext.destination),this.audioProcessor.onaudioprocess=e=>{if(void 0===this.audioTrack)throw Error("Microphone audio track is not initialized");if(void 0===this.downsampler)throw Error("Microphone downsampler is not initialized");if(!this.audioTrack.enabled)return;const t=a.float32ToInt16(this.downsampler(e.inputBuffer.getChannelData(0)));this.onAudioCb(t)}}}},function(e,t,n){"use strict";function a(e){if(0===e)return 1;const t=Math.PI*e;return Math.sin(t)/t}Object.defineProperty(t,"__esModule",{value:!0}),t.generateDownsampler=function(e,t){const n=e/t,i=function(e,t,n){if(n%2==0)throw Error("Filter length must be odd");const i=new Array(n);let r=0;for(let o=0;o<n;o++){const s=a(2*t/e*(o-(n-1)/2));r+=s,i[o]=s}for(let e=0;e<n;e++)i[e]=i[e]/r;return i}(e,t/2,23);let r=new Float32Array(0);return e=>{const t=new Float32Array(r.length+e.length);t.set(r,0),t.set(e,r.length);const a=Math.ceil((t.length-i.length)/n),o=new Float32Array(a);for(let e=0;e<a;e++){const a=Math.round(n*e);for(let n=0;n<i.length;n++)o[e]+=t[a+n]*i[n]}const s=Math.round(n*a);return r=s<t.length?t.slice(s):new Float32Array(0),o}},t.float32ToInt16=function(e){let t=e.length;const n=new Int16Array(t);for(;t-- >0;)n[t]=e[t]*(e[t]<0?32768:32767);return n.buffer}},function(e,t,n){"use strict";function a(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}Object.defineProperty(t,"__esModule",{value:!0}),a(n(67)),a(n(26))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=n(26);t.Websocket=class{constructor(e,t,n,i,r){this.startCbs=[],this.stopCbs=[],this.onResponseCb=()=>{},this.onCloseCb=()=>{},this.onWebsocketMessage=e=>{let t;try{t=JSON.parse(e.data)}catch(e){return void console.error("[SpeechlyClient] Error parsing response from the server:",e)}switch(t.type){case a.WebsocketResponseType.Started:this.startCbs.forEach(e=>{try{e(void 0,t.audio_context)}catch(e){console.error('[SpeechlyClient] Error while invoking "onStart" callback:',e)}}),this.startCbs.length=0;break;case a.WebsocketResponseType.Stopped:this.stopCbs.forEach(e=>{try{e(void 0,t.audio_context)}catch(e){console.error('[SpeechlyClient] Error while invoking "onStop" callback:',e)}}),this.stopCbs.length=0;break;default:this.onResponseCb(t)}},this.onWebsocketClose=e=>{this.onCloseCb(Error(`Websocket was closed: ${e.reason}`))},this.onWebsocketError=e=>{this.close(1e3,"Client disconnecting due to an error"),this.onCloseCb(Error("Websocket was closed because of error"))},this.url=function(e,t,n,a){const i=new URLSearchParams;return i.set("deviceId",t),i.set("languageCode",n),i.set("sampleRate",a.toString()),`${e}?${i.toString()}`}(e,i,n,r),this.appId=t}onResponse(e){this.onResponseCb=e}onClose(e){this.onCloseCb=e}initialize(e){if(void 0!==this.websocket)return e(Error("Cannot initialize an already initialized websocket client"));!function(e,t,n){const a=new WebSocket(e,t),i=()=>{a.removeEventListener("close",i),a.removeEventListener("error",i),a.removeEventListener("open",r),n(Error("Connection failed"))},r=()=>{a.removeEventListener("close",i),a.removeEventListener("error",i),a.removeEventListener("open",r),n(void 0,a)};a.addEventListener("close",i),a.addEventListener("error",i),a.addEventListener("open",r)}(this.url,this.appId,(t,n)=>void 0!==t?e(t):(this.websocket=n,this.websocket.addEventListener("message",this.onWebsocketMessage),this.websocket.addEventListener("error",this.onWebsocketError),this.websocket.addEventListener("close",this.onWebsocketClose),e()))}close(e,t){if(void 0===this.websocket)return Error("Websocket is not open");this.websocket.removeEventListener("message",this.onWebsocketMessage),this.websocket.removeEventListener("error",this.onWebsocketError),this.websocket.removeEventListener("close",this.onWebsocketClose),this.websocket.close(e,t),this.websocket=void 0}start(e){if(!this.isOpen())return e(Error("Websocket is not ready"));this.startCbs.push(e),this.websocket.send(i)}stop(e){if(!this.isOpen())return e(new Error("websocket is not ready"));this.stopCbs.push(e),this.websocket.send(r)}send(e){if(!this.isOpen())return Error("Cannot send data through inactive websocket");this.websocket.send(e)}isOpen(){return void 0!==this.websocket&&this.websocket.readyState===this.websocket.OPEN}};const i=JSON.stringify({event:"start"}),r=JSON.stringify({event:"stop"})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.SegmentState=class{constructor(e,t){this.isFinalized=!1,this.words=[],this.entities=new Map,this.intent={intent:"",isFinal:!1},this.contextId=e,this.id=t}toSegment(){let e=0;const t=new Array(this.entities.size);for(const n of this.entities.values())t[e]=n,e++;return{id:this.id,contextId:this.contextId,isFinal:this.isFinalized,words:this.words,entities:t,intent:this.intent}}updateTranscript(e){return e.forEach(e=>{this.words[e.index]=e}),this}updateEntities(e){return e.forEach(e=>this.entities.set(function(e){return`${e.startPosition.toString()}:${e.endPosition.toString()}`}(e),e)),this}updateIntent(e){return this.intent.isFinal||(this.intent=e),this}finalize(){return this.entities.forEach((e,t)=>{e.isFinal||this.entities.delete(t)}),this.words=this.words.filter(e=>e.isFinal),this.intent.isFinal||(this.intent.intent="",this.intent.isFinal=!0),this.isFinalized=!0,this}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseTentativeTranscript=function(e){return e.words.map(({word:e,index:t,start_timestamp:n,end_timestamp:a})=>({value:e,index:t,startTimestamp:n,endTimestamp:a,isFinal:!1}))},t.parseTranscript=function(e){return{value:e.word,index:e.index,startTimestamp:e.start_timestamp,endTimestamp:e.end_timestamp,isFinal:!0}},t.parseTentativeEntities=function(e){return e.entities.map(({entity:e,value:t,start_position:n,end_position:a})=>({type:e,value:t,startPosition:n,endPosition:a,isFinal:!1}))},t.parseEntity=function(e){return{type:e.entity,value:e.value,startPosition:e.start_position,endPosition:e.end_position,isFinal:!0}},t.parseIntent=function(e,t){return{intent:e.intent,isFinal:t}}},function(e,t,n){"use strict";n.r(t);var a={aa:{name:"Afar",nativeName:"Afaraf"},ab:{name:"Abkhaz",nativeName:"аҧсуа бызшәа"},ae:{name:"Avestan",nativeName:"avesta"},af:{name:"Afrikaans",nativeName:"Afrikaans"},ak:{name:"Akan",nativeName:"Akan"},am:{name:"Amharic",nativeName:"አማርኛ"},an:{name:"Aragonese",nativeName:"aragonés"},ar:{name:"Arabic",nativeName:"اللغة العربية"},as:{name:"Assamese",nativeName:"অসমীয়া"},av:{name:"Avaric",nativeName:"авар мацӀ"},ay:{name:"Aymara",nativeName:"aymar aru"},az:{name:"Azerbaijani",nativeName:"azərbaycan dili"},ba:{name:"Bashkir",nativeName:"башҡорт теле"},be:{name:"Belarusian",nativeName:"беларуская мова"},bg:{name:"Bulgarian",nativeName:"български език"},bh:{name:"Bihari",nativeName:"भोजपुरी"},bi:{name:"Bislama",nativeName:"Bislama"},bm:{name:"Bambara",nativeName:"bamanankan"},bn:{name:"Bengali",nativeName:"বাংলা"},bo:{name:"Tibetan Standard",nativeName:"བོད་ཡིག"},br:{name:"Breton",nativeName:"brezhoneg"},bs:{name:"Bosnian",nativeName:"bosanski jezik"},ca:{name:"Catalan",nativeName:"català"},ce:{name:"Chechen",nativeName:"нохчийн мотт"},ch:{name:"Chamorro",nativeName:"Chamoru"},co:{name:"Corsican",nativeName:"corsu"},cr:{name:"Cree",nativeName:"ᓀᐦᐃᔭᐍᐏᐣ"},cs:{name:"Czech",nativeName:"čeština"},cu:{name:"Old Church Slavonic",nativeName:"ѩзыкъ словѣньскъ"},cv:{name:"Chuvash",nativeName:"чӑваш чӗлхи"},cy:{name:"Welsh",nativeName:"Cymraeg"},da:{name:"Danish",nativeName:"dansk"},de:{name:"German",nativeName:"Deutsch"},dv:{name:"Divehi",nativeName:"Dhivehi"},dz:{name:"Dzongkha",nativeName:"རྫོང་ཁ"},ee:{name:"Ewe",nativeName:"Eʋegbe"},el:{name:"Greek",nativeName:"Ελληνικά"},en:{name:"English",nativeName:"English"},eo:{name:"Esperanto",nativeName:"Esperanto"},es:{name:"Spanish",nativeName:"Español"},et:{name:"Estonian",nativeName:"eesti"},eu:{name:"Basque",nativeName:"euskara"},fa:{name:"Persian",nativeName:"فارسی"},ff:{name:"Fula",nativeName:"Fulfulde"},fi:{name:"Finnish",nativeName:"suomi"},fj:{name:"Fijian",nativeName:"Vakaviti"},fo:{name:"Faroese",nativeName:"føroyskt"},fr:{name:"French",nativeName:"Français"},fy:{name:"Western Frisian",nativeName:"Frysk"},ga:{name:"Irish",nativeName:"Gaeilge"},gd:{name:"Scottish Gaelic",nativeName:"Gàidhlig"},gl:{name:"Galician",nativeName:"galego"},gn:{name:"Guaraní",nativeName:"Avañe'ẽ"},gu:{name:"Gujarati",nativeName:"ગુજરાતી"},gv:{name:"Manx",nativeName:"Gaelg"},ha:{name:"Hausa",nativeName:"هَوُسَ"},he:{name:"Hebrew",nativeName:"עברית"},hi:{name:"Hindi",nativeName:"हिन्दी"},ho:{name:"Hiri Motu",nativeName:"Hiri Motu"},hr:{name:"Croatian",nativeName:"hrvatski jezik"},ht:{name:"Haitian",nativeName:"Kreyòl ayisyen"},hu:{name:"Hungarian",nativeName:"magyar"},hy:{name:"Armenian",nativeName:"Հայերեն"},hz:{name:"Herero",nativeName:"Otjiherero"},ia:{name:"Interlingua",nativeName:"Interlingua"},id:{name:"Indonesian",nativeName:"Indonesian"},ie:{name:"Interlingue",nativeName:"Interlingue"},ig:{name:"Igbo",nativeName:"Asụsụ Igbo"},ii:{name:"Nuosu",nativeName:"ꆈꌠ꒿ Nuosuhxop"},ik:{name:"Inupiaq",nativeName:"Iñupiaq"},io:{name:"Ido",nativeName:"Ido"},is:{name:"Icelandic",nativeName:"Íslenska"},it:{name:"Italian",nativeName:"Italiano"},iu:{name:"Inuktitut",nativeName:"ᐃᓄᒃᑎᑐᑦ"},ja:{name:"Japanese",nativeName:"日本語"},jv:{name:"Javanese",nativeName:"basa Jawa"},ka:{name:"Georgian",nativeName:"ქართული"},kg:{name:"Kongo",nativeName:"Kikongo"},ki:{name:"Kikuyu",nativeName:"Gĩkũyũ"},kj:{name:"Kwanyama",nativeName:"Kuanyama"},kk:{name:"Kazakh",nativeName:"қазақ тілі"},kl:{name:"Kalaallisut",nativeName:"kalaallisut"},km:{name:"Khmer",nativeName:"ខេមរភាសា"},kn:{name:"Kannada",nativeName:"ಕನ್ನಡ"},ko:{name:"Korean",nativeName:"한국어"},kr:{name:"Kanuri",nativeName:"Kanuri"},ks:{name:"Kashmiri",nativeName:"कश्मीरी"},ku:{name:"Kurdish",nativeName:"Kurdî"},kv:{name:"Komi",nativeName:"коми кыв"},kw:{name:"Cornish",nativeName:"Kernewek"},ky:{name:"Kyrgyz",nativeName:"Кыргызча"},la:{name:"Latin",nativeName:"latine"},lb:{name:"Luxembourgish",nativeName:"Lëtzebuergesch"},lg:{name:"Ganda",nativeName:"Luganda"},li:{name:"Limburgish",nativeName:"Limburgs"},ln:{name:"Lingala",nativeName:"Lingála"},lo:{name:"Lao",nativeName:"ພາສາ"},lt:{name:"Lithuanian",nativeName:"lietuvių kalba"},lu:{name:"Luba-Katanga",nativeName:"Tshiluba"},lv:{name:"Latvian",nativeName:"latviešu valoda"},mg:{name:"Malagasy",nativeName:"fiteny malagasy"},mh:{name:"Marshallese",nativeName:"Kajin M̧ajeļ"},mi:{name:"Māori",nativeName:"te reo Māori"},mk:{name:"Macedonian",nativeName:"македонски јазик"},ml:{name:"Malayalam",nativeName:"മലയാളം"},mn:{name:"Mongolian",nativeName:"Монгол хэл"},mr:{name:"Marathi",nativeName:"मराठी"},ms:{name:"Malay",nativeName:"هاس ملايو"},mt:{name:"Maltese",nativeName:"Malti"},my:{name:"Burmese",nativeName:"ဗမာစာ"},na:{name:"Nauru",nativeName:"Ekakairũ Naoero"},nb:{name:"Norwegian Bokmål",nativeName:"Norsk bokmål"},nd:{name:"Northern Ndebele",nativeName:"isiNdebele"},ne:{name:"Nepali",nativeName:"नेपाली"},ng:{name:"Ndonga",nativeName:"Owambo"},nl:{name:"Dutch",nativeName:"Nederlands"},nn:{name:"Norwegian Nynorsk",nativeName:"Norsk nynorsk"},no:{name:"Norwegian",nativeName:"Norsk"},nr:{name:"Southern Ndebele",nativeName:"isiNdebele"},nv:{name:"Navajo",nativeName:"Diné bizaad"},ny:{name:"Chichewa",nativeName:"chiCheŵa"},oc:{name:"Occitan",nativeName:"occitan"},oj:{name:"Ojibwe",nativeName:"ᐊᓂᔑᓈᐯᒧᐎᓐ"},om:{name:"Oromo",nativeName:"Afaan Oromoo"},or:{name:"Oriya",nativeName:"ଓଡ଼ିଆ"},os:{name:"Ossetian",nativeName:"ирон æвзаг"},pa:{name:"Panjabi",nativeName:"ਪੰਜਾਬੀ"},pi:{name:"Pāli",nativeName:"पाऴि"},pl:{name:"Polish",nativeName:"język polski"},ps:{name:"Pashto",nativeName:"پښتو"},pt:{name:"Portuguese",nativeName:"Português"},qu:{name:"Quechua",nativeName:"Runa Simi"},rm:{name:"Romansh",nativeName:"rumantsch grischun"},rn:{name:"Kirundi",nativeName:"Ikirundi"},ro:{name:"Romanian",nativeName:"Română"},ru:{name:"Russian",nativeName:"Русский"},rw:{name:"Kinyarwanda",nativeName:"Ikinyarwanda"},sa:{name:"Sanskrit",nativeName:"संस्कृतम्"},sc:{name:"Sardinian",nativeName:"sardu"},sd:{name:"Sindhi",nativeName:"सिन्धी"},se:{name:"Northern Sami",nativeName:"Davvisámegiella"},sg:{name:"Sango",nativeName:"yângâ tî sängö"},si:{name:"Sinhala",nativeName:"සිංහල"},sk:{name:"Slovak",nativeName:"slovenčina"},sl:{name:"Slovene",nativeName:"slovenski jezik"},sm:{name:"Samoan",nativeName:"gagana fa'a Samoa"},sn:{name:"Shona",nativeName:"chiShona"},so:{name:"Somali",nativeName:"Soomaaliga"},sq:{name:"Albanian",nativeName:"Shqip"},sr:{name:"Serbian",nativeName:"српски језик"},ss:{name:"Swati",nativeName:"SiSwati"},st:{name:"Southern Sotho",nativeName:"Sesotho"},su:{name:"Sundanese",nativeName:"Basa Sunda"},sv:{name:"Swedish",nativeName:"svenska"},sw:{name:"Swahili",nativeName:"Kiswahili"},ta:{name:"Tamil",nativeName:"தமிழ்"},te:{name:"Telugu",nativeName:"తెలుగు"},tg:{name:"Tajik",nativeName:"тоҷикӣ"},th:{name:"Thai",nativeName:"ไทย"},ti:{name:"Tigrinya",nativeName:"ትግርኛ"},tk:{name:"Turkmen",nativeName:"Türkmen"},tl:{name:"Tagalog",nativeName:"Wikang Tagalog"},tn:{name:"Tswana",nativeName:"Setswana"},to:{name:"Tonga",nativeName:"faka Tonga"},tr:{name:"Turkish",nativeName:"Türkçe"},ts:{name:"Tsonga",nativeName:"Xitsonga"},tt:{name:"Tatar",nativeName:"татар теле"},tw:{name:"Twi",nativeName:"Twi"},ty:{name:"Tahitian",nativeName:"Reo Tahiti"},ug:{name:"Uyghur",nativeName:"ئۇيغۇرچە"},uk:{name:"Ukrainian",nativeName:"Українська"},ur:{name:"Urdu",nativeName:"اردو"},uz:{name:"Uzbek",nativeName:"Ўзбек"},ve:{name:"Venda",nativeName:"Tshivenḓa"},vi:{name:"Vietnamese",nativeName:"Tiếng Việt"},vo:{name:"Volapük",nativeName:"Volapük"},wa:{name:"Walloon",nativeName:"walon"},wo:{name:"Wolof",nativeName:"Wollof"},xh:{name:"Xhosa",nativeName:"isiXhosa"},yi:{name:"Yiddish",nativeName:"ייִדיש"},yo:{name:"Yoruba",nativeName:"Yorùbá"},za:{name:"Zhuang",nativeName:"Saɯ cueŋƅ"},zh:{name:"Chinese",nativeName:"中文"},zu:{name:"Zulu",nativeName:"isiZulu"}};class i{static getLanguages(e=[]){return e.map(e=>({code:e,name:i.getName(e),nativeName:i.getNativeName(e)}))}static getName(e){return i.validate(e)?a[e].name:""}static getAllNames(){return Object.values(a).map(e=>e.name)}static getNativeName(e){return i.validate(e)?a[e].nativeName:""}static getAllNativeNames(){return Object.values(a).map(e=>e.nativeName)}static getCode(e){return Object.keys(a).find(t=>{const n=a[t];return n.name.toLowerCase()===e.toLowerCase()||n.nativeName.toLowerCase()===e.toLowerCase()})||""}static getAllCodes(){return Object.keys(a)}static validate(e){return a.hasOwnProperty(e)}}var r={aa:"阿法尔语",ab:"阿布哈兹语",ae:"阿维斯陀语",af:"南非荷兰语",ak:"阿坎语",am:"阿姆哈拉语",an:"阿拉贡语",ar:"阿拉伯语",as:"阿萨姆语",av:"阿瓦尔语",ay:"艾马拉语",az:"阿塞拜疆语",ba:"巴什基尔语",be:"白俄罗斯语",bg:"保加利亚语",bh:"比哈尔语",bi:"比斯拉马语",bm:"班巴拉语",bn:"孟加拉语",bo:"藏语",br:"布列塔尼语",bs:"波斯尼亚语",ca:"加泰罗尼亚语",ce:"车臣语",ch:"查莫洛语",co:"科西嘉语",cr:"克里语",cs:"捷克语",cu:"古教会斯拉夫语",cv:"楚瓦什语",cy:"威尔士语",da:"丹麦语",de:"德语",dv:"迪维希语",dz:"不丹语",ee:"埃维语",el:"希腊语",en:"英语",eo:"世界语",es:"西班牙语",et:"爱沙尼亚语",eu:"巴斯克语",fa:"波斯语",ff:"富拉语",fi:"芬兰语",fj:"斐济语",fo:"法罗语",fr:"法语",fy:"西弗里西亚语",ga:"爱尔兰语",gd:"苏格兰盖尔语",gl:"加利西亚语",gn:"瓜拉尼语",gu:"古吉拉特语",gv:"马恩岛语",ha:"豪萨语",he:"希伯来语",hi:"印地语",ho:"莫图语",hr:"克罗地亚语",ht:"海地文",hu:"匈牙利语",hy:"亚美尼亚语",hz:"赫勒娄语",ia:"国际语",id:"印尼语",ie:"国际语",ig:"伊博语",ii:"诺苏语",ik:"依奴皮维克文",io:"伊多文",is:"冰岛语",it:"意大利语",iu:"因纽特语",ja:"日语",jv:"爪哇语",ka:"格鲁吉亚语",kg:"刚果语",ki:"基库尤语",kj:"宽亚马语",kk:"哈萨克语",kl:"格陵兰语",km:"高棉语",kn:"卡纳达语",ko:"韩语",kr:"卡努里语",ks:"克什米尔语",ku:"库尔德语",kv:"科米语",kw:"科尼什语",ky:"吉尔吉斯语",la:"拉丁语",lb:"卢森堡语",lg:"甘达语",li:"林堡语",ln:"林加拉语",lo:"老挝语",lt:"立陶宛语",lu:"卢巴加丹加语",lv:"拉脱维亚语",mg:"马尔加什语",mh:"马绍尔语",mi:"毛利语",mk:"马其顿语",ml:"马拉雅拉姆语",mn:"蒙古文",mr:"马拉地语",ms:"马来语",mt:"马耳他语",my:"缅甸语",na:"瑙鲁语",nb:"挪威博克马尔语",nd:"北恩德贝勒语",ne:"尼泊尔语",ng:"尼日尔刚果语",nl:"荷兰语",nn:"挪威尼诺斯克语",no:"挪威语",nr:"南恩德贝勒语",nv:"纳瓦霍语",ny:"齐切瓦语",oc:"奥克西唐语",oj:"欧及布威语",om:"奥罗莫语",or:"奥里亚语",os:"奥塞梯语",pa:"旁遮普语",pi:"巴利语",pl:"波兰语",ps:"普什图语",pt:"葡萄牙语",qu:"克丘亚语",rm:"罗曼斯语",rn:"基隆迪语",ro:"罗马尼亚语",ru:"俄语",rw:"卢旺达语",sa:"梵文",sc:"撒丁岛语",sd:"信德语",se:"北萨米文",sg:"桑戈语",si:"僧伽罗语",sk:"斯洛伐克语",sl:"斯洛文尼亚语",sm:"萨摩亚语",sn:"绍纳语",so:"索马里语",sq:"阿尔巴尼亚语",sr:"塞尔维亚语",ss:"斯瓦蒂语",st:"南索托语",su:"巽他语",sv:"瑞典语",sw:"斯瓦希里语",ta:"泰米尔语",te:"泰卢固语",tg:"塔吉克语",th:"泰语",ti:"提格雷语",tk:"土库曼语",tl:"菲律宾语",tn:"茨瓦纳语",to:"汤加语",tr:"土耳其语",ts:"特松加语",tt:"塔塔尔语",tw:"契维语",ty:"塔希提语",ug:"维吾尔语",uk:"乌克兰语",ur:"乌尔都语",uz:"乌兹别克语",ve:"文达语",vi:"越南语",vo:"沃拉普克语",wa:"华隆语",wo:"沃洛夫语",xh:"科萨语",yi:"意第绪语",yo:"约鲁巴语",za:"壮语",zh:"中文",zu:"祖鲁语"};class o extends i{static getLanguages(e){return super.getLanguages(e).map(e=>(Object.assign(e,{zhName:o.getZhName(e.code)}),e))}static getZhName(e){return super.validate(e)?r[e]:""}static getAllZhNames(){return Object.values(r)}}var s=n(12),u=n.n(s);n.d(t,"default",(function(){return l}));const c=/^([a-z]{2})-([A-Z]{2})$/;class l{static getLanguageCode(e){var t=e.match(c);return!t||t.length<1?"":t[1]}static getLanguageName(e){var t=l.getLanguageCode(e);return o.getName(t)}static getLanguageNativeName(e){var t=l.getLanguageCode(e);return o.getNativeName(t)}static getLanguageZhName(e){var t=l.getLanguageCode(e);return o.getZhName(t)}static validateLanguageCode(e){var t=l.getLanguageCode(e);return o.validate(t)}static getLanguages(e){for(var t=[],n=0;n<e.length;n++)t.push({code:e[n],name:l.getLanguageName(e[n]),nativeName:l.getLanguageNativeName(e[n]),zhName:l.getLanguageZhName(e[n])});return t}static getCountryCode(e){var t=e.match(c);return!t||t.length<2?"":t[2]}static getCountryName(e){var t=l.getCountryCode(e);return u.a.getCountry(t)}static validateCountryCode(e){return e=l.getCountryCode(e),-1!==u.a.getCodes().indexOf(e)}static validate(e){var t=e.match(c);return!!(t&&3===t.length&&l.validateLanguageCode(e)&&l.validateCountryCode(e))}}}])})); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.speechly=t():e.speechly=t()}(window,(function(){return function(e){var t={};function n(a){if(t[a])return t[a].exports;var i=t[a]={i:a,l:!1,exports:{}};return e[a].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,a){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(a,i,function(t){return e[t]}.bind(null,i));return a},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=29)}([function(e,t,n){var a=n(2),i=n(6);e.exports=function(e,t,n){i(e,(function(i,o){if(a(e,o))return t.call(n,e[o],o,e)}))}},function(e,t,n){var a=n(36),i=n(15),o=n(16);e.exports=function(e,t){if(null==e)return a;switch(typeof e){case"function":return void 0!==t?function(n,a,i){return e.call(t,n,a,i)}:e;case"object":return function(t){return o(t,e)};case"string":case"number":return i(e)}}},function(e,t){e.exports=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},function(e,t){e.exports=function(e,t,n){var a=e.length;t=null==t?0:t<0?Math.max(a+t,0):Math.min(t,a),n=null==n?a:n<0?Math.max(a+n,0):Math.min(n,a);for(var i=[];t<n;)i.push(e[t++]);return i}},function(e,t){e.exports=function(e){return!!e&&"object"==typeof e&&e.constructor===Object}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e[e.Failed=0]="Failed",e[e.NoBrowserSupport=1]="NoBrowserSupport",e[e.NoAudioConsent=2]="NoAudioConsent",e[e.Disconnected=3]="Disconnected",e[e.Disconnecting=4]="Disconnecting",e[e.Connecting=5]="Connecting",e[e.Connected=6]="Connected",e[e.Starting=7]="Starting",e[e.Stopping=8]="Stopping",e[e.Recording=9]="Recording"}(t.ClientState||(t.ClientState={}))},function(e,t,n){var a,i,o=n(2);function r(e,t,n,a){return e.call(a,t[n],n,t)}e.exports=function(e,t,n){var s,u=0;for(s in null==a&&function(){for(var e in i=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],a=!0,{toString:null})a=!1}(),e)if(!1===r(t,e,s,n))break;if(a)for(var c=e.constructor,l=!!c&&e===c.prototype;(s=i[u++])&&("constructor"===s&&(l||!o(e,s))||e[s]===Object.prototype[s]||!1!==r(t,e,s,n)););}},function(e,t){e.exports=function(e,t,n){if(null!=e)for(var a=-1,i=e.length;++a<i&&!1!==t.call(n,e[a],a,e););}},function(e,t,n){var a=n(0),i=n(1);e.exports=function(e,t,n){t=i(t,n);var o=!1;return a(e,(function(n,a){if(t(n,a,e))return o=!0,!1})),o}},function(e,t,n){var a=n(10);e.exports=function(e,t){return a(e)===t}},function(e,t){var n=/^\[object (.*)\]$/,a=Object.prototype.toString;e.exports=function(e){return null===e?"Null":void 0===e?"Undefined":n.exec(a.call(e))[1]}},function(e,t,n){var a=n(0);e.exports=function(e){var t=[];return a(e,(function(e,n){t.push(e)})),t}},function(e,t,n){(function(){var t,a,i;a=n(32),t=function(){function e(){}return e.prototype.getCountry=function(t){return e.prototype.countries[t]},e.prototype.getCode=function(t){var n,i;return i=null,null!=t&&-1!==(n=a.values(e.prototype.countries).indexOf(t))&&(i=Object.keys(e.prototype.countries)[n]),i},e.prototype.getCountries=function(){return a.values(e.prototype.countries)},e.prototype.getCodes=function(){return Object.keys(e.prototype.countries)},e.prototype.getData=function(){return e.prototype.countries},e.prototype.countries={AF:"Afghanistan",AX:"Åland Islands",AL:"Albania",DZ:"Algeria",AS:"American Samoa",AD:"Andorra",AO:"Angola",AI:"Anguilla",AQ:"Antarctica",AG:"Antigua and Barbuda",AR:"Argentina",AM:"Armenia",AW:"Aruba",AU:"Australia",AT:"Austria",AZ:"Azerbaijan",BS:"Bahamas",BH:"Bahrain",BD:"Bangladesh",BB:"Barbados",BY:"Belarus",BE:"Belgium",BZ:"Belize",BJ:"Benin",BM:"Bermuda",BT:"Bhutan",BO:"Bolivia, Plurinational State of",BQ:"Bonaire, Sint Eustatius and Saba",BA:"Bosnia and Herzegovina",BW:"Botswana",BV:"Bouvet Island",BR:"Brazil",IO:"British Indian Ocean Territory",BN:"Brunei Darussalam",BG:"Bulgaria",BF:"Burkina Faso",BI:"Burundi",KH:"Cambodia",CM:"Cameroon",CA:"Canada",CV:"Cape Verde",KY:"Cayman Islands",CF:"Central African Republic",TD:"Chad",CL:"Chile",CN:"China",CX:"Christmas Island",CC:"Cocos (Keeling) Islands",CO:"Colombia",KM:"Comoros",CG:"Congo",CD:"Congo, the Democratic Republic of the",CK:"Cook Islands",CR:"Costa Rica",CI:"Côte d'Ivoire",HR:"Croatia",CU:"Cuba",CW:"Curaçao",CY:"Cyprus",CZ:"Czech Republic",DK:"Denmark",DJ:"Djibouti",DM:"Dominica",DO:"Dominican Republic",EC:"Ecuador",EG:"Egypt",SV:"El Salvador",GQ:"Equatorial Guinea",ER:"Eritrea",EE:"Estonia",ET:"Ethiopia",FK:"Falkland Islands (Malvinas)",FO:"Faroe Islands",FJ:"Fiji",FI:"Finland",FR:"France",GF:"French Guiana",PF:"French Polynesia",TF:"French Southern Territories",GA:"Gabon",GM:"Gambia",GE:"Georgia",DE:"Germany",GH:"Ghana",GI:"Gibraltar",GR:"Greece",GL:"Greenland",GD:"Grenada",GP:"Guadeloupe",GU:"Guam",GT:"Guatemala",GG:"Guernsey",GN:"Guinea",GW:"Guinea-Bissau",GY:"Guyana",HT:"Haiti",HM:"Heard Island and McDonald Mcdonald Islands",VA:"Holy See (Vatican City State)",HN:"Honduras",HK:"Hong Kong",HU:"Hungary",IS:"Iceland",IN:"India",ID:"Indonesia",IR:"Iran, Islamic Republic of",IQ:"Iraq",IE:"Ireland",IM:"Isle of Man",IL:"Israel",IT:"Italy",JM:"Jamaica",JP:"Japan",JE:"Jersey",JO:"Jordan",KZ:"Kazakhstan",KE:"Kenya",KI:"Kiribati",KP:"Korea, Democratic People's Republic of",KR:"Korea, Republic of",KW:"Kuwait",KG:"Kyrgyzstan",LA:"Lao People's Democratic Republic",LV:"Latvia",LB:"Lebanon",LS:"Lesotho",LR:"Liberia",LY:"Libya",LI:"Liechtenstein",LT:"Lithuania",LU:"Luxembourg",MO:"Macao",MK:"Macedonia, the Former Yugoslav Republic of",MG:"Madagascar",MW:"Malawi",MY:"Malaysia",MV:"Maldives",ML:"Mali",MT:"Malta",MH:"Marshall Islands",MQ:"Martinique",MR:"Mauritania",MU:"Mauritius",YT:"Mayotte",MX:"Mexico",FM:"Micronesia, Federated States of",MD:"Moldova, Republic of",MC:"Monaco",MN:"Mongolia",ME:"Montenegro",MS:"Montserrat",MA:"Morocco",MZ:"Mozambique",MM:"Myanmar",NA:"Namibia",NR:"Nauru",NP:"Nepal",NL:"Netherlands",NC:"New Caledonia",NZ:"New Zealand",NI:"Nicaragua",NE:"Niger",NG:"Nigeria",NU:"Niue",NF:"Norfolk Island",MP:"Northern Mariana Islands",NO:"Norway",OM:"Oman",PK:"Pakistan",PW:"Palau",PS:"Palestine, State of",PA:"Panama",PG:"Papua New Guinea",PY:"Paraguay",PE:"Peru",PH:"Philippines",PN:"Pitcairn",PL:"Poland",PT:"Portugal",PR:"Puerto Rico",QA:"Qatar",RE:"Réunion",RO:"Romania",RU:"Russian Federation",RW:"Rwanda",BL:"Saint Barthélemy",SH:"Saint Helena, Ascension and Tristan da Cunha",KN:"Saint Kitts and Nevis",LC:"Saint Lucia",MF:"Saint Martin (French part)",PM:"Saint Pierre and Miquelon",VC:"Saint Vincent and the Grenadines",WS:"Samoa",SM:"San Marino",ST:"Sao Tome and Principe",SA:"Saudi Arabia",SN:"Senegal",RS:"Serbia",SC:"Seychelles",SL:"Sierra Leone",SG:"Singapore",SX:"Sint Maarten (Dutch part)",SK:"Slovakia",SI:"Slovenia",SB:"Solomon Islands",SO:"Somalia",ZA:"South Africa",GS:"South Georgia and the South Sandwich Islands",SS:"South Sudan",ES:"Spain",LK:"Sri Lanka",SD:"Sudan",SR:"Suriname",SJ:"Svalbard and Jan Mayen",SZ:"Swaziland",SE:"Sweden",CH:"Switzerland",SY:"Syrian Arab Republic",TW:"Taiwan, Province of China",TJ:"Tajikistan",TZ:"Tanzania, United Republic of",TH:"Thailand",TL:"Timor-Leste",TG:"Togo",TK:"Tokelau",TO:"Tonga",TT:"Trinidad and Tobago",TN:"Tunisia",TR:"Turkey",TM:"Turkmenistan",TC:"Turks and Caicos Islands",TV:"Tuvalu",UG:"Uganda",UA:"Ukraine",AE:"United Arab Emirates",GB:"United Kingdom",US:"United States",UM:"United States Minor Outlying Islands",UY:"Uruguay",UZ:"Uzbekistan",VU:"Vanuatu",VE:"Venezuela, Bolivarian Republic of",VN:"Viet Nam",VG:"Virgin Islands, British",VI:"Virgin Islands, U.S.",WF:"Wallis and Futuna",EH:"Western Sahara",YE:"Yemen",ZM:"Zambia",ZW:"Zimbabwe"},e}(),i=null,e.exports=null!=i?i:i=new t}).call(this)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=n(5);t.stateToString=function(e){var t;return null!=(t=o.get(e))?t:i};const i="Unknown",o=new Map([[a.ClientState.Failed,"Failed"],[a.ClientState.NoBrowserSupport,"NoBrowserSupport"],[a.ClientState.NoAudioConsent,"NoAudioConsent"],[a.ClientState.Disconnecting,"Disconnecting"],[a.ClientState.Disconnected,"Disconnected"],[a.ClientState.Connecting,"Connecting"],[a.ClientState.Connected,"Connected"],[a.ClientState.Starting,"Starting"],[a.ClientState.Stopping,"Stopping"],[a.ClientState.Recording,"Recording"]])},function(e,t,n){var a=n(6);e.exports=function(e){var t=[];return a(e,(function(e,n){"function"==typeof e&&t.push(n)})),t.sort()}},function(e,t){e.exports=function(e){return function(t){return t[e]}}},function(e,t,n){var a=n(0),i=n(37);function o(e,t){for(var n=-1,a=e.length;++n<a;)if(r(e[n],t))return!0;return!1}function r(e,t){return e&&"object"==typeof e?i(e)&&i(t)?function(e,t){for(var n=-1,a=t.length;++n<a;)if(!o(e,t[n]))return!1;return!0}(e,t):function(e,t){var n=!0;return a(t,(function(t,a){if(!r(e[a],t))return n=!1})),n}(e,t):e===t}e.exports=r},function(e,t,n){var a=n(0),i=n(1);e.exports=function(e,t,n){t=i(t,n);var o=!0;return a(e,(function(n,a){if(!t(n,a,e))return o=!1,!1})),o}},function(e,t,n){var a=n(9);e.exports=function(e){return a(e,"Object")}},function(e,t,n){var a=n(0),i=n(1);e.exports=function(e,t,n){t=i(t,n);var o={};return a(e,(function(e,n,a){t(e,n,a)&&(o[n]=e)})),o}},function(e,t,n){n(45);e.exports=function(e,t){for(var n=t.split("."),a=n.pop();t=n.shift();)if(null==(e=e[t]))return;return e[a]}},function(e,t,n){var a=n(20);e.exports=function(e,t){return void 0!==a(e,t)}},function(e,t,n){var a=n(0),i=n(1);e.exports=function(e,t,n){t=i(t,n);var o={};return a(e,(function(e,n,a){o[n]=t(e,n,a)})),o}},function(e,t,n){var a=n(0);function i(e,t){this[t]=e}e.exports=function(e,t){for(var n,o=0,r=arguments.length;++o<r;)null!=(n=arguments[o])&&a(n,i,e);return e}},function(e,t,n){var a=n(7);e.exports=function(e,t){return t?(a(t.split("."),(function(t){e[t]||(e[t]={}),e=e[t]})),e):e}},function(e,t,n){var a=n(0);e.exports=function(e){var t=0;return a(e,(function(){t++})),t}},function(e,t,n){"use strict";function a(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}Object.defineProperty(t,"__esModule",{value:!0}),a(n(66)),a(n(27))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSampleRate=16e3,t.ErrNotInitialized=new Error("Microphone is not initialized"),t.ErrAlreadyInitialized=new Error("Microphone is already initialized"),t.ErrDeviceNotSupported=new Error("Current device does not support microphone API"),t.ErrNoAudioConsent=new Error("Microphone consent is no given")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.Started="started",e.Stopped="stopped",e.SegmentEnd="segment_end",e.Transcript="transcript",e.Entity="entity",e.Intent="intent",e.TentativeTranscript="tentative_transcript",e.TentativeEntities="tentative_entities",e.TentativeIntent="tentative_intent"}(t.WebsocketResponseType||(t.WebsocketResponseType={}))},function(e,t,n){"use strict";function a(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}Object.defineProperty(t,"__esModule",{value:!0}),a(n(30)),a(n(26))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),function(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}(n(5));var a=n(13);t.stateToString=a.stateToString;var i=n(31);t.Client=i.Client},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=n(72),i=n(26),o=n(68),r=n(13),s=n(70),u=n(71),c=n(5);t.Client=class{constructor(e){var t,n,r,h,v,p;if(this.activeContexts=new Map,this.state=c.ClientState.Disconnected,this.reconnectAttemptCount=d,this.nextReconnectDelay=m,this.stateChangeCb=()=>{},this.segmentChangeCb=()=>{},this.tentativeTranscriptCb=()=>{},this.tentativeEntitiesCb=()=>{},this.tentativeIntentCb=()=>{},this.transcriptCb=()=>{},this.entityCb=()=>{},this.intentCb=()=>{},this.handleWebsocketResponse=e=>{this.debug&&console.log("[SpeechlyClient]","Received response",e);const{audio_context:t,segment_id:n,type:a}=e;let{data:i}=e,r=this.activeContexts.get(t);if(void 0!==r){switch(a){case o.WebsocketResponseType.TentativeTranscript:i=i;const e=u.parseTentativeTranscript(i);this.tentativeTranscriptCb(t,n,e,i.transcript),r=r.updateTranscript(e);break;case o.WebsocketResponseType.Transcript:i=i;const a=u.parseTranscript(i);this.transcriptCb(t,n,a),r=r.updateTranscript([a]);break;case o.WebsocketResponseType.TentativeEntities:i=i;const s=u.parseTentativeEntities(i);this.tentativeEntitiesCb(t,n,s),r=r.updateEntities(s);break;case o.WebsocketResponseType.Entity:i=i;const c=u.parseEntity(i);this.entityCb(t,n,c),r=r.updateEntities([c]);break;case o.WebsocketResponseType.TentativeIntent:i=i;const l=u.parseIntent(i,!1);this.tentativeIntentCb(t,n,l),r=r.updateIntent(l);break;case o.WebsocketResponseType.Intent:i=i;const m=u.parseIntent(i,!0);this.intentCb(t,n,m),r=r.updateIntent(m);break;case o.WebsocketResponseType.SegmentEnd:r=r.finalize()}this.segmentChangeCb(r.toSegment()),r.isFinalized?this.activeContexts.set(t,new s.SegmentState(t,r.id+1)):this.activeContexts.set(t,r)}else console.warn("[SpeechlyClient]","Received response for non-existent context",t)},this.handleWebsocketClosure=e=>{this.debug&&console.error("[SpeechlyClient]","Server connection closed",e),this.reconnectWebsocket()},this.handleMicrophoneAudio=e=>{this.state===c.ClientState.Recording&&(this.debug&&console.log("[SpeechlyClient]","Sending audio data",e),this.websocket.send(e))},!a.default.validate(e.language))throw Error(`[SpeechlyClient] Invalid language "${e.language}"`);this.debug=null!=(t=e.debug)&&t,this.microphone=null!=(n=e.microphone)?n:new i.BrowserMicrophone(null!=(r=e.sampleRate)?r:i.DefaultSampleRate),this.websocket=new o.Websocket(null!=(h=e.url)?h:l,e.appId,e.language,null!=(v=e.deviceId)?v:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}),null!=(p=e.sampleRate)?p:i.DefaultSampleRate),this.microphone.onAudio(this.handleMicrophoneAudio),this.websocket.onResponse(this.handleWebsocketResponse),this.websocket.onClose(this.handleWebsocketClosure)}initialize(e=(()=>{})){if(this.state!==c.ClientState.Disconnected)return e(new Error("Cannot initialize client - client is not in Disconnected state"));this.setState(c.ClientState.Connecting),this.microphone.initialize(t=>{if(void 0!==t){switch(t){case i.ErrDeviceNotSupported:this.setState(c.ClientState.NoBrowserSupport);break;case i.ErrNoAudioConsent:this.setState(c.ClientState.NoAudioConsent);break;default:this.setState(c.ClientState.Failed)}return e(t)}this.websocket.initialize(t=>void 0!==t?(this.reconnectWebsocket(),e()):(this.setState(c.ClientState.Connected),e()))})}close(e=(()=>{})){this.microphone.close(t=>{const n=[];void 0!==t&&n.push(t.message);const a=this.websocket.close(1e3,"client disconnecting");return void 0!==a&&n.push(a.message),this.activeContexts.clear(),n.length>0?e(Error(n.join(","))):e()})}startContext(e=(()=>{})){if(this.state!==c.ClientState.Connected)return e(Error("Cannot start context - client is not connected"));this.reconnectAttemptCount=d,this.nextReconnectDelay=m,this.setState(c.ClientState.Starting),this.websocket.start((t,n)=>{if(void 0!==t)return this.setState(c.ClientState.Connected),e(t);const a=n;return this.setState(c.ClientState.Recording),this.microphone.unmute(),this.activeContexts.set(a,new s.SegmentState(a,1)),e(void 0,n)})}stopContext(e=(()=>{})){if(this.state!==c.ClientState.Recording)return e(new Error("Cannot stop context - client is not recording"));this.setState(c.ClientState.Stopping),this.microphone.mute(),this.websocket.stop((t,n)=>{if(void 0!==t)return this.setState(c.ClientState.Failed),e(t);const a=n;return this.setState(c.ClientState.Connected),this.activeContexts.delete(a)||console.warn("[SpeechlyClient]","Attempted to remove non-existent context",a),e()})}onStateChange(e){this.stateChangeCb=e}onSegmentChange(e){this.segmentChangeCb=e}onTentativeTranscript(e){this.tentativeTranscriptCb=e}onTranscript(e){this.transcriptCb=e}onTentativeEntities(e){this.tentativeEntitiesCb=e}onEntity(e){this.entityCb=e}onTentativeIntent(e){this.tentativeIntentCb=e}onIntent(e){this.intentCb=e}reconnectWebsocket(){if(this.reconnectAttemptCount<1)return this.setState(c.ClientState.Disconnected);this.state!==c.ClientState.Connecting&&this.setState(c.ClientState.Connecting),this.debug&&console.log("[SpeechlyClient]",`Attempting to re-connect to the server in ${this.nextReconnectDelay.toString()}ms`),setTimeout(()=>{this.reconnectAttemptCount=this.reconnectAttemptCount-1,this.nextReconnectDelay=2*this.nextReconnectDelay,this.websocket.initialize(e=>{if(void 0!==e)return this.reconnectWebsocket();this.setState(c.ClientState.Connected)})},this.nextReconnectDelay)}setState(e){this.state!==e&&(this.debug&&console.log("[SpeechlyClient]","State transition",r.stateToString(this.state),r.stateToString(e)),this.state=e,this.stateChangeCb(e))}};const l="wss://api.speechly.com/ws",m=1e3,d=5},function(e,t,n){e.exports={bindAll:n(33),contains:n(35),deepFillIn:n(38),deepMatches:n(16),deepMixIn:n(39),equals:n(40),every:n(17),fillIn:n(42),filter:n(19),find:n(43),flatten:n(44),forIn:n(6),forOwn:n(0),functions:n(14),get:n(20),has:n(21),hasOwn:n(2),keys:n(46),map:n(22),matches:n(47),max:n(48),merge:n(50),min:n(53),mixIn:n(23),namespace:n(24),omit:n(55),pick:n(58),pluck:n(59),reduce:n(60),reject:n(61),result:n(62),set:n(64),size:n(25),some:n(8),unset:n(65),values:n(11)}},function(e,t,n){var a=n(14),i=n(34),o=n(7),r=n(3);e.exports=function(e,t){var n=arguments.length>1?r(arguments,1):a(e);o(n,(function(t){e[t]=i(e[t],e)}))}},function(e,t,n){var a=n(3);e.exports=function(e,t,n){var i=a(arguments,2);return function(){return e.apply(t,i.concat(a(arguments)))}}},function(e,t,n){var a=n(8);e.exports=function(e,t){return a(e,(function(e){return e===t}))}},function(e,t){e.exports=function(e){return e}},function(e,t,n){var a=n(9),i=Array.isArray||function(e){return a(e,"Array")};e.exports=i},function(e,t,n){var a=n(0),i=n(4);e.exports=function e(t,n){for(var o,r=0,s=arguments.length;++r<s;)(o=arguments[r])&&a(o,(function(n,a){var o=t[a];null==o?t[a]=n:i(o)&&i(n)&&e(o,n)}));return t}},function(e,t,n){var a=n(0),i=n(4);function o(e,t){for(var n,i=0,o=arguments.length;++i<o;)(n=arguments[i])&&a(n,r,e);return e}function r(e,t){var n=this[t];i(e)&&i(n)?o(n,e):this[t]=e}e.exports=o},function(e,t,n){var a=n(2),i=n(17),o=n(18),r=n(41);function s(e,t){return a(this,t)}e.exports=function(e,t,n){return n=n||r,o(e)&&o(t)?i(e,function(e){return function(t,n){return a(this,n)&&e(t,this[n])}}(n),t)&&i(t,s,e):n(e,t)}},function(e,t){e.exports=function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}},function(e,t,n){var a=n(7),i=n(3),o=n(0);e.exports=function(e,t){return a(i(arguments,1),(function(t){o(t,(function(t,n){null==e[n]&&(e[n]=t)}))})),e}},function(e,t,n){var a=n(8),i=n(1);e.exports=function(e,t,n){var o;return t=i(t,n),a(e,(function(e,n,a){if(t(e,n,a))return o=e,!0})),o}},function(e,t,n){var a=n(0),i=n(4);e.exports=function(e,t){return null==e?{}:function e(t,n,o,r){return a(t,(function(t,a){var s=o?o+"."+a:a;0!==r&&i(t)?e(t,n,s,r-1):n[s]=t})),n}(e,{},"",t=null==t?-1:t)}},function(e,t){e.exports=function(e){switch(typeof e){case"string":case"number":case"boolean":return!0}return null==e}},function(e,t,n){var a=n(0),i=Object.keys||function(e){var t=[];return a(e,(function(e,n){t.push(n)})),t};e.exports=i},function(e,t,n){var a=n(0);e.exports=function(e,t){var n=!0;return a(t,(function(t,a){if(e[a]!==t)return n=!1})),n}},function(e,t,n){var a=n(49),i=n(11);e.exports=function(e,t){return a(i(e),t)}},function(e,t,n){var a=n(1);e.exports=function(e,t,n){if(null!=e&&e.length){if(e.length&&!t)return Math.max.apply(Math,e);t=a(t,n);for(var i,o,r,s=-1/0,u=-1,c=e.length;++u<c;)(r=t(o=e[u],u,e))>s&&(s=r,i=o);return i}return 1/0}},function(e,t,n){var a=n(2),i=n(51),o=n(18);e.exports=function e(){var t,n,r,s,u=1;for(s=i(arguments[0]);r=arguments[u++];)for(t in r)a(r,t)&&(n=r[t],o(n)&&o(s[t])?s[t]=e(s[t],n):s[t]=i(n));return s}},function(e,t,n){var a=n(52),i=n(0),o=n(10),r=n(4);function s(e,t){switch(o(e)){case"Object":return function(e,t){if(r(e)){var n={};return i(e,(function(e,n){this[n]=s(e,t)}),n),n}return t?t(e):e}(e,t);case"Array":return function(e,t){var n=[],a=-1,i=e.length;for(;++a<i;)n[a]=s(e[a],t);return n}(e,t);default:return a(e)}}e.exports=s},function(e,t,n){var a=n(10),i=n(4),o=n(23);e.exports=function(e){switch(a(e)){case"Object":return i(r=e)?o({},r):r;case"Array":return e.slice();case"RegExp":return n="",n+=(t=e).multiline?"m":"",n+=t.global?"g":"",n+=t.ignoreCase?"i":"",new RegExp(t.source,n);case"Date":return new Date(+e);default:return e}var t,n,r}},function(e,t,n){var a=n(54),i=n(11);e.exports=function(e,t){return a(i(e),t)}},function(e,t,n){var a=n(1);e.exports=function(e,t,n){if(null!=e&&e.length){if(e.length&&!t)return Math.min.apply(Math,e);t=a(t,n);for(var i,o,r,s=1/0,u=-1,c=e.length;++u<c;)(r=t(o=e[u],u,e))<s&&(s=r,i=o);return i}return-1/0}},function(e,t,n){var a=n(3),i=n(56);e.exports=function(e,t){var n="string"!=typeof arguments[1]?arguments[1]:a(arguments,1),o={};for(var r in e)e.hasOwnProperty(r)&&!i(n,r)&&(o[r]=e[r]);return o}},function(e,t,n){var a=n(57);e.exports=function(e,t){return-1!==a(e,t)}},function(e,t){e.exports=function(e,t,n){if(n=n||0,null==e)return-1;for(var a=e.length,i=n<0?a+n:n;i<a;){if(e[i]===t)return i;i++}return-1}},function(e,t,n){var a=n(3);e.exports=function(e,t){for(var n,i="string"!=typeof arguments[1]?arguments[1]:a(arguments,1),o={},r=0;n=i[r++];)o[n]=e[n];return o}},function(e,t,n){var a=n(22),i=n(15);e.exports=function(e,t){return a(e,i(t))}},function(e,t,n){var a=n(0),i=n(25);e.exports=function(e,t,n,o){var r=arguments.length>2;if(!i(e)&&!r)throw new Error("reduce of empty object with no initial value");return a(e,(function(e,a,i){r?n=t.call(o,n,e,a,i):(n=e,r=!0)})),n}},function(e,t,n){var a=n(19),i=n(1);e.exports=function(e,t,n){return t=i(t,n),a(e,(function(e,n,a){return!t(e,n,a)}),n)}},function(e,t,n){var a=n(63);e.exports=function(e,t){var n=e[t];if(void 0!==n)return a(n)?n.call(e):n}},function(e,t,n){var a=n(9);e.exports=function(e){return a(e,"Function")}},function(e,t,n){var a=n(24);e.exports=function(e,t,n){var i=/^(.+)\.(.+)$/.exec(t);i?a(e,i[1])[i[2]]=n:e[t]=n}},function(e,t,n){var a=n(21);e.exports=function(e,t){if(a(e,t)){for(var n=t.split("."),i=n.pop();t=n.shift();)e=e[t];return delete e[i]}return!0}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=n(67),i=n(27);t.BrowserMicrophone=class{constructor(e){this.onAudioCb=()=>{},this.sampleRate=e}onAudio(e){this.onAudioCb=e}initialize(e){var t;return void 0!==this.audioTrack?e(i.ErrAlreadyInitialized):void 0===(null===(t=window.navigator)||void 0===t?void 0:t.mediaDevices)?e(i.ErrDeviceNotSupported):void window.navigator.mediaDevices.getUserMedia({audio:!0,video:!1}).then(t=>{this.mediaStream=t,this.audioTrack=this.mediaStream.getAudioTracks()[0],this.audioTrack.enabled=!1,e()}).catch(()=>{e(i.ErrNoAudioConsent)})}close(e){if(void 0===this.mediaStream)return e(i.ErrNotInitialized);if(this.mute(),this.mediaStream.getTracks().forEach(e=>e.stop()),void 0!==this.audioProcessor&&this.audioProcessor.disconnect(),void 0===this.audioContext)return e();const t=t=>(this.mediaStream=void 0,this.audioTrack=void 0,this.audioContext=void 0,this.downsampler=void 0,this.audioProcessor=void 0,void 0!==t?e(t):e());this.audioContext.close().then(t).catch(t)}mute(){void 0!==this.audioTrack&&(this.audioTrack.enabled=!1)}unmute(){void 0!==this.audioTrack&&(this.audioTrack.enabled=!0,void 0===this.audioContext&&this.initializeAudioContext())}initializeAudioContext(){if(void 0===this.mediaStream)throw Error("Microphone media stream is not initialized");if(void 0!==this.audioContext)throw Error("Microphone audio context is already initialized");if(void 0!==window.AudioContext)this.audioContext=new window.AudioContext;else{if(void 0===window.webkitAudioContext)throw Error("Microphone functionality is not supported in your browser");this.audioContext=new window.webkitAudioContext}this.downsampler=a.generateDownsampler(this.audioContext.sampleRate,this.sampleRate),this.audioProcessor=this.audioContext.createScriptProcessor(4096,1,1),this.audioContext.createMediaStreamSource(this.mediaStream).connect(this.audioProcessor),this.audioProcessor.connect(this.audioContext.destination),this.audioProcessor.onaudioprocess=e=>{if(void 0===this.audioTrack)throw Error("Microphone audio track is not initialized");if(void 0===this.downsampler)throw Error("Microphone downsampler is not initialized");if(!this.audioTrack.enabled)return;const t=a.float32ToInt16(this.downsampler(e.inputBuffer.getChannelData(0)));this.onAudioCb(t)}}}},function(e,t,n){"use strict";function a(e){if(0===e)return 1;const t=Math.PI*e;return Math.sin(t)/t}Object.defineProperty(t,"__esModule",{value:!0}),t.generateDownsampler=function(e,t){const n=e/t,i=function(e,t,n){if(n%2==0)throw Error("Filter length must be odd");const i=new Array(n);let o=0;for(let r=0;r<n;r++){const s=a(2*t/e*(r-(n-1)/2));o+=s,i[r]=s}for(let e=0;e<n;e++)i[e]=i[e]/o;return i}(e,t/2,23);let o=new Float32Array(0);return e=>{const t=new Float32Array(o.length+e.length);t.set(o,0),t.set(e,o.length);const a=Math.ceil((t.length-i.length)/n),r=new Float32Array(a);for(let e=0;e<a;e++){const a=Math.round(n*e);for(let n=0;n<i.length;n++)r[e]+=t[a+n]*i[n]}const s=Math.round(n*a);return o=s<t.length?t.slice(s):new Float32Array(0),r}},t.float32ToInt16=function(e){let t=e.length;const n=new Int16Array(t);for(;t-- >0;)n[t]=e[t]*(e[t]<0?32768:32767);return n.buffer}},function(e,t,n){"use strict";function a(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}Object.defineProperty(t,"__esModule",{value:!0}),a(n(69)),a(n(28))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const a=n(28);t.Websocket=class{constructor(e,t,n,i,o){this.startCbs=[],this.stopCbs=[],this.onResponseCb=()=>{},this.onCloseCb=()=>{},this.onWebsocketMessage=e=>{let t;try{t=JSON.parse(e.data)}catch(e){return void console.error("[SpeechlyClient] Error parsing response from the server:",e)}switch(t.type){case a.WebsocketResponseType.Started:this.startCbs.forEach(e=>{try{e(void 0,t.audio_context)}catch(e){console.error('[SpeechlyClient] Error while invoking "onStart" callback:',e)}}),this.startCbs.length=0;break;case a.WebsocketResponseType.Stopped:this.stopCbs.forEach(e=>{try{e(void 0,t.audio_context)}catch(e){console.error('[SpeechlyClient] Error while invoking "onStop" callback:',e)}}),this.stopCbs.length=0;break;default:this.onResponseCb(t)}},this.onWebsocketClose=e=>{this.onCloseCb(Error(`Websocket was closed: ${e.reason}`))},this.onWebsocketError=e=>{this.close(1e3,"Client disconnecting due to an error"),this.onCloseCb(Error("Websocket was closed because of error"))},this.url=function(e,t,n,a){const i=new URLSearchParams;return i.append("deviceId",t),i.append("languageCode",n),i.append("sampleRate",a.toString()),`${e}?${i.toString()}`}(e,i,n,o),this.appId=t}onResponse(e){this.onResponseCb=e}onClose(e){this.onCloseCb=e}initialize(e){if(void 0!==this.websocket)return e(Error("Cannot initialize an already initialized websocket client"));!function(e,t,n){const a=new WebSocket(e,t),i=()=>{a.removeEventListener("close",i),a.removeEventListener("error",i),a.removeEventListener("open",o),n(Error("Connection failed"))},o=()=>{a.removeEventListener("close",i),a.removeEventListener("error",i),a.removeEventListener("open",o),n(void 0,a)};a.addEventListener("close",i),a.addEventListener("error",i),a.addEventListener("open",o)}(this.url,this.appId,(t,n)=>void 0!==t?e(t):(this.websocket=n,this.websocket.addEventListener("message",this.onWebsocketMessage),this.websocket.addEventListener("error",this.onWebsocketError),this.websocket.addEventListener("close",this.onWebsocketClose),e()))}close(e,t){if(void 0===this.websocket)return Error("Websocket is not open");this.websocket.removeEventListener("message",this.onWebsocketMessage),this.websocket.removeEventListener("error",this.onWebsocketError),this.websocket.removeEventListener("close",this.onWebsocketClose),this.websocket.close(e,t),this.websocket=void 0}start(e){if(!this.isOpen())return e(Error("Websocket is not ready"));this.startCbs.push(e),this.websocket.send(i)}stop(e){if(!this.isOpen())return e(new Error("websocket is not ready"));this.stopCbs.push(e),this.websocket.send(o)}send(e){if(!this.isOpen())return Error("Cannot send data through inactive websocket");this.websocket.send(e)}isOpen(){return void 0!==this.websocket&&this.websocket.readyState===this.websocket.OPEN}};const i=JSON.stringify({event:"start"}),o=JSON.stringify({event:"stop"})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.SegmentState=class{constructor(e,t){this.isFinalized=!1,this.words=[],this.entities=new Map,this.intent={intent:"",isFinal:!1},this.contextId=e,this.id=t}toSegment(){let e=0;const t=new Array(this.entities.size);for(const n of this.entities.values())t[e]=n,e++;return{id:this.id,contextId:this.contextId,isFinal:this.isFinalized,words:this.words,entities:t,intent:this.intent}}updateTranscript(e){return e.forEach(e=>{this.words[e.index]=e}),this}updateEntities(e){return e.forEach(e=>this.entities.set(function(e){return`${e.startPosition.toString()}:${e.endPosition.toString()}`}(e),e)),this}updateIntent(e){return this.intent.isFinal||(this.intent=e),this}finalize(){return this.entities.forEach((e,t)=>{e.isFinal||this.entities.delete(t)}),this.words=this.words.filter(e=>e.isFinal),this.intent.isFinal||(this.intent.intent="",this.intent.isFinal=!0),this.isFinalized=!0,this}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseTentativeTranscript=function(e){return e.words.map(({word:e,index:t,start_timestamp:n,end_timestamp:a})=>({value:e,index:t,startTimestamp:n,endTimestamp:a,isFinal:!1}))},t.parseTranscript=function(e){return{value:e.word,index:e.index,startTimestamp:e.start_timestamp,endTimestamp:e.end_timestamp,isFinal:!0}},t.parseTentativeEntities=function(e){return e.entities.map(({entity:e,value:t,start_position:n,end_position:a})=>({type:e,value:t,startPosition:n,endPosition:a,isFinal:!1}))},t.parseEntity=function(e){return{type:e.entity,value:e.value,startPosition:e.start_position,endPosition:e.end_position,isFinal:!0}},t.parseIntent=function(e,t){return{intent:e.intent,isFinal:t}}},function(e,t,n){"use strict";n.r(t);var a={aa:{name:"Afar",nativeName:"Afaraf"},ab:{name:"Abkhaz",nativeName:"аҧсуа бызшәа"},ae:{name:"Avestan",nativeName:"avesta"},af:{name:"Afrikaans",nativeName:"Afrikaans"},ak:{name:"Akan",nativeName:"Akan"},am:{name:"Amharic",nativeName:"አማርኛ"},an:{name:"Aragonese",nativeName:"aragonés"},ar:{name:"Arabic",nativeName:"اللغة العربية"},as:{name:"Assamese",nativeName:"অসমীয়া"},av:{name:"Avaric",nativeName:"авар мацӀ"},ay:{name:"Aymara",nativeName:"aymar aru"},az:{name:"Azerbaijani",nativeName:"azərbaycan dili"},ba:{name:"Bashkir",nativeName:"башҡорт теле"},be:{name:"Belarusian",nativeName:"беларуская мова"},bg:{name:"Bulgarian",nativeName:"български език"},bh:{name:"Bihari",nativeName:"भोजपुरी"},bi:{name:"Bislama",nativeName:"Bislama"},bm:{name:"Bambara",nativeName:"bamanankan"},bn:{name:"Bengali",nativeName:"বাংলা"},bo:{name:"Tibetan Standard",nativeName:"བོད་ཡིག"},br:{name:"Breton",nativeName:"brezhoneg"},bs:{name:"Bosnian",nativeName:"bosanski jezik"},ca:{name:"Catalan",nativeName:"català"},ce:{name:"Chechen",nativeName:"нохчийн мотт"},ch:{name:"Chamorro",nativeName:"Chamoru"},co:{name:"Corsican",nativeName:"corsu"},cr:{name:"Cree",nativeName:"ᓀᐦᐃᔭᐍᐏᐣ"},cs:{name:"Czech",nativeName:"čeština"},cu:{name:"Old Church Slavonic",nativeName:"ѩзыкъ словѣньскъ"},cv:{name:"Chuvash",nativeName:"чӑваш чӗлхи"},cy:{name:"Welsh",nativeName:"Cymraeg"},da:{name:"Danish",nativeName:"dansk"},de:{name:"German",nativeName:"Deutsch"},dv:{name:"Divehi",nativeName:"Dhivehi"},dz:{name:"Dzongkha",nativeName:"རྫོང་ཁ"},ee:{name:"Ewe",nativeName:"Eʋegbe"},el:{name:"Greek",nativeName:"Ελληνικά"},en:{name:"English",nativeName:"English"},eo:{name:"Esperanto",nativeName:"Esperanto"},es:{name:"Spanish",nativeName:"Español"},et:{name:"Estonian",nativeName:"eesti"},eu:{name:"Basque",nativeName:"euskara"},fa:{name:"Persian",nativeName:"فارسی"},ff:{name:"Fula",nativeName:"Fulfulde"},fi:{name:"Finnish",nativeName:"suomi"},fj:{name:"Fijian",nativeName:"Vakaviti"},fo:{name:"Faroese",nativeName:"føroyskt"},fr:{name:"French",nativeName:"Français"},fy:{name:"Western Frisian",nativeName:"Frysk"},ga:{name:"Irish",nativeName:"Gaeilge"},gd:{name:"Scottish Gaelic",nativeName:"Gàidhlig"},gl:{name:"Galician",nativeName:"galego"},gn:{name:"Guaraní",nativeName:"Avañe'ẽ"},gu:{name:"Gujarati",nativeName:"ગુજરાતી"},gv:{name:"Manx",nativeName:"Gaelg"},ha:{name:"Hausa",nativeName:"هَوُسَ"},he:{name:"Hebrew",nativeName:"עברית"},hi:{name:"Hindi",nativeName:"हिन्दी"},ho:{name:"Hiri Motu",nativeName:"Hiri Motu"},hr:{name:"Croatian",nativeName:"hrvatski jezik"},ht:{name:"Haitian",nativeName:"Kreyòl ayisyen"},hu:{name:"Hungarian",nativeName:"magyar"},hy:{name:"Armenian",nativeName:"Հայերեն"},hz:{name:"Herero",nativeName:"Otjiherero"},ia:{name:"Interlingua",nativeName:"Interlingua"},id:{name:"Indonesian",nativeName:"Indonesian"},ie:{name:"Interlingue",nativeName:"Interlingue"},ig:{name:"Igbo",nativeName:"Asụsụ Igbo"},ii:{name:"Nuosu",nativeName:"ꆈꌠ꒿ Nuosuhxop"},ik:{name:"Inupiaq",nativeName:"Iñupiaq"},io:{name:"Ido",nativeName:"Ido"},is:{name:"Icelandic",nativeName:"Íslenska"},it:{name:"Italian",nativeName:"Italiano"},iu:{name:"Inuktitut",nativeName:"ᐃᓄᒃᑎᑐᑦ"},ja:{name:"Japanese",nativeName:"日本語"},jv:{name:"Javanese",nativeName:"basa Jawa"},ka:{name:"Georgian",nativeName:"ქართული"},kg:{name:"Kongo",nativeName:"Kikongo"},ki:{name:"Kikuyu",nativeName:"Gĩkũyũ"},kj:{name:"Kwanyama",nativeName:"Kuanyama"},kk:{name:"Kazakh",nativeName:"қазақ тілі"},kl:{name:"Kalaallisut",nativeName:"kalaallisut"},km:{name:"Khmer",nativeName:"ខេមរភាសា"},kn:{name:"Kannada",nativeName:"ಕನ್ನಡ"},ko:{name:"Korean",nativeName:"한국어"},kr:{name:"Kanuri",nativeName:"Kanuri"},ks:{name:"Kashmiri",nativeName:"कश्मीरी"},ku:{name:"Kurdish",nativeName:"Kurdî"},kv:{name:"Komi",nativeName:"коми кыв"},kw:{name:"Cornish",nativeName:"Kernewek"},ky:{name:"Kyrgyz",nativeName:"Кыргызча"},la:{name:"Latin",nativeName:"latine"},lb:{name:"Luxembourgish",nativeName:"Lëtzebuergesch"},lg:{name:"Ganda",nativeName:"Luganda"},li:{name:"Limburgish",nativeName:"Limburgs"},ln:{name:"Lingala",nativeName:"Lingála"},lo:{name:"Lao",nativeName:"ພາສາ"},lt:{name:"Lithuanian",nativeName:"lietuvių kalba"},lu:{name:"Luba-Katanga",nativeName:"Tshiluba"},lv:{name:"Latvian",nativeName:"latviešu valoda"},mg:{name:"Malagasy",nativeName:"fiteny malagasy"},mh:{name:"Marshallese",nativeName:"Kajin M̧ajeļ"},mi:{name:"Māori",nativeName:"te reo Māori"},mk:{name:"Macedonian",nativeName:"македонски јазик"},ml:{name:"Malayalam",nativeName:"മലയാളം"},mn:{name:"Mongolian",nativeName:"Монгол хэл"},mr:{name:"Marathi",nativeName:"मराठी"},ms:{name:"Malay",nativeName:"هاس ملايو"},mt:{name:"Maltese",nativeName:"Malti"},my:{name:"Burmese",nativeName:"ဗမာစာ"},na:{name:"Nauru",nativeName:"Ekakairũ Naoero"},nb:{name:"Norwegian Bokmål",nativeName:"Norsk bokmål"},nd:{name:"Northern Ndebele",nativeName:"isiNdebele"},ne:{name:"Nepali",nativeName:"नेपाली"},ng:{name:"Ndonga",nativeName:"Owambo"},nl:{name:"Dutch",nativeName:"Nederlands"},nn:{name:"Norwegian Nynorsk",nativeName:"Norsk nynorsk"},no:{name:"Norwegian",nativeName:"Norsk"},nr:{name:"Southern Ndebele",nativeName:"isiNdebele"},nv:{name:"Navajo",nativeName:"Diné bizaad"},ny:{name:"Chichewa",nativeName:"chiCheŵa"},oc:{name:"Occitan",nativeName:"occitan"},oj:{name:"Ojibwe",nativeName:"ᐊᓂᔑᓈᐯᒧᐎᓐ"},om:{name:"Oromo",nativeName:"Afaan Oromoo"},or:{name:"Oriya",nativeName:"ଓଡ଼ିଆ"},os:{name:"Ossetian",nativeName:"ирон æвзаг"},pa:{name:"Panjabi",nativeName:"ਪੰਜਾਬੀ"},pi:{name:"Pāli",nativeName:"पाऴि"},pl:{name:"Polish",nativeName:"język polski"},ps:{name:"Pashto",nativeName:"پښتو"},pt:{name:"Portuguese",nativeName:"Português"},qu:{name:"Quechua",nativeName:"Runa Simi"},rm:{name:"Romansh",nativeName:"rumantsch grischun"},rn:{name:"Kirundi",nativeName:"Ikirundi"},ro:{name:"Romanian",nativeName:"Română"},ru:{name:"Russian",nativeName:"Русский"},rw:{name:"Kinyarwanda",nativeName:"Ikinyarwanda"},sa:{name:"Sanskrit",nativeName:"संस्कृतम्"},sc:{name:"Sardinian",nativeName:"sardu"},sd:{name:"Sindhi",nativeName:"सिन्धी"},se:{name:"Northern Sami",nativeName:"Davvisámegiella"},sg:{name:"Sango",nativeName:"yângâ tî sängö"},si:{name:"Sinhala",nativeName:"සිංහල"},sk:{name:"Slovak",nativeName:"slovenčina"},sl:{name:"Slovene",nativeName:"slovenski jezik"},sm:{name:"Samoan",nativeName:"gagana fa'a Samoa"},sn:{name:"Shona",nativeName:"chiShona"},so:{name:"Somali",nativeName:"Soomaaliga"},sq:{name:"Albanian",nativeName:"Shqip"},sr:{name:"Serbian",nativeName:"српски језик"},ss:{name:"Swati",nativeName:"SiSwati"},st:{name:"Southern Sotho",nativeName:"Sesotho"},su:{name:"Sundanese",nativeName:"Basa Sunda"},sv:{name:"Swedish",nativeName:"svenska"},sw:{name:"Swahili",nativeName:"Kiswahili"},ta:{name:"Tamil",nativeName:"தமிழ்"},te:{name:"Telugu",nativeName:"తెలుగు"},tg:{name:"Tajik",nativeName:"тоҷикӣ"},th:{name:"Thai",nativeName:"ไทย"},ti:{name:"Tigrinya",nativeName:"ትግርኛ"},tk:{name:"Turkmen",nativeName:"Türkmen"},tl:{name:"Tagalog",nativeName:"Wikang Tagalog"},tn:{name:"Tswana",nativeName:"Setswana"},to:{name:"Tonga",nativeName:"faka Tonga"},tr:{name:"Turkish",nativeName:"Türkçe"},ts:{name:"Tsonga",nativeName:"Xitsonga"},tt:{name:"Tatar",nativeName:"татар теле"},tw:{name:"Twi",nativeName:"Twi"},ty:{name:"Tahitian",nativeName:"Reo Tahiti"},ug:{name:"Uyghur",nativeName:"ئۇيغۇرچە"},uk:{name:"Ukrainian",nativeName:"Українська"},ur:{name:"Urdu",nativeName:"اردو"},uz:{name:"Uzbek",nativeName:"Ўзбек"},ve:{name:"Venda",nativeName:"Tshivenḓa"},vi:{name:"Vietnamese",nativeName:"Tiếng Việt"},vo:{name:"Volapük",nativeName:"Volapük"},wa:{name:"Walloon",nativeName:"walon"},wo:{name:"Wolof",nativeName:"Wollof"},xh:{name:"Xhosa",nativeName:"isiXhosa"},yi:{name:"Yiddish",nativeName:"ייִדיש"},yo:{name:"Yoruba",nativeName:"Yorùbá"},za:{name:"Zhuang",nativeName:"Saɯ cueŋƅ"},zh:{name:"Chinese",nativeName:"中文"},zu:{name:"Zulu",nativeName:"isiZulu"}};class i{static getLanguages(e=[]){return e.map(e=>({code:e,name:i.getName(e),nativeName:i.getNativeName(e)}))}static getName(e){return i.validate(e)?a[e].name:""}static getAllNames(){return Object.values(a).map(e=>e.name)}static getNativeName(e){return i.validate(e)?a[e].nativeName:""}static getAllNativeNames(){return Object.values(a).map(e=>e.nativeName)}static getCode(e){return Object.keys(a).find(t=>{const n=a[t];return n.name.toLowerCase()===e.toLowerCase()||n.nativeName.toLowerCase()===e.toLowerCase()})||""}static getAllCodes(){return Object.keys(a)}static validate(e){return a.hasOwnProperty(e)}}var o={aa:"阿法尔语",ab:"阿布哈兹语",ae:"阿维斯陀语",af:"南非荷兰语",ak:"阿坎语",am:"阿姆哈拉语",an:"阿拉贡语",ar:"阿拉伯语",as:"阿萨姆语",av:"阿瓦尔语",ay:"艾马拉语",az:"阿塞拜疆语",ba:"巴什基尔语",be:"白俄罗斯语",bg:"保加利亚语",bh:"比哈尔语",bi:"比斯拉马语",bm:"班巴拉语",bn:"孟加拉语",bo:"藏语",br:"布列塔尼语",bs:"波斯尼亚语",ca:"加泰罗尼亚语",ce:"车臣语",ch:"查莫洛语",co:"科西嘉语",cr:"克里语",cs:"捷克语",cu:"古教会斯拉夫语",cv:"楚瓦什语",cy:"威尔士语",da:"丹麦语",de:"德语",dv:"迪维希语",dz:"不丹语",ee:"埃维语",el:"希腊语",en:"英语",eo:"世界语",es:"西班牙语",et:"爱沙尼亚语",eu:"巴斯克语",fa:"波斯语",ff:"富拉语",fi:"芬兰语",fj:"斐济语",fo:"法罗语",fr:"法语",fy:"西弗里西亚语",ga:"爱尔兰语",gd:"苏格兰盖尔语",gl:"加利西亚语",gn:"瓜拉尼语",gu:"古吉拉特语",gv:"马恩岛语",ha:"豪萨语",he:"希伯来语",hi:"印地语",ho:"莫图语",hr:"克罗地亚语",ht:"海地文",hu:"匈牙利语",hy:"亚美尼亚语",hz:"赫勒娄语",ia:"国际语",id:"印尼语",ie:"国际语",ig:"伊博语",ii:"诺苏语",ik:"依奴皮维克文",io:"伊多文",is:"冰岛语",it:"意大利语",iu:"因纽特语",ja:"日语",jv:"爪哇语",ka:"格鲁吉亚语",kg:"刚果语",ki:"基库尤语",kj:"宽亚马语",kk:"哈萨克语",kl:"格陵兰语",km:"高棉语",kn:"卡纳达语",ko:"韩语",kr:"卡努里语",ks:"克什米尔语",ku:"库尔德语",kv:"科米语",kw:"科尼什语",ky:"吉尔吉斯语",la:"拉丁语",lb:"卢森堡语",lg:"甘达语",li:"林堡语",ln:"林加拉语",lo:"老挝语",lt:"立陶宛语",lu:"卢巴加丹加语",lv:"拉脱维亚语",mg:"马尔加什语",mh:"马绍尔语",mi:"毛利语",mk:"马其顿语",ml:"马拉雅拉姆语",mn:"蒙古文",mr:"马拉地语",ms:"马来语",mt:"马耳他语",my:"缅甸语",na:"瑙鲁语",nb:"挪威博克马尔语",nd:"北恩德贝勒语",ne:"尼泊尔语",ng:"尼日尔刚果语",nl:"荷兰语",nn:"挪威尼诺斯克语",no:"挪威语",nr:"南恩德贝勒语",nv:"纳瓦霍语",ny:"齐切瓦语",oc:"奥克西唐语",oj:"欧及布威语",om:"奥罗莫语",or:"奥里亚语",os:"奥塞梯语",pa:"旁遮普语",pi:"巴利语",pl:"波兰语",ps:"普什图语",pt:"葡萄牙语",qu:"克丘亚语",rm:"罗曼斯语",rn:"基隆迪语",ro:"罗马尼亚语",ru:"俄语",rw:"卢旺达语",sa:"梵文",sc:"撒丁岛语",sd:"信德语",se:"北萨米文",sg:"桑戈语",si:"僧伽罗语",sk:"斯洛伐克语",sl:"斯洛文尼亚语",sm:"萨摩亚语",sn:"绍纳语",so:"索马里语",sq:"阿尔巴尼亚语",sr:"塞尔维亚语",ss:"斯瓦蒂语",st:"南索托语",su:"巽他语",sv:"瑞典语",sw:"斯瓦希里语",ta:"泰米尔语",te:"泰卢固语",tg:"塔吉克语",th:"泰语",ti:"提格雷语",tk:"土库曼语",tl:"菲律宾语",tn:"茨瓦纳语",to:"汤加语",tr:"土耳其语",ts:"特松加语",tt:"塔塔尔语",tw:"契维语",ty:"塔希提语",ug:"维吾尔语",uk:"乌克兰语",ur:"乌尔都语",uz:"乌兹别克语",ve:"文达语",vi:"越南语",vo:"沃拉普克语",wa:"华隆语",wo:"沃洛夫语",xh:"科萨语",yi:"意第绪语",yo:"约鲁巴语",za:"壮语",zh:"中文",zu:"祖鲁语"};class r extends i{static getLanguages(e){return super.getLanguages(e).map(e=>(Object.assign(e,{zhName:r.getZhName(e.code)}),e))}static getZhName(e){return super.validate(e)?o[e]:""}static getAllZhNames(){return Object.values(o)}}var s=n(12),u=n.n(s);n.d(t,"default",(function(){return l}));const c=/^([a-z]{2})-([A-Z]{2})$/;class l{static getLanguageCode(e){var t=e.match(c);return!t||t.length<1?"":t[1]}static getLanguageName(e){var t=l.getLanguageCode(e);return r.getName(t)}static getLanguageNativeName(e){var t=l.getLanguageCode(e);return r.getNativeName(t)}static getLanguageZhName(e){var t=l.getLanguageCode(e);return r.getZhName(t)}static validateLanguageCode(e){var t=l.getLanguageCode(e);return r.validate(t)}static getLanguages(e){for(var t=[],n=0;n<e.length;n++)t.push({code:e[n],name:l.getLanguageName(e[n]),nativeName:l.getLanguageNativeName(e[n]),zhName:l.getLanguageZhName(e[n])});return t}static getCountryCode(e){var t=e.match(c);return!t||t.length<2?"":t[2]}static getCountryName(e){var t=l.getCountryCode(e);return u.a.getCountry(t)}static validateCountryCode(e){return e=l.getCountryCode(e),-1!==u.a.getCodes().indexOf(e)}static validate(e){var t=e.match(c);return!!(t&&3===t.length&&l.validateLanguageCode(e)&&l.validateCountryCode(e))}}}])})); | ||
//# sourceMappingURL=speechly.js.map |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
222044
535
62