@aim-packages/subtitle 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +6 -6
- package/dist/index.es.js +92 -79
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
* @author Newtopia Dev (http://www.newtopia.com)
|
|
18
18
|
* @version 1.0.1
|
|
19
19
|
* @license MIT
|
|
20
|
-
*/function wt(e,t){let r=t;for(;!e[r];)r++;return r}function Ot(e){let t=e.length-1;for(;t>=0&&!e[t];)t--;return t}function At(e="",t={propName:{}}){const r=[],n=e.split(/(?:\r\n|\r|\n)/gm).filter(
|
|
21
|
-
`:
|
|
22
|
-
`).split(/(?:\r\n|\r|\n)/gm),c=Ot(a)+1;let s=0,u,i,
|
|
23
|
-
`:" ").replace(/\{(\\[\w]+\(?([\w\d]+,?)+\)?)+\}/gi,""),
|
|
24
|
-
`);i.forEach((f
|
|
25
|
-
${f}`,l===i.length-1&&s.push(se(c))):(c.part=f,s.push(se(c)),c.part="")))}),c=[];const o=/(<([0-9:.>]+)>)/ig;s.forEach(f=>{const _=f.part.split().map(function(p){return p.replace(o,function(b){return b.split("").reduce(function(S,N){return`==${b.replace("<","").replace(">","")}`},0)})})[0].replace(r,"").split(" "),y=[];_.forEach(function(p){if(p.indexOf("==")>-1){const b=p.split("=="),S=b[0];if(b[1],S==""||S=="##")return;y.push({word:xe(p.split("==")[0]),time:ae(p.split("==")[1])})}else y.push({word:xe(p),time:void 0})}),f.words=y,f.part=f.part.replace(r,"")}),n(s)})}function ae(e){const t=e.split(":"),r=t[t.length-3]?+t[t.length-3]:0,n=t[t.length-2]?+t[t.length-2]:0,a=+t[t.length-1];return r*3600+n*60+a}function xe(e){return e.replace(/[^0-9a-z'-]/gi,"").toLowerCase()}function se(e){if(e==null||typeof e!="object")return e;const t=e.constructor();for(const r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t}function Et(e){return e.Transcription.Paragraphs.map(t=>{const r=t.Words.map(n=>({st:g(n.Start/1e3),et:g(n.End/1e3),text:n.Text,spk:t.SpeakerId}));return{st:g(t.Words[0].Start/1e3),et:g(t.Words[t.Words.length-1].End/1e3),text:r.map(n=>n.text).join(""),spk:t.SpeakerId,children:r}})}function Ct(e){var t;if(e.segments){const r=e.segments.map(n=>({st:g(n.start),et:g(n.end),text:n.text}));if(e.words.length>0){const n=e.words;let a=0,c=0;for(;a<r.length;){const s=r[a];let u=s.text;for(let i=c;i<n.length;i++){const o=n[i];if(o&&u.startsWith(o.word))s.children=s.children||[],s.children.push({st:g(o.start),et:g(o.end),text:o.word}),u=u.substring(o.word.length);else if(o&&new RegExp(`^[\\s\\p{P}]*${o.word}`,"u").test(u)){s.children=s.children||[];const f=u.match(new RegExp(`^[\\s\\p{P}]*${o.word}`,"u"))[0];s.children.push({st:g(o.start),et:g(o.end),text:f}),u=u.substring(f.length)}else{c=i;break}}a++}return r}return r}else if(((t=e.words)==null?void 0:t.length)>=0){const r=e.words.map(n=>({st:g(n.start),et:g(n.end),text:n.word}));return[{st:g(e.words[0].start),et:g(e.words[e.words.length-1].end),text:e.text,children:r}]}else return[]}const ie={padding:[.4,0],maxGap:10,minGap:2,minStart:6};function Ft(e){let t,r,n,a,c,s,u,i,o;const f=!!(e&&e.vad&&e.vad.length>0),l="[--end--]",m="[--Single--]",T="[--Full--]",_=/\[(\d{2}:\d{2}:\d{2}\.\d{3}) --> (\d{2}:\d{2}:\d{2}\.\d{3})\]/;let y=!1,p=!1,b="";return S(),{feed:B,reset:S,end:N};function S(){t=!0,r="",n=!1,a="",c=!1,s=void 0,u=0,i=!1,o=0}function N(){if(i){console.log("whisper parser is already end");return}B(l)}function J(x){y||(b+=x),!y&&!p&&Ve(b)&&(p=!0),!y&&b.length>50&&(y=!0)}function B(x){var Te,_e,Se;J(x);const O=[];r+=x,t&&((Te=e==null?void 0:e.onStart)==null||Te.call(e,{type:"event",event:"start",data:[]})),t&&It(r)&&(r=r.slice(qe.length)),t=!1;const Y=r.length;for(;u<Y;){const X=r[u];if(++u,c&&s&&X!=="["&&(s.text+=X),X==="["&&(n&&a.length&&s&&(s.text+=a),a="",n=!0,c=!1),n){if(a+=X,a===T&&(a=""),a===m&&(a="",f&&o++),a===l){s&&O.push(s),i=!0;break}if(_.test(a)){const I=_.exec(a),D=I==null?void 0:I[1],ne=I==null?void 0:I[2];if(s&&O.push(s),D&&ne){if(f&&(e!=null&&e.vad)&&e.vad.length>0){let Z=0;Z=e.vad[o].start-ie.padding[0]<0?0:e.vad[o].start-ie.padding[0];const _t=D==="00:00:00.000";let je=g(A(D)+Z);o>0&&_t&&(je=g(A(D)+Z+ie.padding[0])),s={st:je,et:g(A(ne)+Z),text:"",children:[]}}else s={st:D,et:ne,text:"",children:[]};c=!0,n=!1,a=""}}}}O.length&&((_e=e==null?void 0:e.onParse)==null||_e.call(e,{type:"event",event:"message",data:O})),i&&((Se=e==null?void 0:e.onEnd)==null||Se.call(e,{type:"event",event:"end",data:r}),S())}}const qe=[239,187,191];function It(e){return qe.every((t,r)=>e.charCodeAt(r)===t)}function Lt(e){let t,r,n,a,c,s,u,i;const o=/\[(\d+)\]/,f="[--end--]";return l(),{feed:T,reset:l,end:m};function l(){t=!0,r="",n=0,i=!1,s="",a=void 0,c=!1,u=!1}function m(){T(f)}function T(_){var b,S,N,J,B;const y=[];r+=_,t&&((b=e==null?void 0:e.onStart)==null||b.call(e,{type:"event",event:"start",data:[]})),t&&Mt(r)&&(r=r.slice(Je.length)),t=!1;const p=r.length;for(;n<p;){const x=r[n];if(++n,u&&a&&x!=="["&&(a.text+=x,(S=e==null?void 0:e.onProgress)==null||S.call(e,{type:"event",event:"message",data:[a]})),x==="["&&(c&&s.length&&a&&(a.text+=s,(N=e==null?void 0:e.onProgress)==null||N.call(e,{type:"event",event:"message",data:[a]})),s="",c=!0,u=!1),c){if(s+=x,s===f){a&&y.push(a),i=!0;break}if(o.test(s)){const O=o.exec(s),Y=O==null?void 0:O[1];a&&y.push(a),Y&&(a={index:Number(Y),text:""},u=!0,c=!1,s="")}}}y.length&&((J=e==null?void 0:e.onParse)==null||J.call(e,{type:"event",event:"message",data:y})),i&&((B=e==null?void 0:e.onEnd)==null||B.call(e,{type:"event",event:"end",data:r}),l())}}const Je=[239,187,191];function Mt(e){return Je.every((t,r)=>e.charCodeAt(r)===t)}async function kt(e){return At(e,{keepMultiLine:!0,propName:{}}).filter(n=>n.text).map(n=>({st:g(n.start),et:g(n.end),text:n.text}))}async function Ye(e){return(await Pt(e)).filter(n=>n.part).map(n=>({st:g(n.start),et:g(n.end),text:n.part}))}async function zt(e){return Ye($t(e))}async function Nt(e){return Et(e)}async function Bt(e){return Ct(e)}const Dt=Object.freeze(Object.defineProperty({__proto__:null,assToAimSegments:zt,createTranslateStreamParser:Lt,createWhisperStreamParser:Ft,openaiToAimSegments:Bt,srtToAimSegments:kt,tingwuToAimSegments:Nt,vttToAimSegments:Ye},Symbol.toStringTag,{value:"Module"}));class Rt{constructor(t){v(this,"chains",{});v(this,"delimit","__replace__");v(this,"onFilter");v(this,"checked",!1);v(this,"checkedText","");v(this,"checkedLevel");v(this,"filteredText","");this.onFilter=t}add(t,r){typeof t!="string"&&(t=new TextDecoder().decode(t));const n=t;if(!n)return;let a=this.chains;for(let c=0;c<n.length;c++){if(n[c]in a)a=a[n[c]];else{if(!(a instanceof Object))break;let s,u;for(let i=c;i<n.length;i++)a[n[i]]={},[s,u]=[a,n[i]],a=a[n[i]];s&&u&&(s[u]={[this.delimit]:r||""});break}c===n.length-1&&(a[this.delimit]=r||"")}}parse(t){t.forEach(r=>{this.add(...r)})}reParse(t){this.chains={},t.forEach(r=>{this.add(r[0],r[1])})}feed(t){if(!this.checked&&!this.chains[t]){this.filteredText+=t,this.onFilter&&this.onFilter(t);return}if(!this.checked&&this.chains[t]){this.checked=!0,this.checkedLevel=this.chains[t],this.checkedText+=t;return}if(this.checked&&this.checkedLevel[t]){this.checkedLevel=this.checkedLevel[t],this.checkedText+=t;return}if(this.checked&&!this.checkedLevel[t]){const r=typeof this.checkedLevel[this.delimit]=="string"?this.checkedLevel[this.delimit]:this.checkedText;r&&r.length&&r.split("").forEach(n=>{this.filteredText+=n,this.onFilter&&this.onFilter(n)}),this.checked=!1,this.checkedText="",this.checkedLevel=void 0,this.chains[t]?(this.checked=!0,this.checkedLevel=this.chains[t],this.checkedText=t):(this.onFilter&&this.onFilter(t),this.filteredText+=t)}}feedAll(t){return t.length?(t.split("").forEach(n=>{this.feed(n)}),this.end()):""}end(){if(this.checked&&this.checkedText){const r=typeof this.checkedLevel[this.delimit]=="string"?this.checkedLevel[this.delimit]:this.checkedText;r&&r.length&&r.split("").forEach(n=>{this.onFilter&&this.onFilter(n),this.filteredText+=n}),this.checkedText="",this.checkedLevel=void 0,this.checked=!1}const t=this.filteredText;return this.filteredText="",t}}const Gt=Object.freeze(Object.defineProperty({__proto__:null,StreamFilter:Rt},Symbol.toStringTag,{value:"Module"}));var Xe=typeof global=="object"&&global&&global.Object===Object&&global,Ut=typeof self=="object"&&self&&self.Object===Object&&self,j=Xe||Ut||Function("return this")(),L=j.Symbol,Ze=Object.prototype,Ht=Ze.hasOwnProperty,Wt=Ze.toString,R=L?L.toStringTag:void 0;function Kt(e){var t=Ht.call(e,R),r=e[R];try{e[R]=void 0;var n=!0}catch{}var a=Wt.call(e);return n&&(t?e[R]=r:delete e[R]),a}var Vt=Object.prototype,qt=Vt.toString;function Jt(e){return qt.call(e)}var Yt="[object Null]",Xt="[object Undefined]",$e=L?L.toStringTag:void 0;function K(e){return e==null?e===void 0?Xt:Yt:$e&&$e in Object(e)?Kt(e):Jt(e)}function V(e){return e!=null&&typeof e=="object"}var de=Array.isArray;function q(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Zt="[object AsyncFunction]",Qt="[object Function]",er="[object GeneratorFunction]",tr="[object Proxy]";function Qe(e){if(!q(e))return!1;var t=K(e);return t==Qt||t==er||t==Zt||t==tr}var ce=j["__core-js_shared__"],we=function(){var e=/[^.]+$/.exec(ce&&ce.keys&&ce.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function rr(e){return!!we&&we in e}var nr=Function.prototype,ar=nr.toString;function C(e){if(e!=null){try{return ar.call(e)}catch{}try{return e+""}catch{}}return""}var sr=/[\\^$.*+?()[\]{}|]/g,ir=/^\[object .+?Constructor\]$/,cr=Function.prototype,or=Object.prototype,ur=cr.toString,fr=or.hasOwnProperty,lr=RegExp("^"+ur.call(fr).replace(sr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function hr(e){if(!q(e)||rr(e))return!1;var t=Qe(e)?lr:ir;return t.test(C(e))}function dr(e,t){return e==null?void 0:e[t]}function F(e,t){var r=dr(e,t);return hr(r)?r:void 0}var ue=F(j,"WeakMap"),Oe=Object.create,gr=function(){function e(){}return function(t){if(!q(t))return{};if(Oe)return Oe(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}();function pr(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}var Ae=function(){try{var e=F(Object,"defineProperty");return e({},"",{}),e}catch{}}();function br(e,t){for(var r=-1,n=e==null?0:e.length;++r<n&&t(e[r],r,e)!==!1;);return e}var yr=9007199254740991,vr=/^(?:0|[1-9]\d*)$/;function mr(e,t){var r=typeof e;return t=t??yr,!!t&&(r=="number"||r!="symbol"&&vr.test(e))&&e>-1&&e%1==0&&e<t}function et(e,t,r){t=="__proto__"&&Ae?Ae(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function tt(e,t){return e===t||e!==e&&t!==t}var Tr=Object.prototype,_r=Tr.hasOwnProperty;function rt(e,t,r){var n=e[t];(!(_r.call(e,t)&&tt(n,r))||r===void 0&&!(t in e))&&et(e,t,r)}function ee(e,t,r,n){var a=!r;r||(r={});for(var c=-1,s=t.length;++c<s;){var u=t[c],i=void 0;i===void 0&&(i=e[u]),a?et(r,u,i):rt(r,u,i)}return r}var Sr=9007199254740991;function nt(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Sr}function at(e){return e!=null&&nt(e.length)&&!Qe(e)}var jr=Object.prototype;function ge(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||jr;return e===r}function xr(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}var $r="[object Arguments]";function Pe(e){return V(e)&&K(e)==$r}var st=Object.prototype,wr=st.hasOwnProperty,Or=st.propertyIsEnumerable,Ar=Pe(function(){return arguments}())?Pe:function(e){return V(e)&&wr.call(e,"callee")&&!Or.call(e,"callee")};function Pr(){return!1}var it=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ee=it&&typeof module=="object"&&module&&!module.nodeType&&module,Er=Ee&&Ee.exports===it,Ce=Er?j.Buffer:void 0,Cr=Ce?Ce.isBuffer:void 0,ct=Cr||Pr,Fr="[object Arguments]",Ir="[object Array]",Lr="[object Boolean]",Mr="[object Date]",kr="[object Error]",zr="[object Function]",Nr="[object Map]",Br="[object Number]",Dr="[object Object]",Rr="[object RegExp]",Gr="[object Set]",Ur="[object String]",Hr="[object WeakMap]",Wr="[object ArrayBuffer]",Kr="[object DataView]",Vr="[object Float32Array]",qr="[object Float64Array]",Jr="[object Int8Array]",Yr="[object Int16Array]",Xr="[object Int32Array]",Zr="[object Uint8Array]",Qr="[object Uint8ClampedArray]",en="[object Uint16Array]",tn="[object Uint32Array]",d={};d[Vr]=d[qr]=d[Jr]=d[Yr]=d[Xr]=d[Zr]=d[Qr]=d[en]=d[tn]=!0;d[Fr]=d[Ir]=d[Wr]=d[Lr]=d[Kr]=d[Mr]=d[kr]=d[zr]=d[Nr]=d[Br]=d[Dr]=d[Rr]=d[Gr]=d[Ur]=d[Hr]=!1;function rn(e){return V(e)&&nt(e.length)&&!!d[K(e)]}function pe(e){return function(t){return e(t)}}var ot=typeof exports=="object"&&exports&&!exports.nodeType&&exports,U=ot&&typeof module=="object"&&module&&!module.nodeType&&module,nn=U&&U.exports===ot,oe=nn&&Xe.process,M=function(){try{var e=U&&U.require&&U.require("util").types;return e||oe&&oe.binding&&oe.binding("util")}catch{}}(),Fe=M&&M.isTypedArray,an=Fe?pe(Fe):rn,sn=Object.prototype,cn=sn.hasOwnProperty;function ut(e,t){var r=de(e),n=!r&&Ar(e),a=!r&&!n&&ct(e),c=!r&&!n&&!a&&an(e),s=r||n||a||c,u=s?xr(e.length,String):[],i=u.length;for(var o in e)(t||cn.call(e,o))&&!(s&&(o=="length"||a&&(o=="offset"||o=="parent")||c&&(o=="buffer"||o=="byteLength"||o=="byteOffset")||mr(o,i)))&&u.push(o);return u}function ft(e,t){return function(r){return e(t(r))}}var on=ft(Object.keys,Object),un=Object.prototype,fn=un.hasOwnProperty;function ln(e){if(!ge(e))return on(e);var t=[];for(var r in Object(e))fn.call(e,r)&&r!="constructor"&&t.push(r);return t}function be(e){return at(e)?ut(e):ln(e)}function hn(e){var t=[];if(e!=null)for(var r in Object(e))t.push(r);return t}var dn=Object.prototype,gn=dn.hasOwnProperty;function pn(e){if(!q(e))return hn(e);var t=ge(e),r=[];for(var n in e)n=="constructor"&&(t||!gn.call(e,n))||r.push(n);return r}function ye(e){return at(e)?ut(e,!0):pn(e)}var H=F(Object,"create");function bn(){this.__data__=H?H(null):{},this.size=0}function yn(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var vn="__lodash_hash_undefined__",mn=Object.prototype,Tn=mn.hasOwnProperty;function _n(e){var t=this.__data__;if(H){var r=t[e];return r===vn?void 0:r}return Tn.call(t,e)?t[e]:void 0}var Sn=Object.prototype,jn=Sn.hasOwnProperty;function xn(e){var t=this.__data__;return H?t[e]!==void 0:jn.call(t,e)}var $n="__lodash_hash_undefined__";function wn(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=H&&t===void 0?$n:t,this}function E(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}E.prototype.clear=bn;E.prototype.delete=yn;E.prototype.get=_n;E.prototype.has=xn;E.prototype.set=wn;function On(){this.__data__=[],this.size=0}function te(e,t){for(var r=e.length;r--;)if(tt(e[r][0],t))return r;return-1}var An=Array.prototype,Pn=An.splice;function En(e){var t=this.__data__,r=te(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():Pn.call(t,r,1),--this.size,!0}function Cn(e){var t=this.__data__,r=te(t,e);return r<0?void 0:t[r][1]}function Fn(e){return te(this.__data__,e)>-1}function In(e,t){var r=this.__data__,n=te(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}function w(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}w.prototype.clear=On;w.prototype.delete=En;w.prototype.get=Cn;w.prototype.has=Fn;w.prototype.set=In;var W=F(j,"Map");function Ln(){this.size=0,this.__data__={hash:new E,map:new(W||w),string:new E}}function Mn(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function re(e,t){var r=e.__data__;return Mn(t)?r[typeof t=="string"?"string":"hash"]:r.map}function kn(e){var t=re(this,e).delete(e);return this.size-=t?1:0,t}function zn(e){return re(this,e).get(e)}function Nn(e){return re(this,e).has(e)}function Bn(e,t){var r=re(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}function k(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}k.prototype.clear=Ln;k.prototype.delete=kn;k.prototype.get=zn;k.prototype.has=Nn;k.prototype.set=Bn;function lt(e,t){for(var r=-1,n=t.length,a=e.length;++r<n;)e[a+r]=t[r];return e}var ht=ft(Object.getPrototypeOf,Object);function Dn(){this.__data__=new w,this.size=0}function Rn(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}function Gn(e){return this.__data__.get(e)}function Un(e){return this.__data__.has(e)}var Hn=200;function Wn(e,t){var r=this.__data__;if(r instanceof w){var n=r.__data__;if(!W||n.length<Hn-1)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new k(n)}return r.set(e,t),this.size=r.size,this}function z(e){var t=this.__data__=new w(e);this.size=t.size}z.prototype.clear=Dn;z.prototype.delete=Rn;z.prototype.get=Gn;z.prototype.has=Un;z.prototype.set=Wn;function Kn(e,t){return e&&ee(t,be(t),e)}function Vn(e,t){return e&&ee(t,ye(t),e)}var dt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ie=dt&&typeof module=="object"&&module&&!module.nodeType&&module,qn=Ie&&Ie.exports===dt,Le=qn?j.Buffer:void 0,Me=Le?Le.allocUnsafe:void 0;function Jn(e,t){if(t)return e.slice();var r=e.length,n=Me?Me(r):new e.constructor(r);return e.copy(n),n}function Yn(e,t){for(var r=-1,n=e==null?0:e.length,a=0,c=[];++r<n;){var s=e[r];t(s,r,e)&&(c[a++]=s)}return c}function gt(){return[]}var Xn=Object.prototype,Zn=Xn.propertyIsEnumerable,ke=Object.getOwnPropertySymbols,ve=ke?function(e){return e==null?[]:(e=Object(e),Yn(ke(e),function(t){return Zn.call(e,t)}))}:gt;function Qn(e,t){return ee(e,ve(e),t)}var ea=Object.getOwnPropertySymbols,pt=ea?function(e){for(var t=[];e;)lt(t,ve(e)),e=ht(e);return t}:gt;function ta(e,t){return ee(e,pt(e),t)}function bt(e,t,r){var n=t(e);return de(e)?n:lt(n,r(e))}function ra(e){return bt(e,be,ve)}function na(e){return bt(e,ye,pt)}var fe=F(j,"DataView"),le=F(j,"Promise"),he=F(j,"Set"),ze="[object Map]",aa="[object Object]",Ne="[object Promise]",Be="[object Set]",De="[object WeakMap]",Re="[object DataView]",sa=C(fe),ia=C(W),ca=C(le),oa=C(he),ua=C(ue),$=K;(fe&&$(new fe(new ArrayBuffer(1)))!=Re||W&&$(new W)!=ze||le&&$(le.resolve())!=Ne||he&&$(new he)!=Be||ue&&$(new ue)!=De)&&($=function(e){var t=K(e),r=t==aa?e.constructor:void 0,n=r?C(r):"";if(n)switch(n){case sa:return Re;case ia:return ze;case ca:return Ne;case oa:return Be;case ua:return De}return t});var fa=Object.prototype,la=fa.hasOwnProperty;function ha(e){var t=e.length,r=new e.constructor(t);return t&&typeof e[0]=="string"&&la.call(e,"index")&&(r.index=e.index,r.input=e.input),r}var Ge=j.Uint8Array;function me(e){var t=new e.constructor(e.byteLength);return new Ge(t).set(new Ge(e)),t}function da(e,t){var r=t?me(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}var ga=/\w*$/;function pa(e){var t=new e.constructor(e.source,ga.exec(e));return t.lastIndex=e.lastIndex,t}var Ue=L?L.prototype:void 0,He=Ue?Ue.valueOf:void 0;function ba(e){return He?Object(He.call(e)):{}}function ya(e,t){var r=t?me(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}var va="[object Boolean]",ma="[object Date]",Ta="[object Map]",_a="[object Number]",Sa="[object RegExp]",ja="[object Set]",xa="[object String]",$a="[object Symbol]",wa="[object ArrayBuffer]",Oa="[object DataView]",Aa="[object Float32Array]",Pa="[object Float64Array]",Ea="[object Int8Array]",Ca="[object Int16Array]",Fa="[object Int32Array]",Ia="[object Uint8Array]",La="[object Uint8ClampedArray]",Ma="[object Uint16Array]",ka="[object Uint32Array]";function za(e,t,r){var n=e.constructor;switch(t){case wa:return me(e);case va:case ma:return new n(+e);case Oa:return da(e,r);case Aa:case Pa:case Ea:case Ca:case Fa:case Ia:case La:case Ma:case ka:return ya(e,r);case Ta:return new n;case _a:case xa:return new n(e);case Sa:return pa(e);case ja:return new n;case $a:return ba(e)}}function Na(e){return typeof e.constructor=="function"&&!ge(e)?gr(ht(e)):{}}var Ba="[object Map]";function Da(e){return V(e)&&$(e)==Ba}var We=M&&M.isMap,Ra=We?pe(We):Da,Ga="[object Set]";function Ua(e){return V(e)&&$(e)==Ga}var Ke=M&&M.isSet,Ha=Ke?pe(Ke):Ua,Wa=1,Ka=2,Va=4,yt="[object Arguments]",qa="[object Array]",Ja="[object Boolean]",Ya="[object Date]",Xa="[object Error]",vt="[object Function]",Za="[object GeneratorFunction]",Qa="[object Map]",es="[object Number]",mt="[object Object]",ts="[object RegExp]",rs="[object Set]",ns="[object String]",as="[object Symbol]",ss="[object WeakMap]",is="[object ArrayBuffer]",cs="[object DataView]",os="[object Float32Array]",us="[object Float64Array]",fs="[object Int8Array]",ls="[object Int16Array]",hs="[object Int32Array]",ds="[object Uint8Array]",gs="[object Uint8ClampedArray]",ps="[object Uint16Array]",bs="[object Uint32Array]",h={};h[yt]=h[qa]=h[is]=h[cs]=h[Ja]=h[Ya]=h[os]=h[us]=h[fs]=h[ls]=h[hs]=h[Qa]=h[es]=h[mt]=h[ts]=h[rs]=h[ns]=h[as]=h[ds]=h[gs]=h[ps]=h[bs]=!0;h[Xa]=h[vt]=h[ss]=!1;function Q(e,t,r,n,a,c){var s,u=t&Wa,i=t&Ka,o=t&Va;if(s!==void 0)return s;if(!q(e))return e;var f=de(e);if(f){if(s=ha(e),!u)return pr(e,s)}else{var l=$(e),m=l==vt||l==Za;if(ct(e))return Jn(e,u);if(l==mt||l==yt||m&&!a){if(s=i||m?{}:Na(e),!u)return i?ta(e,Vn(s,e)):Qn(e,Kn(s,e))}else{if(!h[l])return a?e:{};s=za(e,l,u)}}c||(c=new z);var T=c.get(e);if(T)return T;c.set(e,s),Ha(e)?e.forEach(function(p){s.add(Q(p,t,r,p,e,c))}):Ra(e)&&e.forEach(function(p,b){s.set(b,Q(p,t,r,b,e,c))});var _=o?i?na:ra:i?ye:be,y=f?void 0:_(e);return br(y||e,function(p,b){y&&(b=p,p=e[b]),rt(s,b,Q(p,t,r,b,e,c))}),s}var ys=1,vs=4;function ms(e){return Q(e,ys|vs)}class Tt{constructor(t){v(this,"threshold",2);v(this,"hit",0);v(this,"prevSegment");v(this,"hitSegment");v(this,"hitSegmentList",[]);v(this,"options");this.options=t||{}}push(t){var r,n;this.hitSegment&&this.hitSegment.text!==t.text&&(this.hitSegmentList.push(this.hitSegment),this.reset()),this.prevSegment&&t.text===this.prevSegment.text?(this.hit++,this.hit===1&&(this.hitSegment=ms(this.prevSegment)),this.threshold<=this.hit&&this.hitSegment&&(this.hitSegment.et=t.et,this.hitSegment.hit=this.hit,(n=(r=this.options).onHit)==null||n.call(r,this.hitSegmentList))):this.hit=0,this.prevSegment=t}end(){var t,r;this.hitSegment&&(this.hitSegmentList.push(this.hitSegment),(r=(t=this.options).onHit)==null||r.call(t,this.hitSegmentList)),this.reset()}reset(){this.hit=0,this.prevSegment=void 0,this.hitSegment=void 0}}const P={punc:/[.,?!\],。!?…]{1}/,em:/[.?!\]。!?…]{1}/,space:/^\s+|\s+$|\s{2,}/g,ep:/[.,?!,。!?…]{1}\s*$/};function Ts(e,t){let r=[];const n=new Tt({onHit:i=>{r=i}}),a=i=>i.trim().length===0,c=i=>{const o=A(i.st),f=A(i.et);return o>=f},s={emt:[],ep:[],zf:[],punc:[],em:[],space:[]},u=[];return e.forEach((i,o)=>{const f=P.punc.test(i.text),l=P.em.test(i.text),m=P.space.test(i.text),T=a(i.text),_=c(i),y=P.ep.test(i.text);n.push(i),i.punc=f?1:0,f&&s.punc.push(o),i.em=l?1:0,l&&s.em.push(o),i.space=m?1:0,m&&(t!=null&&t.space?i.text=i.text.replace(P.space," ").trim():s.space.push(o)),i.emt=a(i.text)?1:0,T&&(t!=null&&t.emt||s.emt.push(o)),i.zf=c(i)?1:0,_&&(t!=null&&t.zf||s.zf.push(o)),i.ep=y?1:0,y&&(t!=null&&t.ep?i.text=i.text.replace(P.ep,""):s.ep.push(o)),!(t!=null&&t.zf&&i.zf)&&(t!=null&&t.emt&&i.emt||u.push(i))}),n.end(),{result:s,repeat:r,segments:u}}const _s=Object.freeze(Object.defineProperty({__proto__:null,RepeatCheck:Tt,subtitleOptimization:Ts,subtitleOptimizationRegExp:P},Symbol.toStringTag,{value:"Module"}));exports.filter=Gt;exports.parser=Dt;exports.tools=_s;exports.utils=xt;
|
|
20
|
+
*/function wt(e,t){let r=t;for(;!e[r];)r++;return r}function Ot(e){let t=e.length-1;for(;t>=0&&!e[t];)t--;return t}function At(e="",t={propName:{}}){const r=[],n=e.split(/(?:\r\n|\r|\n)/gm).filter(o=>o.length>0),a=n.map((o,f)=>n[f+2]&&/\d{2}:\d{2}:\d{2}[,\.]\d{2,3}\s*-->\s*\d{2}:\d{2}:\d{2}[,\.]\d{2,3}/.test(n[f+2])?o+`\r
|
|
21
|
+
`:o).join(`
|
|
22
|
+
`).split(/(?:\r\n|\r|\n)/gm),c=Ot(a)+1;let s=0,u,i,l;for(let o=0;o<c;o++){for(l={},i=[],o=wt(a,o),l.id=parseInt(a[o++],10),u=a[o++].split(/[\t ]*-->[\t ]*/),l[t.propName.start||"start"]=t.timeInText?u[0]:A(u[0]),s=u[1].indexOf(" "),s!==-1&&(u[1]=u[1].substr(0,s)),l[t.propName.end||"end"]=t.timeInText?u[1]:A(u[1]);o<c&&a[o];)i.push(a[o++]);const f=t.propName.text||"text";l[f]=i.join(t.keepMultiLine?`
|
|
23
|
+
`:" ").replace(/\{(\\[\w]+\(?([\w\d]+,?)+\)?)+\}/gi,""),l[f]=l[f].replace(/</g,"<").replace(/>/g,">"),l[f]=l[f].replace(/<(\/?(font|b|u|i|s))((\s+(\w|\w[\w\-]*\w)(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)(\/?)>/gi,"<$1$3$7>"),t.ignoreLineBreaks?l[f]=l[f].replace(/\\N/gi,""):l[f]=l[f].replace(/\\N/gi,"<br />"),r.push(l)}return r}function Pt(e,t){const r=/<\/?[^>]+(>|$)/g;return new Promise((n,a)=>{let c={};const s=[];let u=!1;const i=e.split(`
|
|
24
|
+
`);i.forEach((o,f)=>{o.replace(r,"")===" "||o.replace(r,"")===""||(o.indexOf("-->")!==-1?(u=!0,typeof c.start=="number"&&c.start>=0&&s.push(se(c)),c={start:ae(o.split("-->")[0].trimRight().split(" ").pop()),end:ae(o.split("-->")[1].trimLeft().split(" ").shift()),part:""}):u&&(s.length!==0?(s[s.length-1].part.replace(r,""),o.replace(r,""),c.part.length===0?c.part=o:c.part=`${c.part}
|
|
25
|
+
${o}`,f===i.length-1&&s.push(se(c))):(c.part=o,s.push(se(c)),c.part="")))}),c=[];const l=/(<([0-9:.>]+)>)/ig;s.forEach(o=>{const _=o.part.split().map(function(p){return p.replace(l,function(b){return b.split("").reduce(function(S,N){return`==${b.replace("<","").replace(">","")}`},0)})})[0].replace(r,"").split(" "),y=[];_.forEach(function(p){if(p.indexOf("==")>-1){const b=p.split("=="),S=b[0];if(b[1],S==""||S=="##")return;y.push({word:xe(p.split("==")[0]),time:ae(p.split("==")[1])})}else y.push({word:xe(p),time:void 0})}),o.words=y,o.part=o.part.replace(r,"")}),n(s)})}function ae(e){const t=e.split(":"),r=t[t.length-3]?+t[t.length-3]:0,n=t[t.length-2]?+t[t.length-2]:0,a=+t[t.length-1];return r*3600+n*60+a}function xe(e){return e.replace(/[^0-9a-z'-]/gi,"").toLowerCase()}function se(e){if(e==null||typeof e!="object")return e;const t=e.constructor();for(const r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t}function Et(e){return e.Transcription.Paragraphs.map(t=>{const r=t.Words.map(n=>({st:g(n.Start/1e3),et:g(n.End/1e3),text:n.Text,spk:t.SpeakerId}));return{st:g(t.Words[0].Start/1e3),et:g(t.Words[t.Words.length-1].End/1e3),text:r.map(n=>n.text).join(""),spk:t.SpeakerId,children:r}})}function Ct(e){var t,r;if(e.segments){const n=e.segments.map(a=>({st:g(a.start),et:g(a.end),text:a.text}));if(e.words.length>0){const a=e.words;let c=0,s=0;for(;c<n.length;){const u=n[c];let i=u.text;for(let l=s;l<a.length;l++){const o=a[l];if(o&&i.startsWith(o.word))u.children=u.children||[],u.children.push({st:g(o.start),et:g(o.end),text:o.word}),i=i.substring(o.word.length);else if(o&&new RegExp(`^[\\s\\p{P}]*${o.word}`,"u").test(i)){u.children=u.children||[];const f=i.match(new RegExp(`^[\\s\\p{P}]*${o.word}`,"u"))[0];if(/^[,.?…,。?!!]/u.test(f)){const m=((t=f.match(/^[,.?…,。?!!]+/u))==null?void 0:t[0])||"",T=f.substring(m.length);if(u.children.length>0){const _=u.children[u.children.length-1];_.text+=m}u.children.push({st:g(o.start),et:g(o.end),text:T})}else u.children.push({st:g(o.start),et:g(o.end),text:f});i=i.substring(f.length)}else{s=l;break}}c++}return n}return n}else if(((r=e.words)==null?void 0:r.length)>=0){const n=e.words.map(a=>({st:g(a.start),et:g(a.end),text:a.word}));return[{st:g(e.words[0].start),et:g(e.words[e.words.length-1].end),text:e.text,children:n}]}else return[]}const ie={padding:[.4,0],maxGap:10,minGap:2,minStart:6};function Ft(e){let t,r,n,a,c,s,u,i,l;const o=!!(e&&e.vad&&e.vad.length>0),f="[--end--]",m="[--Single--]",T="[--Full--]",_=/\[(\d{2}:\d{2}:\d{2}\.\d{3}) --> (\d{2}:\d{2}:\d{2}\.\d{3})\]/;let y=!1,p=!1,b="";return S(),{feed:B,reset:S,end:N};function S(){t=!0,r="",n=!1,a="",c=!1,s=void 0,u=0,i=!1,l=0}function N(){if(i){console.log("whisper parser is already end");return}B(f)}function J(x){y||(b+=x),!y&&!p&&Ve(b)&&(p=!0),!y&&b.length>50&&(y=!0)}function B(x){var Te,_e,Se;J(x);const O=[];r+=x,t&&((Te=e==null?void 0:e.onStart)==null||Te.call(e,{type:"event",event:"start",data:[]})),t&&It(r)&&(r=r.slice(qe.length)),t=!1;const Y=r.length;for(;u<Y;){const X=r[u];if(++u,c&&s&&X!=="["&&(s.text+=X),X==="["&&(n&&a.length&&s&&(s.text+=a),a="",n=!0,c=!1),n){if(a+=X,a===T&&(a=""),a===m&&(a="",o&&l++),a===f){s&&O.push(s),i=!0;break}if(_.test(a)){const I=_.exec(a),D=I==null?void 0:I[1],ne=I==null?void 0:I[2];if(s&&O.push(s),D&&ne){if(o&&(e!=null&&e.vad)&&e.vad.length>0){let Z=0;Z=e.vad[l].start-ie.padding[0]<0?0:e.vad[l].start-ie.padding[0];const _t=D==="00:00:00.000";let je=g(A(D)+Z);l>0&&_t&&(je=g(A(D)+Z+ie.padding[0])),s={st:je,et:g(A(ne)+Z),text:"",children:[]}}else s={st:D,et:ne,text:"",children:[]};c=!0,n=!1,a=""}}}}O.length&&((_e=e==null?void 0:e.onParse)==null||_e.call(e,{type:"event",event:"message",data:O})),i&&((Se=e==null?void 0:e.onEnd)==null||Se.call(e,{type:"event",event:"end",data:r}),S())}}const qe=[239,187,191];function It(e){return qe.every((t,r)=>e.charCodeAt(r)===t)}function Lt(e){let t,r,n,a,c,s,u,i;const l=/\[(\d+)\]/,o="[--end--]";return f(),{feed:T,reset:f,end:m};function f(){t=!0,r="",n=0,i=!1,s="",a=void 0,c=!1,u=!1}function m(){T(o)}function T(_){var b,S,N,J,B;const y=[];r+=_,t&&((b=e==null?void 0:e.onStart)==null||b.call(e,{type:"event",event:"start",data:[]})),t&&Mt(r)&&(r=r.slice(Je.length)),t=!1;const p=r.length;for(;n<p;){const x=r[n];if(++n,u&&a&&x!=="["&&(a.text+=x,(S=e==null?void 0:e.onProgress)==null||S.call(e,{type:"event",event:"message",data:[a]})),x==="["&&(c&&s.length&&a&&(a.text+=s,(N=e==null?void 0:e.onProgress)==null||N.call(e,{type:"event",event:"message",data:[a]})),s="",c=!0,u=!1),c){if(s+=x,s===o){a&&y.push(a),i=!0;break}if(l.test(s)){const O=l.exec(s),Y=O==null?void 0:O[1];a&&y.push(a),Y&&(a={index:Number(Y),text:""},u=!0,c=!1,s="")}}}y.length&&((J=e==null?void 0:e.onParse)==null||J.call(e,{type:"event",event:"message",data:y})),i&&((B=e==null?void 0:e.onEnd)==null||B.call(e,{type:"event",event:"end",data:r}),f())}}const Je=[239,187,191];function Mt(e){return Je.every((t,r)=>e.charCodeAt(r)===t)}async function kt(e){return At(e,{keepMultiLine:!0,propName:{}}).filter(n=>n.text).map(n=>({st:g(n.start),et:g(n.end),text:n.text}))}async function Ye(e){return(await Pt(e)).filter(n=>n.part).map(n=>({st:g(n.start),et:g(n.end),text:n.part}))}async function zt(e){return Ye($t(e))}async function Nt(e){return Et(e)}async function Bt(e){return Ct(e)}const Dt=Object.freeze(Object.defineProperty({__proto__:null,assToAimSegments:zt,createTranslateStreamParser:Lt,createWhisperStreamParser:Ft,openaiToAimSegments:Bt,srtToAimSegments:kt,tingwuToAimSegments:Nt,vttToAimSegments:Ye},Symbol.toStringTag,{value:"Module"}));class Rt{constructor(t){v(this,"chains",{});v(this,"delimit","__replace__");v(this,"onFilter");v(this,"checked",!1);v(this,"checkedText","");v(this,"checkedLevel");v(this,"filteredText","");this.onFilter=t}add(t,r){typeof t!="string"&&(t=new TextDecoder().decode(t));const n=t;if(!n)return;let a=this.chains;for(let c=0;c<n.length;c++){if(n[c]in a)a=a[n[c]];else{if(!(a instanceof Object))break;let s,u;for(let i=c;i<n.length;i++)a[n[i]]={},[s,u]=[a,n[i]],a=a[n[i]];s&&u&&(s[u]={[this.delimit]:r||""});break}c===n.length-1&&(a[this.delimit]=r||"")}}parse(t){t.forEach(r=>{this.add(...r)})}reParse(t){this.chains={},t.forEach(r=>{this.add(r[0],r[1])})}feed(t){if(!this.checked&&!this.chains[t]){this.filteredText+=t,this.onFilter&&this.onFilter(t);return}if(!this.checked&&this.chains[t]){this.checked=!0,this.checkedLevel=this.chains[t],this.checkedText+=t;return}if(this.checked&&this.checkedLevel[t]){this.checkedLevel=this.checkedLevel[t],this.checkedText+=t;return}if(this.checked&&!this.checkedLevel[t]){const r=typeof this.checkedLevel[this.delimit]=="string"?this.checkedLevel[this.delimit]:this.checkedText;r&&r.length&&r.split("").forEach(n=>{this.filteredText+=n,this.onFilter&&this.onFilter(n)}),this.checked=!1,this.checkedText="",this.checkedLevel=void 0,this.chains[t]?(this.checked=!0,this.checkedLevel=this.chains[t],this.checkedText=t):(this.onFilter&&this.onFilter(t),this.filteredText+=t)}}feedAll(t){return t.length?(t.split("").forEach(n=>{this.feed(n)}),this.end()):""}end(){if(this.checked&&this.checkedText){const r=typeof this.checkedLevel[this.delimit]=="string"?this.checkedLevel[this.delimit]:this.checkedText;r&&r.length&&r.split("").forEach(n=>{this.onFilter&&this.onFilter(n),this.filteredText+=n}),this.checkedText="",this.checkedLevel=void 0,this.checked=!1}const t=this.filteredText;return this.filteredText="",t}}const Gt=Object.freeze(Object.defineProperty({__proto__:null,StreamFilter:Rt},Symbol.toStringTag,{value:"Module"}));var Xe=typeof global=="object"&&global&&global.Object===Object&&global,Ut=typeof self=="object"&&self&&self.Object===Object&&self,j=Xe||Ut||Function("return this")(),L=j.Symbol,Ze=Object.prototype,Ht=Ze.hasOwnProperty,Wt=Ze.toString,R=L?L.toStringTag:void 0;function Kt(e){var t=Ht.call(e,R),r=e[R];try{e[R]=void 0;var n=!0}catch{}var a=Wt.call(e);return n&&(t?e[R]=r:delete e[R]),a}var Vt=Object.prototype,qt=Vt.toString;function Jt(e){return qt.call(e)}var Yt="[object Null]",Xt="[object Undefined]",$e=L?L.toStringTag:void 0;function K(e){return e==null?e===void 0?Xt:Yt:$e&&$e in Object(e)?Kt(e):Jt(e)}function V(e){return e!=null&&typeof e=="object"}var de=Array.isArray;function q(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var Zt="[object AsyncFunction]",Qt="[object Function]",er="[object GeneratorFunction]",tr="[object Proxy]";function Qe(e){if(!q(e))return!1;var t=K(e);return t==Qt||t==er||t==Zt||t==tr}var ce=j["__core-js_shared__"],we=function(){var e=/[^.]+$/.exec(ce&&ce.keys&&ce.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function rr(e){return!!we&&we in e}var nr=Function.prototype,ar=nr.toString;function C(e){if(e!=null){try{return ar.call(e)}catch{}try{return e+""}catch{}}return""}var sr=/[\\^$.*+?()[\]{}|]/g,ir=/^\[object .+?Constructor\]$/,cr=Function.prototype,or=Object.prototype,ur=cr.toString,lr=or.hasOwnProperty,fr=RegExp("^"+ur.call(lr).replace(sr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function hr(e){if(!q(e)||rr(e))return!1;var t=Qe(e)?fr:ir;return t.test(C(e))}function dr(e,t){return e==null?void 0:e[t]}function F(e,t){var r=dr(e,t);return hr(r)?r:void 0}var ue=F(j,"WeakMap"),Oe=Object.create,gr=function(){function e(){}return function(t){if(!q(t))return{};if(Oe)return Oe(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}();function pr(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t}var Ae=function(){try{var e=F(Object,"defineProperty");return e({},"",{}),e}catch{}}();function br(e,t){for(var r=-1,n=e==null?0:e.length;++r<n&&t(e[r],r,e)!==!1;);return e}var yr=9007199254740991,vr=/^(?:0|[1-9]\d*)$/;function mr(e,t){var r=typeof e;return t=t??yr,!!t&&(r=="number"||r!="symbol"&&vr.test(e))&&e>-1&&e%1==0&&e<t}function et(e,t,r){t=="__proto__"&&Ae?Ae(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function tt(e,t){return e===t||e!==e&&t!==t}var Tr=Object.prototype,_r=Tr.hasOwnProperty;function rt(e,t,r){var n=e[t];(!(_r.call(e,t)&&tt(n,r))||r===void 0&&!(t in e))&&et(e,t,r)}function ee(e,t,r,n){var a=!r;r||(r={});for(var c=-1,s=t.length;++c<s;){var u=t[c],i=void 0;i===void 0&&(i=e[u]),a?et(r,u,i):rt(r,u,i)}return r}var Sr=9007199254740991;function nt(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Sr}function at(e){return e!=null&&nt(e.length)&&!Qe(e)}var jr=Object.prototype;function ge(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||jr;return e===r}function xr(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}var $r="[object Arguments]";function Pe(e){return V(e)&&K(e)==$r}var st=Object.prototype,wr=st.hasOwnProperty,Or=st.propertyIsEnumerable,Ar=Pe(function(){return arguments}())?Pe:function(e){return V(e)&&wr.call(e,"callee")&&!Or.call(e,"callee")};function Pr(){return!1}var it=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ee=it&&typeof module=="object"&&module&&!module.nodeType&&module,Er=Ee&&Ee.exports===it,Ce=Er?j.Buffer:void 0,Cr=Ce?Ce.isBuffer:void 0,ct=Cr||Pr,Fr="[object Arguments]",Ir="[object Array]",Lr="[object Boolean]",Mr="[object Date]",kr="[object Error]",zr="[object Function]",Nr="[object Map]",Br="[object Number]",Dr="[object Object]",Rr="[object RegExp]",Gr="[object Set]",Ur="[object String]",Hr="[object WeakMap]",Wr="[object ArrayBuffer]",Kr="[object DataView]",Vr="[object Float32Array]",qr="[object Float64Array]",Jr="[object Int8Array]",Yr="[object Int16Array]",Xr="[object Int32Array]",Zr="[object Uint8Array]",Qr="[object Uint8ClampedArray]",en="[object Uint16Array]",tn="[object Uint32Array]",d={};d[Vr]=d[qr]=d[Jr]=d[Yr]=d[Xr]=d[Zr]=d[Qr]=d[en]=d[tn]=!0;d[Fr]=d[Ir]=d[Wr]=d[Lr]=d[Kr]=d[Mr]=d[kr]=d[zr]=d[Nr]=d[Br]=d[Dr]=d[Rr]=d[Gr]=d[Ur]=d[Hr]=!1;function rn(e){return V(e)&&nt(e.length)&&!!d[K(e)]}function pe(e){return function(t){return e(t)}}var ot=typeof exports=="object"&&exports&&!exports.nodeType&&exports,U=ot&&typeof module=="object"&&module&&!module.nodeType&&module,nn=U&&U.exports===ot,oe=nn&&Xe.process,M=function(){try{var e=U&&U.require&&U.require("util").types;return e||oe&&oe.binding&&oe.binding("util")}catch{}}(),Fe=M&&M.isTypedArray,an=Fe?pe(Fe):rn,sn=Object.prototype,cn=sn.hasOwnProperty;function ut(e,t){var r=de(e),n=!r&&Ar(e),a=!r&&!n&&ct(e),c=!r&&!n&&!a&&an(e),s=r||n||a||c,u=s?xr(e.length,String):[],i=u.length;for(var l in e)(t||cn.call(e,l))&&!(s&&(l=="length"||a&&(l=="offset"||l=="parent")||c&&(l=="buffer"||l=="byteLength"||l=="byteOffset")||mr(l,i)))&&u.push(l);return u}function lt(e,t){return function(r){return e(t(r))}}var on=lt(Object.keys,Object),un=Object.prototype,ln=un.hasOwnProperty;function fn(e){if(!ge(e))return on(e);var t=[];for(var r in Object(e))ln.call(e,r)&&r!="constructor"&&t.push(r);return t}function be(e){return at(e)?ut(e):fn(e)}function hn(e){var t=[];if(e!=null)for(var r in Object(e))t.push(r);return t}var dn=Object.prototype,gn=dn.hasOwnProperty;function pn(e){if(!q(e))return hn(e);var t=ge(e),r=[];for(var n in e)n=="constructor"&&(t||!gn.call(e,n))||r.push(n);return r}function ye(e){return at(e)?ut(e,!0):pn(e)}var H=F(Object,"create");function bn(){this.__data__=H?H(null):{},this.size=0}function yn(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var vn="__lodash_hash_undefined__",mn=Object.prototype,Tn=mn.hasOwnProperty;function _n(e){var t=this.__data__;if(H){var r=t[e];return r===vn?void 0:r}return Tn.call(t,e)?t[e]:void 0}var Sn=Object.prototype,jn=Sn.hasOwnProperty;function xn(e){var t=this.__data__;return H?t[e]!==void 0:jn.call(t,e)}var $n="__lodash_hash_undefined__";function wn(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=H&&t===void 0?$n:t,this}function E(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}E.prototype.clear=bn;E.prototype.delete=yn;E.prototype.get=_n;E.prototype.has=xn;E.prototype.set=wn;function On(){this.__data__=[],this.size=0}function te(e,t){for(var r=e.length;r--;)if(tt(e[r][0],t))return r;return-1}var An=Array.prototype,Pn=An.splice;function En(e){var t=this.__data__,r=te(t,e);if(r<0)return!1;var n=t.length-1;return r==n?t.pop():Pn.call(t,r,1),--this.size,!0}function Cn(e){var t=this.__data__,r=te(t,e);return r<0?void 0:t[r][1]}function Fn(e){return te(this.__data__,e)>-1}function In(e,t){var r=this.__data__,n=te(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}function w(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}w.prototype.clear=On;w.prototype.delete=En;w.prototype.get=Cn;w.prototype.has=Fn;w.prototype.set=In;var W=F(j,"Map");function Ln(){this.size=0,this.__data__={hash:new E,map:new(W||w),string:new E}}function Mn(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function re(e,t){var r=e.__data__;return Mn(t)?r[typeof t=="string"?"string":"hash"]:r.map}function kn(e){var t=re(this,e).delete(e);return this.size-=t?1:0,t}function zn(e){return re(this,e).get(e)}function Nn(e){return re(this,e).has(e)}function Bn(e,t){var r=re(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}function k(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}k.prototype.clear=Ln;k.prototype.delete=kn;k.prototype.get=zn;k.prototype.has=Nn;k.prototype.set=Bn;function ft(e,t){for(var r=-1,n=t.length,a=e.length;++r<n;)e[a+r]=t[r];return e}var ht=lt(Object.getPrototypeOf,Object);function Dn(){this.__data__=new w,this.size=0}function Rn(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}function Gn(e){return this.__data__.get(e)}function Un(e){return this.__data__.has(e)}var Hn=200;function Wn(e,t){var r=this.__data__;if(r instanceof w){var n=r.__data__;if(!W||n.length<Hn-1)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new k(n)}return r.set(e,t),this.size=r.size,this}function z(e){var t=this.__data__=new w(e);this.size=t.size}z.prototype.clear=Dn;z.prototype.delete=Rn;z.prototype.get=Gn;z.prototype.has=Un;z.prototype.set=Wn;function Kn(e,t){return e&&ee(t,be(t),e)}function Vn(e,t){return e&&ee(t,ye(t),e)}var dt=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ie=dt&&typeof module=="object"&&module&&!module.nodeType&&module,qn=Ie&&Ie.exports===dt,Le=qn?j.Buffer:void 0,Me=Le?Le.allocUnsafe:void 0;function Jn(e,t){if(t)return e.slice();var r=e.length,n=Me?Me(r):new e.constructor(r);return e.copy(n),n}function Yn(e,t){for(var r=-1,n=e==null?0:e.length,a=0,c=[];++r<n;){var s=e[r];t(s,r,e)&&(c[a++]=s)}return c}function gt(){return[]}var Xn=Object.prototype,Zn=Xn.propertyIsEnumerable,ke=Object.getOwnPropertySymbols,ve=ke?function(e){return e==null?[]:(e=Object(e),Yn(ke(e),function(t){return Zn.call(e,t)}))}:gt;function Qn(e,t){return ee(e,ve(e),t)}var ea=Object.getOwnPropertySymbols,pt=ea?function(e){for(var t=[];e;)ft(t,ve(e)),e=ht(e);return t}:gt;function ta(e,t){return ee(e,pt(e),t)}function bt(e,t,r){var n=t(e);return de(e)?n:ft(n,r(e))}function ra(e){return bt(e,be,ve)}function na(e){return bt(e,ye,pt)}var le=F(j,"DataView"),fe=F(j,"Promise"),he=F(j,"Set"),ze="[object Map]",aa="[object Object]",Ne="[object Promise]",Be="[object Set]",De="[object WeakMap]",Re="[object DataView]",sa=C(le),ia=C(W),ca=C(fe),oa=C(he),ua=C(ue),$=K;(le&&$(new le(new ArrayBuffer(1)))!=Re||W&&$(new W)!=ze||fe&&$(fe.resolve())!=Ne||he&&$(new he)!=Be||ue&&$(new ue)!=De)&&($=function(e){var t=K(e),r=t==aa?e.constructor:void 0,n=r?C(r):"";if(n)switch(n){case sa:return Re;case ia:return ze;case ca:return Ne;case oa:return Be;case ua:return De}return t});var la=Object.prototype,fa=la.hasOwnProperty;function ha(e){var t=e.length,r=new e.constructor(t);return t&&typeof e[0]=="string"&&fa.call(e,"index")&&(r.index=e.index,r.input=e.input),r}var Ge=j.Uint8Array;function me(e){var t=new e.constructor(e.byteLength);return new Ge(t).set(new Ge(e)),t}function da(e,t){var r=t?me(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}var ga=/\w*$/;function pa(e){var t=new e.constructor(e.source,ga.exec(e));return t.lastIndex=e.lastIndex,t}var Ue=L?L.prototype:void 0,He=Ue?Ue.valueOf:void 0;function ba(e){return He?Object(He.call(e)):{}}function ya(e,t){var r=t?me(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}var va="[object Boolean]",ma="[object Date]",Ta="[object Map]",_a="[object Number]",Sa="[object RegExp]",ja="[object Set]",xa="[object String]",$a="[object Symbol]",wa="[object ArrayBuffer]",Oa="[object DataView]",Aa="[object Float32Array]",Pa="[object Float64Array]",Ea="[object Int8Array]",Ca="[object Int16Array]",Fa="[object Int32Array]",Ia="[object Uint8Array]",La="[object Uint8ClampedArray]",Ma="[object Uint16Array]",ka="[object Uint32Array]";function za(e,t,r){var n=e.constructor;switch(t){case wa:return me(e);case va:case ma:return new n(+e);case Oa:return da(e,r);case Aa:case Pa:case Ea:case Ca:case Fa:case Ia:case La:case Ma:case ka:return ya(e,r);case Ta:return new n;case _a:case xa:return new n(e);case Sa:return pa(e);case ja:return new n;case $a:return ba(e)}}function Na(e){return typeof e.constructor=="function"&&!ge(e)?gr(ht(e)):{}}var Ba="[object Map]";function Da(e){return V(e)&&$(e)==Ba}var We=M&&M.isMap,Ra=We?pe(We):Da,Ga="[object Set]";function Ua(e){return V(e)&&$(e)==Ga}var Ke=M&&M.isSet,Ha=Ke?pe(Ke):Ua,Wa=1,Ka=2,Va=4,yt="[object Arguments]",qa="[object Array]",Ja="[object Boolean]",Ya="[object Date]",Xa="[object Error]",vt="[object Function]",Za="[object GeneratorFunction]",Qa="[object Map]",es="[object Number]",mt="[object Object]",ts="[object RegExp]",rs="[object Set]",ns="[object String]",as="[object Symbol]",ss="[object WeakMap]",is="[object ArrayBuffer]",cs="[object DataView]",os="[object Float32Array]",us="[object Float64Array]",ls="[object Int8Array]",fs="[object Int16Array]",hs="[object Int32Array]",ds="[object Uint8Array]",gs="[object Uint8ClampedArray]",ps="[object Uint16Array]",bs="[object Uint32Array]",h={};h[yt]=h[qa]=h[is]=h[cs]=h[Ja]=h[Ya]=h[os]=h[us]=h[ls]=h[fs]=h[hs]=h[Qa]=h[es]=h[mt]=h[ts]=h[rs]=h[ns]=h[as]=h[ds]=h[gs]=h[ps]=h[bs]=!0;h[Xa]=h[vt]=h[ss]=!1;function Q(e,t,r,n,a,c){var s,u=t&Wa,i=t&Ka,l=t&Va;if(s!==void 0)return s;if(!q(e))return e;var o=de(e);if(o){if(s=ha(e),!u)return pr(e,s)}else{var f=$(e),m=f==vt||f==Za;if(ct(e))return Jn(e,u);if(f==mt||f==yt||m&&!a){if(s=i||m?{}:Na(e),!u)return i?ta(e,Vn(s,e)):Qn(e,Kn(s,e))}else{if(!h[f])return a?e:{};s=za(e,f,u)}}c||(c=new z);var T=c.get(e);if(T)return T;c.set(e,s),Ha(e)?e.forEach(function(p){s.add(Q(p,t,r,p,e,c))}):Ra(e)&&e.forEach(function(p,b){s.set(b,Q(p,t,r,b,e,c))});var _=l?i?na:ra:i?ye:be,y=o?void 0:_(e);return br(y||e,function(p,b){y&&(b=p,p=e[b]),rt(s,b,Q(p,t,r,b,e,c))}),s}var ys=1,vs=4;function ms(e){return Q(e,ys|vs)}class Tt{constructor(t){v(this,"threshold",2);v(this,"hit",0);v(this,"prevSegment");v(this,"hitSegment");v(this,"hitSegmentList",[]);v(this,"options");this.options=t||{}}push(t){var r,n;this.hitSegment&&this.hitSegment.text!==t.text&&(this.hitSegmentList.push(this.hitSegment),this.reset()),this.prevSegment&&t.text===this.prevSegment.text?(this.hit++,this.hit===1&&(this.hitSegment=ms(this.prevSegment)),this.threshold<=this.hit&&this.hitSegment&&(this.hitSegment.et=t.et,this.hitSegment.hit=this.hit,(n=(r=this.options).onHit)==null||n.call(r,this.hitSegmentList))):this.hit=0,this.prevSegment=t}end(){var t,r;this.hitSegment&&(this.hitSegmentList.push(this.hitSegment),(r=(t=this.options).onHit)==null||r.call(t,this.hitSegmentList)),this.reset()}reset(){this.hit=0,this.prevSegment=void 0,this.hitSegment=void 0}}const P={punc:/[.,?!\],。!?…]{1}/,em:/[.?!\]。!?…]{1}/,space:/^\s+|\s+$|\s{2,}/g,ep:/[.,?!,。!?…]{1}\s*$/};function Ts(e,t){let r=[];const n=new Tt({onHit:i=>{r=i}}),a=i=>i.trim().length===0,c=i=>{const l=A(i.st),o=A(i.et);return l>=o},s={emt:[],ep:[],zf:[],punc:[],em:[],space:[]},u=[];return e.forEach((i,l)=>{const o=P.punc.test(i.text),f=P.em.test(i.text),m=P.space.test(i.text),T=a(i.text),_=c(i),y=P.ep.test(i.text);n.push(i),i.punc=o?1:0,o&&s.punc.push(l),i.em=f?1:0,f&&s.em.push(l),i.space=m?1:0,m&&(t!=null&&t.space?i.text=i.text.replace(P.space," ").trim():s.space.push(l)),i.emt=a(i.text)?1:0,T&&(t!=null&&t.emt||s.emt.push(l)),i.zf=c(i)?1:0,_&&(t!=null&&t.zf||s.zf.push(l)),i.ep=y?1:0,y&&(t!=null&&t.ep?i.text=i.text.replace(P.ep,""):s.ep.push(l)),!(t!=null&&t.zf&&i.zf)&&(t!=null&&t.emt&&i.emt||u.push(i))}),n.end(),{result:s,repeat:r,segments:u}}const _s=Object.freeze(Object.defineProperty({__proto__:null,RepeatCheck:Tt,subtitleOptimization:Ts,subtitleOptimizationRegExp:P},Symbol.toStringTag,{value:"Module"}));exports.filter=Gt;exports.parser=Dt;exports.tools=_s;exports.utils=xt;
|
package/dist/index.es.js
CHANGED
|
@@ -89,16 +89,16 @@ function wt(e) {
|
|
|
89
89
|
return t;
|
|
90
90
|
}
|
|
91
91
|
function Ot(e = "", t = { propName: {} }) {
|
|
92
|
-
const r = [], n = e.split(/(?:\r\n|\r|\n)/gm).filter((
|
|
93
|
-
` :
|
|
92
|
+
const r = [], n = e.split(/(?:\r\n|\r|\n)/gm).filter((o) => o.length > 0), a = n.map((o, f) => n[f + 2] && /\d{2}:\d{2}:\d{2}[,\.]\d{2,3}\s*-->\s*\d{2}:\d{2}:\d{2}[,\.]\d{2,3}/.test(n[f + 2]) ? o + `\r
|
|
93
|
+
` : o).join(`
|
|
94
94
|
`).split(/(?:\r\n|\r|\n)/gm), c = wt(a) + 1;
|
|
95
|
-
let s = 0, u, i,
|
|
96
|
-
for (let
|
|
97
|
-
for (
|
|
98
|
-
i.push(a[
|
|
95
|
+
let s = 0, u, i, l;
|
|
96
|
+
for (let o = 0; o < c; o++) {
|
|
97
|
+
for (l = {}, i = [], o = $t(a, o), l.id = parseInt(a[o++], 10), u = a[o++].split(/[\t ]*-->[\t ]*/), l[t.propName.start || "start"] = t.timeInText ? u[0] : A(u[0]), s = u[1].indexOf(" "), s !== -1 && (u[1] = u[1].substr(0, s)), l[t.propName.end || "end"] = t.timeInText ? u[1] : A(u[1]); o < c && a[o]; )
|
|
98
|
+
i.push(a[o++]);
|
|
99
99
|
const f = t.propName.text || "text";
|
|
100
|
-
|
|
101
|
-
` : " ").replace(/\{(\\[\w]+\(?([\w\d]+,?)+\)?)+\}/gi, ""),
|
|
100
|
+
l[f] = i.join(t.keepMultiLine ? `
|
|
101
|
+
` : " ").replace(/\{(\\[\w]+\(?([\w\d]+,?)+\)?)+\}/gi, ""), l[f] = l[f].replace(/</g, "<").replace(/>/g, ">"), l[f] = l[f].replace(/<(\/?(font|b|u|i|s))((\s+(\w|\w[\w\-]*\w)(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)(\/?)>/gi, "<$1$3$7>"), t.ignoreLineBreaks ? l[f] = l[f].replace(/\\N/gi, "") : l[f] = l[f].replace(/\\N/gi, "<br />"), r.push(l);
|
|
102
102
|
}
|
|
103
103
|
return r;
|
|
104
104
|
}
|
|
@@ -110,18 +110,18 @@ function At(e, t) {
|
|
|
110
110
|
let u = !1;
|
|
111
111
|
const i = e.split(`
|
|
112
112
|
`);
|
|
113
|
-
i.forEach((
|
|
114
|
-
|
|
115
|
-
start: ae(
|
|
116
|
-
end: ae(
|
|
113
|
+
i.forEach((o, f) => {
|
|
114
|
+
o.replace(r, "") === " " || o.replace(r, "") === "" || (o.indexOf("-->") !== -1 ? (u = !0, typeof c.start == "number" && c.start >= 0 && s.push(se(c)), c = {
|
|
115
|
+
start: ae(o.split("-->")[0].trimRight().split(" ").pop()),
|
|
116
|
+
end: ae(o.split("-->")[1].trimLeft().split(" ").shift()),
|
|
117
117
|
part: ""
|
|
118
|
-
}) : u && (s.length !== 0 ? (s[s.length - 1].part.replace(r, ""),
|
|
119
|
-
${
|
|
118
|
+
}) : u && (s.length !== 0 ? (s[s.length - 1].part.replace(r, ""), o.replace(r, ""), c.part.length === 0 ? c.part = o : c.part = `${c.part}
|
|
119
|
+
${o}`, f === i.length - 1 && s.push(se(c))) : (c.part = o, s.push(se(c)), c.part = "")));
|
|
120
120
|
}), c = [];
|
|
121
|
-
const
|
|
122
|
-
s.forEach((
|
|
123
|
-
const _ =
|
|
124
|
-
return p.replace(
|
|
121
|
+
const l = /(<([0-9:.>]+)>)/ig;
|
|
122
|
+
s.forEach((o) => {
|
|
123
|
+
const _ = o.part.split().map(function(p) {
|
|
124
|
+
return p.replace(l, function(b) {
|
|
125
125
|
return b.split("").reduce(function(x, N) {
|
|
126
126
|
return `==${b.replace("<", "").replace(">", "")}`;
|
|
127
127
|
}, 0);
|
|
@@ -141,7 +141,7 @@ ${l}`, f === i.length - 1 && s.push(se(c))) : (c.part = l, s.push(se(c)), c.part
|
|
|
141
141
|
word: je(p),
|
|
142
142
|
time: void 0
|
|
143
143
|
});
|
|
144
|
-
}),
|
|
144
|
+
}), o.words = y, o.part = o.part.replace(r, "");
|
|
145
145
|
}), n(s);
|
|
146
146
|
});
|
|
147
147
|
}
|
|
@@ -178,56 +178,69 @@ function Pt(e) {
|
|
|
178
178
|
});
|
|
179
179
|
}
|
|
180
180
|
function Et(e) {
|
|
181
|
-
var t;
|
|
181
|
+
var t, r;
|
|
182
182
|
if (e.segments) {
|
|
183
|
-
const
|
|
184
|
-
st: g(
|
|
185
|
-
et: g(
|
|
186
|
-
text:
|
|
183
|
+
const n = e.segments.map((a) => ({
|
|
184
|
+
st: g(a.start),
|
|
185
|
+
et: g(a.end),
|
|
186
|
+
text: a.text
|
|
187
187
|
}));
|
|
188
188
|
if (e.words.length > 0) {
|
|
189
|
-
const
|
|
190
|
-
let
|
|
191
|
-
for (;
|
|
192
|
-
const
|
|
193
|
-
let
|
|
194
|
-
for (let
|
|
195
|
-
const o =
|
|
196
|
-
if (o &&
|
|
197
|
-
|
|
189
|
+
const a = e.words;
|
|
190
|
+
let c = 0, s = 0;
|
|
191
|
+
for (; c < n.length; ) {
|
|
192
|
+
const u = n[c];
|
|
193
|
+
let i = u.text;
|
|
194
|
+
for (let l = s; l < a.length; l++) {
|
|
195
|
+
const o = a[l];
|
|
196
|
+
if (o && i.startsWith(o.word))
|
|
197
|
+
u.children = u.children || [], u.children.push({
|
|
198
198
|
st: g(o.start),
|
|
199
199
|
et: g(o.end),
|
|
200
200
|
text: o.word
|
|
201
|
-
}),
|
|
202
|
-
else if (o && new RegExp(`^[\\s\\p{P}]*${o.word}`, "u").test(
|
|
203
|
-
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
201
|
+
}), i = i.substring(o.word.length);
|
|
202
|
+
else if (o && new RegExp(`^[\\s\\p{P}]*${o.word}`, "u").test(i)) {
|
|
203
|
+
u.children = u.children || [];
|
|
204
|
+
const f = i.match(new RegExp(`^[\\s\\p{P}]*${o.word}`, "u"))[0];
|
|
205
|
+
if (/^[,.?…,。?!!]/u.test(f)) {
|
|
206
|
+
const v = ((t = f.match(/^[,.?…,。?!!]+/u)) == null ? void 0 : t[0]) || "", T = f.substring(v.length);
|
|
207
|
+
if (u.children.length > 0) {
|
|
208
|
+
const _ = u.children[u.children.length - 1];
|
|
209
|
+
_.text += v;
|
|
210
|
+
}
|
|
211
|
+
u.children.push({
|
|
212
|
+
st: g(o.start),
|
|
213
|
+
et: g(o.end),
|
|
214
|
+
text: T
|
|
215
|
+
});
|
|
216
|
+
} else
|
|
217
|
+
u.children.push({
|
|
218
|
+
st: g(o.start),
|
|
219
|
+
et: g(o.end),
|
|
220
|
+
text: f
|
|
221
|
+
});
|
|
222
|
+
i = i.substring(f.length);
|
|
210
223
|
} else {
|
|
211
|
-
|
|
224
|
+
s = l;
|
|
212
225
|
break;
|
|
213
226
|
}
|
|
214
227
|
}
|
|
215
|
-
|
|
228
|
+
c++;
|
|
216
229
|
}
|
|
217
|
-
return
|
|
230
|
+
return n;
|
|
218
231
|
}
|
|
219
|
-
return
|
|
220
|
-
} else if (((
|
|
221
|
-
const
|
|
222
|
-
st: g(
|
|
223
|
-
et: g(
|
|
224
|
-
text:
|
|
232
|
+
return n;
|
|
233
|
+
} else if (((r = e.words) == null ? void 0 : r.length) >= 0) {
|
|
234
|
+
const n = e.words.map((a) => ({
|
|
235
|
+
st: g(a.start),
|
|
236
|
+
et: g(a.end),
|
|
237
|
+
text: a.word
|
|
225
238
|
}));
|
|
226
239
|
return [{
|
|
227
240
|
st: g(e.words[0].start),
|
|
228
241
|
et: g(e.words[e.words.length - 1].end),
|
|
229
242
|
text: e.text,
|
|
230
|
-
children:
|
|
243
|
+
children: n
|
|
231
244
|
}];
|
|
232
245
|
} else
|
|
233
246
|
return [];
|
|
@@ -243,12 +256,12 @@ const ie = {
|
|
|
243
256
|
// 宽松模式下,如果VAD第一段的秒数小于该值,则设置为从头开始
|
|
244
257
|
};
|
|
245
258
|
function Ct(e) {
|
|
246
|
-
let t, r, n, a, c, s, u, i,
|
|
247
|
-
const
|
|
259
|
+
let t, r, n, a, c, s, u, i, l;
|
|
260
|
+
const o = !!(e && e.vad && e.vad.length > 0), f = "[--end--]", v = "[--Single--]", T = "[--Full--]", _ = /\[(\d{2}:\d{2}:\d{2}\.\d{3}) --> (\d{2}:\d{2}:\d{2}\.\d{3})\]/;
|
|
248
261
|
let y = !1, p = !1, b = "";
|
|
249
262
|
return x(), { feed: B, reset: x, end: N };
|
|
250
263
|
function x() {
|
|
251
|
-
t = !0, r = "", n = !1, a = "", c = !1, s = void 0, u = 0, i = !1,
|
|
264
|
+
t = !0, r = "", n = !1, a = "", c = !1, s = void 0, u = 0, i = !1, l = 0;
|
|
252
265
|
}
|
|
253
266
|
function N() {
|
|
254
267
|
if (i) {
|
|
@@ -273,19 +286,19 @@ function Ct(e) {
|
|
|
273
286
|
for (; u < Y; ) {
|
|
274
287
|
const X = r[u];
|
|
275
288
|
if (++u, c && s && X !== "[" && (s.text += X), X === "[" && (n && a.length && s && (s.text += a), a = "", n = !0, c = !1), n) {
|
|
276
|
-
if (a += X, a === T && (a = ""), a === v && (a = "",
|
|
289
|
+
if (a += X, a === T && (a = ""), a === v && (a = "", o && l++), a === f) {
|
|
277
290
|
s && O.push(s), i = !0;
|
|
278
291
|
break;
|
|
279
292
|
}
|
|
280
293
|
if (_.test(a)) {
|
|
281
294
|
const I = _.exec(a), D = I == null ? void 0 : I[1], ne = I == null ? void 0 : I[2];
|
|
282
295
|
if (s && O.push(s), D && ne) {
|
|
283
|
-
if (
|
|
296
|
+
if (o && (e != null && e.vad) && e.vad.length > 0) {
|
|
284
297
|
let Z = 0;
|
|
285
|
-
Z = e.vad[
|
|
298
|
+
Z = e.vad[l].start - ie.padding[0] < 0 ? 0 : e.vad[l].start - ie.padding[0];
|
|
286
299
|
const _t = D === "00:00:00.000";
|
|
287
300
|
let Se = g(A(D) + Z);
|
|
288
|
-
|
|
301
|
+
l > 0 && _t && (Se = g(A(D) + Z + ie.padding[0])), s = {
|
|
289
302
|
st: Se,
|
|
290
303
|
et: g(A(ne) + Z),
|
|
291
304
|
text: "",
|
|
@@ -320,13 +333,13 @@ function Ft(e) {
|
|
|
320
333
|
}
|
|
321
334
|
function It(e) {
|
|
322
335
|
let t, r, n, a, c, s, u, i;
|
|
323
|
-
const
|
|
336
|
+
const l = /\[(\d+)\]/, o = "[--end--]";
|
|
324
337
|
return f(), { feed: T, reset: f, end: v };
|
|
325
338
|
function f() {
|
|
326
339
|
t = !0, r = "", n = 0, i = !1, s = "", a = void 0, c = !1, u = !1;
|
|
327
340
|
}
|
|
328
341
|
function v() {
|
|
329
|
-
T(
|
|
342
|
+
T(o);
|
|
330
343
|
}
|
|
331
344
|
function T(_) {
|
|
332
345
|
var b, x, N, J, B;
|
|
@@ -348,12 +361,12 @@ function It(e) {
|
|
|
348
361
|
event: "message",
|
|
349
362
|
data: [a]
|
|
350
363
|
})), s = "", c = !0, u = !1), c) {
|
|
351
|
-
if (s += j, s ===
|
|
364
|
+
if (s += j, s === o) {
|
|
352
365
|
a && y.push(a), i = !0;
|
|
353
366
|
break;
|
|
354
367
|
}
|
|
355
|
-
if (
|
|
356
|
-
const O =
|
|
368
|
+
if (l.test(s)) {
|
|
369
|
+
const O = l.exec(s), Y = O == null ? void 0 : O[1];
|
|
357
370
|
a && y.push(a), Y && (a = {
|
|
358
371
|
index: Number(Y),
|
|
359
372
|
text: ""
|
|
@@ -675,12 +688,12 @@ var ot = typeof exports == "object" && exports && !exports.nodeType && exports,
|
|
|
675
688
|
}(), Fe = M && M.isTypedArray, tn = Fe ? pe(Fe) : Qr, rn = Object.prototype, nn = rn.hasOwnProperty;
|
|
676
689
|
function ut(e, t) {
|
|
677
690
|
var r = de(e), n = !r && $r(e), a = !r && !n && ct(e), c = !r && !n && !a && tn(e), s = r || n || a || c, u = s ? _r(e.length, String) : [], i = u.length;
|
|
678
|
-
for (var
|
|
679
|
-
(t || nn.call(e,
|
|
680
|
-
(
|
|
681
|
-
a && (
|
|
682
|
-
c && (
|
|
683
|
-
br(
|
|
691
|
+
for (var l in e)
|
|
692
|
+
(t || nn.call(e, l)) && !(s && // Safari 9 has enumerable `arguments.length` in strict mode.
|
|
693
|
+
(l == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
|
|
694
|
+
a && (l == "offset" || l == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
|
|
695
|
+
c && (l == "buffer" || l == "byteLength" || l == "byteOffset") || // Skip index properties.
|
|
696
|
+
br(l, i))) && u.push(l);
|
|
684
697
|
return u;
|
|
685
698
|
}
|
|
686
699
|
function lt(e, t) {
|
|
@@ -1022,13 +1035,13 @@ var Ke = M && M.isSet, Ra = Ke ? pe(Ke) : Da, Ga = 1, Ua = 2, Ha = 4, yt = "[obj
|
|
|
1022
1035
|
h[yt] = h[Wa] = h[ns] = h[as] = h[Ka] = h[Va] = h[ss] = h[is] = h[cs] = h[os] = h[us] = h[Ya] = h[Xa] = h[vt] = h[Za] = h[Qa] = h[es] = h[ts] = h[ls] = h[fs] = h[hs] = h[ds] = !0;
|
|
1023
1036
|
h[qa] = h[mt] = h[rs] = !1;
|
|
1024
1037
|
function Q(e, t, r, n, a, c) {
|
|
1025
|
-
var s, u = t & Ga, i = t & Ua,
|
|
1038
|
+
var s, u = t & Ga, i = t & Ua, l = t & Ha;
|
|
1026
1039
|
if (s !== void 0)
|
|
1027
1040
|
return s;
|
|
1028
1041
|
if (!q(e))
|
|
1029
1042
|
return e;
|
|
1030
|
-
var
|
|
1031
|
-
if (
|
|
1043
|
+
var o = de(e);
|
|
1044
|
+
if (o) {
|
|
1032
1045
|
if (s = ua(e), !u)
|
|
1033
1046
|
return hr(e, s);
|
|
1034
1047
|
} else {
|
|
@@ -1053,7 +1066,7 @@ function Q(e, t, r, n, a, c) {
|
|
|
1053
1066
|
}) : Na(e) && e.forEach(function(p, b) {
|
|
1054
1067
|
s.set(b, Q(p, t, r, b, e, c));
|
|
1055
1068
|
});
|
|
1056
|
-
var _ =
|
|
1069
|
+
var _ = l ? i ? ea : Qn : i ? ye : be, y = o ? void 0 : _(e);
|
|
1057
1070
|
return dr(y || e, function(p, b) {
|
|
1058
1071
|
y && (b = p, p = e[b]), rt(s, b, Q(p, t, r, b, e, c));
|
|
1059
1072
|
}), s;
|
|
@@ -1101,8 +1114,8 @@ function ys(e, t) {
|
|
|
1101
1114
|
r = i;
|
|
1102
1115
|
}
|
|
1103
1116
|
}), a = (i) => i.trim().length === 0, c = (i) => {
|
|
1104
|
-
const
|
|
1105
|
-
return
|
|
1117
|
+
const l = A(i.st), o = A(i.et);
|
|
1118
|
+
return l >= o;
|
|
1106
1119
|
}, s = {
|
|
1107
1120
|
emt: [],
|
|
1108
1121
|
ep: [],
|
|
@@ -1111,9 +1124,9 @@ function ys(e, t) {
|
|
|
1111
1124
|
em: [],
|
|
1112
1125
|
space: []
|
|
1113
1126
|
}, u = [];
|
|
1114
|
-
return e.forEach((i,
|
|
1115
|
-
const
|
|
1116
|
-
n.push(i), i.punc =
|
|
1127
|
+
return e.forEach((i, l) => {
|
|
1128
|
+
const o = P.punc.test(i.text), f = P.em.test(i.text), v = P.space.test(i.text), T = a(i.text), _ = c(i), y = P.ep.test(i.text);
|
|
1129
|
+
n.push(i), i.punc = o ? 1 : 0, o && s.punc.push(l), i.em = f ? 1 : 0, f && s.em.push(l), i.space = v ? 1 : 0, v && (t != null && t.space ? i.text = i.text.replace(P.space, " ").trim() : s.space.push(l)), i.emt = a(i.text) ? 1 : 0, T && (t != null && t.emt || s.emt.push(l)), i.zf = c(i) ? 1 : 0, _ && (t != null && t.zf || s.zf.push(l)), i.ep = y ? 1 : 0, y && (t != null && t.ep ? i.text = i.text.replace(P.ep, "") : s.ep.push(l)), !(t != null && t.zf && i.zf) && (t != null && t.emt && i.emt || u.push(i));
|
|
1117
1130
|
}), n.end(), {
|
|
1118
1131
|
result: s,
|
|
1119
1132
|
repeat: r,
|