You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gpt4free/g4f/gui/client/static/js/text_to_speech/900.index.js

1 line
749 KiB
JavaScript

(self.webpackChunk=self.webpackChunk||[]).push([[900],{450:(t,e,n)=>{"use strict";n.r(e),n.d(e,{InferenceSession:()=>f,Tensor:()=>h,env:()=>o,registerBackend:()=>s});const r={},i=[],s=(t,e,n)=>{if(!e||"function"!=typeof e.init||"function"!=typeof e.createSessionHandler)throw new TypeError("not a valid backend");{const s=r[t];if(void 0===s)r[t]={backend:e,priority:n};else{if(s.priority>n)return;if(s.priority===n&&s.backend!==e)throw new Error(`cannot register backend "${t}" using priority ${n}`)}if(n>=0){const e=i.indexOf(t);-1!==e&&i.splice(e,1);for(let e=0;e<i.length;e++)if(r[i[e]].priority<=n)return void i.splice(e,0,t);i.push(t)}}},o=new class{constructor(){this.wasm={},this.webgl={},this.logLevelInternal="warning"}set logLevel(t){if(void 0!==t){if("string"!=typeof t||-1===["verbose","info","warning","error","fatal"].indexOf(t))throw new Error(`Unsupported logging level: ${t}`);this.logLevelInternal=t}}get logLevel(){return this.logLevelInternal}},a="undefined"!=typeof BigInt64Array&&"function"==typeof BigInt64Array.from,u="undefined"!=typeof BigUint64Array&&"function"==typeof BigUint64Array.from,l=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array]]),c=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]);a&&(l.set("int64",BigInt64Array),c.set(BigInt64Array,"int64")),u&&(l.set("uint64",BigUint64Array),c.set(BigUint64Array,"uint64"));class d{constructor(t,e,n){let r,i,s;if("string"==typeof t)if(r=t,s=n,"string"===t){if(!Array.isArray(e))throw new TypeError("A string tensor's data must be a string array.");i=e}else{const n=l.get(t);if(void 0===n)throw new TypeError(`Unsupported tensor type: ${t}.`);if(Array.isArray(e))i=n.from(e);else{if(!(e instanceof n))throw new TypeError(`A ${r} tensor's data must be type of ${n}`);i=e}}else if(s=e,Array.isArray(t)){if(0===t.length)throw new TypeError("Tensor type cannot be inferred from an empty array.");const e=typeof t[0];if("string"===e)r="string",i=t;else{if("boolean"!==e)throw new TypeError(`Invalid element type of data array: ${e}.`);r="bool",i=Uint8Array.from(t)}}else{const e=c.get(t.constructor);if(void 0===e)throw new TypeError(`Unsupported type for tensor data: ${t.constructor}.`);r=e,i=t}if(void 0===s)s=[i.length];else if(!Array.isArray(s))throw new TypeError("A tensor's dims must be a number array");const o=(t=>{let e=1;for(let n=0;n<t.length;n++){const r=t[n];if("number"!=typeof r||!Number.isSafeInteger(r))throw new TypeError(`dims[${n}] must be an integer, got: ${r}`);if(r<0)throw new RangeError(`dims[${n}] must be a non-negative integer, got: ${r}`);e*=r}return e})(s);if(o!==i.length)throw new Error(`Tensor's size(${o}) does not match data length(${i.length}).`);this.dims=s,this.type=r,this.data=i,this.size=o}static bufferToTensor(t,e){if(void 0===t)throw new Error("Image buffer must be defined");if(void 0===e.height||void 0===e.width)throw new Error("Image height and width must be defined");const{height:n,width:r}=e,i=e.norm;let s,o;s=void 0===i||void 0===i.mean?255:i.mean,o=void 0===i||void 0===i.bias?0:i.bias;const a=void 0!==e.bitmapFormat?e.bitmapFormat:"RGBA",u=void 0!==e.tensorFormat&&void 0!==e.tensorFormat?e.tensorFormat:"RGB",l=n*r,c="RGBA"===u?new Float32Array(4*l):new Float32Array(3*l);let h=4,p=0,f=1,g=2,m=3,_=0,b=l,y=2*l,w=-1;"RGB"===a&&(h=3,p=0,f=1,g=2,m=-1),"RGBA"===u?w=3*l:"RBG"===u?(_=0,y=l,b=2*l):"BGR"===u&&(y=0,b=l,_=2*l);for(let e=0;e<l;e++,p+=h,g+=h,f+=h,m+=h)c[_++]=(t[p]+o)/s,c[b++]=(t[f]+o)/s,c[y++]=(t[g]+o)/s,-1!==w&&-1!==m&&(c[w++]=(t[m]+o)/s);return new d("float32",c,"RGBA"===u?[1,4,n,r]:[1,3,n,r])}static async fromImage(t,e){const n="undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement,r="undefined"!=typeof ImageData&&t instanceof ImageData,i="undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap,s="undefined"!=typeof String&&(t instanc