web-speech-cognitive-services 8.1.4-main.202512240506.3b5f3a0 → 8.1.4-main.202512240512.82ccc40
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.
|
@@ -24871,7 +24871,7 @@
|
|
|
24871
24871
|
}
|
|
24872
24872
|
var meta = document.createElement("meta");
|
|
24873
24873
|
meta.setAttribute("name", "web-speech-cognitive-services");
|
|
24874
|
-
meta.setAttribute("content", `version=${"8.1.4-main.
|
|
24874
|
+
meta.setAttribute("content", `version=${"8.1.4-main.202512240512.82ccc40"}`);
|
|
24875
24875
|
document.head.appendChild(meta);
|
|
24876
24876
|
var SpeechServices_default = createSpeechServicesPonyfill;
|
|
24877
24877
|
|
|
@@ -1458,7 +1458,7 @@ function createSpeechServicesPonyfill(options = {}) {
|
|
|
1458
1458
|
}
|
|
1459
1459
|
var meta = document.createElement("meta");
|
|
1460
1460
|
meta.setAttribute("name", "web-speech-cognitive-services");
|
|
1461
|
-
meta.setAttribute("content", `version=${"8.1.4-main.
|
|
1461
|
+
meta.setAttribute("content", `version=${"8.1.4-main.202512240512.82ccc40"}`);
|
|
1462
1462
|
document.head.appendChild(meta);
|
|
1463
1463
|
var SpeechServices_default = createSpeechServicesPonyfill;
|
|
1464
1464
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1424,7 +1424,7 @@ function createSpeechServicesPonyfill(options = {}) {
|
|
|
1424
1424
|
}
|
|
1425
1425
|
var meta = document.createElement("meta");
|
|
1426
1426
|
meta.setAttribute("name", "web-speech-cognitive-services");
|
|
1427
|
-
meta.setAttribute("content", `version=${"8.1.4-main.
|
|
1427
|
+
meta.setAttribute("content", `version=${"8.1.4-main.202512240512.82ccc40"}`);
|
|
1428
1428
|
document.head.appendChild(meta);
|
|
1429
1429
|
var SpeechServices_default = createSpeechServicesPonyfill;
|
|
1430
1430
|
export {
|
|
@@ -27,5 +27,5 @@ File System access not available, please use Push or PullAudioOutputStream`),thi
|
|
|
27
27
|
${i}
|
|
28
28
|
</prosody>
|
|
29
29
|
</voice>
|
|
30
|
-
</speak>`}var s0=/^\s*<speak(\s|\/?>)/u,o0=/^\s*<\?xml\s/u;function Sf(r){return s0.test(r)||o0.test(r)}var a0="en-US",c0="riff-16khz-16bit-mono-pcm",u0="Microsoft Server Speech Text to Speech Voice (en-US, AriaNeural)",p0="SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU3LjU2LjEwMQAAAAAAAAAAAAAA//tAwAAAAAAAAAAAAAAAAAAAAAAASW5mbwAAAA8AAAACAAABhgC7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7//////////////////////////////////////////////////////////////////8AAAAATGF2YzU3LjY0AAAAAAAAAAAAAAAAJAUHAAAAAAAAAYYoRBqpAAAAAAD/+xDEAAPAAAGkAAAAIAAANIAAAARMQU1FMy45OS41VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7EMQpg8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV";async function Cf({deploymentId:r,fetchCredentials:e,lang:t=a0,outputFormat:i=c0,pitch:n,rate:s,text:o,voice:a=u0,volume:c}){if(!o)return rR(p0);let{authorizationToken:u,region:h,speechSynthesisHostname:d,subscriptionKey:v}=await e();if(u&&v||!u&&!v)throw new Error('Only "authorizationToken" or "subscriptionKey" should be set.');if(h&&d||!h&&!d)throw new Error('Only "region" or "speechSynthesisHostnamename" should be set.');let g=Sf(o)?o:yf({lang:t,pitch:n,rate:s,text:o,voice:a,volume:c}),x=d||(r?`${encodeURI(h)}.voice.speech.microsoft.com`:`${encodeURI(h)}.tts.speech.microsoft.com`),I=r?`?deploymentId=${encodeURI(r)}`:"",V=`https://${x}/cognitiveservices/v1${I}`,G=await fetch(V,{headers:{"Content-Type":"application/ssml+xml","X-Microsoft-OutputFormat":i,...u?{Authorization:`Bearer ${u}`}:{"Ocp-Apim-Subscription-Key":v}},method:"POST",body:g});if(!G.ok)throw new Error(`web-speech-cognitive-services: Failed to syntheis speech, server returned ${G.status}`);return G.arrayBuffer()}function Pf(r,e,t){return r.addEventListener(e,t),()=>r.removeEventListener(e,t)}function h0(r,e){return new Promise((t,i)=>{let n=r.decodeAudioData(e,t,i);n&&typeof n.then=="function"&&t(n)})}function l0(r,e,t){return new Promise((i,n)=>{let s=new gf,o=new gf,a=Pf(r,"statechange",({target:{state:c}})=>c==="closed"&&s.eventListener());try{t.buffer=e,t.onended=o.eventListener,t.connect(r.destination),t.start(0),Promise.race([s.upcoming(),o.upcoming()]).then(i)}catch(c){n(c)}finally{a()}})}var Rf=class extends Yt{constructor(e){super(),this._lang=null,this._pitch=1,this._rate=1,this._voice=null,this._volume=1,this.text=e,this.onboundary=null,this.onend=null,this.onerror=null,this.onmark=null,this.onpause=null,this.onresume=null,this.onstart=null}get lang(){return this._lang}set lang(e){this._lang=e}get onboundary(){return jt(this,"boundary")}set onboundary(e){zt(this,"boundary",e)}get onend(){return jt(this,"end")}set onend(e){zt(this,"end",e)}get onerror(){return jt(this,"error")}set onerror(e){zt(this,"error",e)}get onmark(){return jt(this,"mark")}set onmark(e){zt(this,"mark",e)}get onpause(){return jt(this,"pause")}set onpause(e){zt(this,"pause",e)}get onresume(){return jt(this,"resume")}set onresume(e){zt(this,"resume",e)}get onstart(){return jt(this,"start")}set onstart(e){zt(this,"start",e)}get pitch(){return this._pitch}set pitch(e){this._pitch=e}get rate(){return this._rate}set rate(e){this._rate=e}get voice(){return this._voice}set voice(e){this._voice=e}get volume(){return this._volume}set volume(e){this._volume=e}preload({deploymentId:e,fetchCredentials:t,outputFormat:i}){this.arrayBufferPromise=Cf({fetchCredentials:t,deploymentId:e,lang:this.lang||window.navigator.language,outputFormat:i,pitch:this.pitch,rate:this.rate,text:this.text,voice:this.voice&&this.voice.voiceURI,volume:this.volume}),this.arrayBufferPromise.catch()}async play(e){try{this.dispatchEvent(new er("start"));let t=e.createBufferSource(),i=await h0(e,await this.arrayBufferPromise);this._playingSource=t,await l0(e,i,t),this._playingSource=null,this.dispatchEvent(new er("end"))}catch(t){this.dispatchEvent(new ErrorEvent("error",{error:"synthesis-failed",message:t.stack}))}}stop(){this._playingSource&&this._playingSource.stop()}},Ef=Rf;var pi=class{constructor({gender:e,lang:t,voiceURI:i}){this._default=!1,this._gender=e,this._lang=t,this._localService=!1,this._name=i,this._voiceURI=i}get default(){return this._default}get gender(){return this._gender}get lang(){return this._lang}get localService(){return this._localService}get name(){return this._name}get voiceURI(){return this._voiceURI}};async function d0({customVoiceHostname:r,deploymentId:e,region:t,subscriptionKey:i}){let n=r||`${t}.customvoice.api.speech.microsoft.com`,s=await fetch(`https://${encodeURI(n)}/api/texttospeech/v2.0/endpoints/${encodeURIComponent(e)}`,{headers:{accept:"application/json","ocp-apim-subscription-key":i}});if(!s.ok)throw new Error("Failed to fetch custom voices");return s.json()}async function wf({customVoiceHostname:r,deploymentId:e,region:t,subscriptionKey:i}){let{models:n}=await d0({customVoiceHostname:r,deploymentId:e,region:t,subscriptionKey:i});return n.map(({properties:{Gender:s},locale:o,name:a})=>new pi({gender:s,lang:o,voiceURI:a})).sort(({name:s},{name:o})=>s>o?1:s<o?-1:0)}async function bf({authorizationToken:r,region:e,speechSynthesisHostname:t,subscriptionKey:i}){let n=t||`${encodeURI(e)}.tts.speech.microsoft.com`,s=await fetch(`https://${n}/cognitiveservices/voices/list`,{headers:{"content-type":"application/json",...r?{authorization:`Bearer ${r}`}:{"Ocp-Apim-Subscription-Key":i}}});if(!s.ok)throw new Error("Failed to fetch voices");return(await s.json()).map(({Gender:a,Locale:c,Name:u})=>new pi({gender:a,lang:c,voiceURI:u})).sort(({name:a},{name:c})=>a>c?1:a<c?-1:0)}var v0="audio-24khz-160kbitrate-mono-mp3",f0=[];function g0(r){let{audioContext:e,fetchCredentials:t,ponyfill:i={AudioContext:window.AudioContext||window.webkitAudioContext},speechSynthesisDeploymentId:n,speechSynthesisOutputFormat:s=v0}=ss(r);if(!e&&!i.AudioContext)return console.warn("web-speech-cognitive-services: This browser does not support Web Audio and it will not work with Cognitive Services Speech Services."),{};class o extends Yt{constructor(){super(),this.queue=new ps({audioContext:e,ponyfill:i}),this.updateVoices()}cancel(){this.queue.stop()}getVoices(){return f0}get onvoiceschanged(){return jt(this,"voiceschanged")}set onvoiceschanged(c){zt(this,"voiceschanged",c)}pause(){this.queue.pause()}resume(){this.queue.resume()}speak(c){if(!(c instanceof Ef))throw new Error("invalid utterance");let{reject:u,resolve:h,promise:d}=os(),v=({error:g,message:x})=>{let I=new Error(g);I.stack=x,u(I)};return c.addEventListener("end",h),c.addEventListener("error",v),c.preload({deploymentId:n,fetchCredentials:t,outputFormat:s}),this.queue.push(c),d.finally(()=>{c.removeEventListener("end",h),c.removeEventListener("error",v)})}get speaking(){return this.queue.speaking}async updateVoices(){let{customVoiceHostname:c,region:u,speechSynthesisHostname:h,subscriptionKey:d}=await t();n?d&&(console.warn("web-speech-cognitive-services: Listing of custom voice models are only available when using subscription key."),await ff(async()=>{let v=await wf({customVoiceHostname:c,deploymentId:n,region:u,speechSynthesisHostname:h,subscriptionKey:d});this.getVoices=()=>v})):await ff(async()=>{let v=await bf(await t());this.getVoices=()=>v}),this.dispatchEvent(new er("voiceschanged"))}}return{speechSynthesis:new o,SpeechSynthesisEvent:er,SpeechSynthesisUtterance:Ef}}var iR=g0;var Af=iR;function y0(r={}){return{...cs(r),...Af(r)}}var Tf=document.createElement("meta");Tf.setAttribute("name","web-speech-cognitive-services");Tf.setAttribute("content","version=8.1.4-main.
|
|
30
|
+
</speak>`}var s0=/^\s*<speak(\s|\/?>)/u,o0=/^\s*<\?xml\s/u;function Sf(r){return s0.test(r)||o0.test(r)}var a0="en-US",c0="riff-16khz-16bit-mono-pcm",u0="Microsoft Server Speech Text to Speech Voice (en-US, AriaNeural)",p0="SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU3LjU2LjEwMQAAAAAAAAAAAAAA//tAwAAAAAAAAAAAAAAAAAAAAAAASW5mbwAAAA8AAAACAAABhgC7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7//////////////////////////////////////////////////////////////////8AAAAATGF2YzU3LjY0AAAAAAAAAAAAAAAAJAUHAAAAAAAAAYYoRBqpAAAAAAD/+xDEAAPAAAGkAAAAIAAANIAAAARMQU1FMy45OS41VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7EMQpg8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV";async function Cf({deploymentId:r,fetchCredentials:e,lang:t=a0,outputFormat:i=c0,pitch:n,rate:s,text:o,voice:a=u0,volume:c}){if(!o)return rR(p0);let{authorizationToken:u,region:h,speechSynthesisHostname:d,subscriptionKey:v}=await e();if(u&&v||!u&&!v)throw new Error('Only "authorizationToken" or "subscriptionKey" should be set.');if(h&&d||!h&&!d)throw new Error('Only "region" or "speechSynthesisHostnamename" should be set.');let g=Sf(o)?o:yf({lang:t,pitch:n,rate:s,text:o,voice:a,volume:c}),x=d||(r?`${encodeURI(h)}.voice.speech.microsoft.com`:`${encodeURI(h)}.tts.speech.microsoft.com`),I=r?`?deploymentId=${encodeURI(r)}`:"",V=`https://${x}/cognitiveservices/v1${I}`,G=await fetch(V,{headers:{"Content-Type":"application/ssml+xml","X-Microsoft-OutputFormat":i,...u?{Authorization:`Bearer ${u}`}:{"Ocp-Apim-Subscription-Key":v}},method:"POST",body:g});if(!G.ok)throw new Error(`web-speech-cognitive-services: Failed to syntheis speech, server returned ${G.status}`);return G.arrayBuffer()}function Pf(r,e,t){return r.addEventListener(e,t),()=>r.removeEventListener(e,t)}function h0(r,e){return new Promise((t,i)=>{let n=r.decodeAudioData(e,t,i);n&&typeof n.then=="function"&&t(n)})}function l0(r,e,t){return new Promise((i,n)=>{let s=new gf,o=new gf,a=Pf(r,"statechange",({target:{state:c}})=>c==="closed"&&s.eventListener());try{t.buffer=e,t.onended=o.eventListener,t.connect(r.destination),t.start(0),Promise.race([s.upcoming(),o.upcoming()]).then(i)}catch(c){n(c)}finally{a()}})}var Rf=class extends Yt{constructor(e){super(),this._lang=null,this._pitch=1,this._rate=1,this._voice=null,this._volume=1,this.text=e,this.onboundary=null,this.onend=null,this.onerror=null,this.onmark=null,this.onpause=null,this.onresume=null,this.onstart=null}get lang(){return this._lang}set lang(e){this._lang=e}get onboundary(){return jt(this,"boundary")}set onboundary(e){zt(this,"boundary",e)}get onend(){return jt(this,"end")}set onend(e){zt(this,"end",e)}get onerror(){return jt(this,"error")}set onerror(e){zt(this,"error",e)}get onmark(){return jt(this,"mark")}set onmark(e){zt(this,"mark",e)}get onpause(){return jt(this,"pause")}set onpause(e){zt(this,"pause",e)}get onresume(){return jt(this,"resume")}set onresume(e){zt(this,"resume",e)}get onstart(){return jt(this,"start")}set onstart(e){zt(this,"start",e)}get pitch(){return this._pitch}set pitch(e){this._pitch=e}get rate(){return this._rate}set rate(e){this._rate=e}get voice(){return this._voice}set voice(e){this._voice=e}get volume(){return this._volume}set volume(e){this._volume=e}preload({deploymentId:e,fetchCredentials:t,outputFormat:i}){this.arrayBufferPromise=Cf({fetchCredentials:t,deploymentId:e,lang:this.lang||window.navigator.language,outputFormat:i,pitch:this.pitch,rate:this.rate,text:this.text,voice:this.voice&&this.voice.voiceURI,volume:this.volume}),this.arrayBufferPromise.catch()}async play(e){try{this.dispatchEvent(new er("start"));let t=e.createBufferSource(),i=await h0(e,await this.arrayBufferPromise);this._playingSource=t,await l0(e,i,t),this._playingSource=null,this.dispatchEvent(new er("end"))}catch(t){this.dispatchEvent(new ErrorEvent("error",{error:"synthesis-failed",message:t.stack}))}}stop(){this._playingSource&&this._playingSource.stop()}},Ef=Rf;var pi=class{constructor({gender:e,lang:t,voiceURI:i}){this._default=!1,this._gender=e,this._lang=t,this._localService=!1,this._name=i,this._voiceURI=i}get default(){return this._default}get gender(){return this._gender}get lang(){return this._lang}get localService(){return this._localService}get name(){return this._name}get voiceURI(){return this._voiceURI}};async function d0({customVoiceHostname:r,deploymentId:e,region:t,subscriptionKey:i}){let n=r||`${t}.customvoice.api.speech.microsoft.com`,s=await fetch(`https://${encodeURI(n)}/api/texttospeech/v2.0/endpoints/${encodeURIComponent(e)}`,{headers:{accept:"application/json","ocp-apim-subscription-key":i}});if(!s.ok)throw new Error("Failed to fetch custom voices");return s.json()}async function wf({customVoiceHostname:r,deploymentId:e,region:t,subscriptionKey:i}){let{models:n}=await d0({customVoiceHostname:r,deploymentId:e,region:t,subscriptionKey:i});return n.map(({properties:{Gender:s},locale:o,name:a})=>new pi({gender:s,lang:o,voiceURI:a})).sort(({name:s},{name:o})=>s>o?1:s<o?-1:0)}async function bf({authorizationToken:r,region:e,speechSynthesisHostname:t,subscriptionKey:i}){let n=t||`${encodeURI(e)}.tts.speech.microsoft.com`,s=await fetch(`https://${n}/cognitiveservices/voices/list`,{headers:{"content-type":"application/json",...r?{authorization:`Bearer ${r}`}:{"Ocp-Apim-Subscription-Key":i}}});if(!s.ok)throw new Error("Failed to fetch voices");return(await s.json()).map(({Gender:a,Locale:c,Name:u})=>new pi({gender:a,lang:c,voiceURI:u})).sort(({name:a},{name:c})=>a>c?1:a<c?-1:0)}var v0="audio-24khz-160kbitrate-mono-mp3",f0=[];function g0(r){let{audioContext:e,fetchCredentials:t,ponyfill:i={AudioContext:window.AudioContext||window.webkitAudioContext},speechSynthesisDeploymentId:n,speechSynthesisOutputFormat:s=v0}=ss(r);if(!e&&!i.AudioContext)return console.warn("web-speech-cognitive-services: This browser does not support Web Audio and it will not work with Cognitive Services Speech Services."),{};class o extends Yt{constructor(){super(),this.queue=new ps({audioContext:e,ponyfill:i}),this.updateVoices()}cancel(){this.queue.stop()}getVoices(){return f0}get onvoiceschanged(){return jt(this,"voiceschanged")}set onvoiceschanged(c){zt(this,"voiceschanged",c)}pause(){this.queue.pause()}resume(){this.queue.resume()}speak(c){if(!(c instanceof Ef))throw new Error("invalid utterance");let{reject:u,resolve:h,promise:d}=os(),v=({error:g,message:x})=>{let I=new Error(g);I.stack=x,u(I)};return c.addEventListener("end",h),c.addEventListener("error",v),c.preload({deploymentId:n,fetchCredentials:t,outputFormat:s}),this.queue.push(c),d.finally(()=>{c.removeEventListener("end",h),c.removeEventListener("error",v)})}get speaking(){return this.queue.speaking}async updateVoices(){let{customVoiceHostname:c,region:u,speechSynthesisHostname:h,subscriptionKey:d}=await t();n?d&&(console.warn("web-speech-cognitive-services: Listing of custom voice models are only available when using subscription key."),await ff(async()=>{let v=await wf({customVoiceHostname:c,deploymentId:n,region:u,speechSynthesisHostname:h,subscriptionKey:d});this.getVoices=()=>v})):await ff(async()=>{let v=await bf(await t());this.getVoices=()=>v}),this.dispatchEvent(new er("voiceschanged"))}}return{speechSynthesis:new o,SpeechSynthesisEvent:er,SpeechSynthesisUtterance:Ef}}var iR=g0;var Af=iR;function y0(r={}){return{...cs(r),...Af(r)}}var Tf=document.createElement("meta");Tf.setAttribute("name","web-speech-cognitive-services");Tf.setAttribute("content","version=8.1.4-main.202512240512.82ccc40");document.head.appendChild(Tf);var _f=y0;globalThis.WebSpeechCognitiveServices={create:_f,createSpeechRecognitionPonyfillFromRecognizer:Mr};})();
|
|
31
31
|
//# sourceMappingURL=web-speech-cognitive-services.production.min.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "web-speech-cognitive-services",
|
|
3
|
-
"version": "8.1.4-main.
|
|
3
|
+
"version": "8.1.4-main.202512240512.82ccc40",
|
|
4
4
|
"description": "Polyfill Web Speech API with Cognitive Services Speech-to-Text service",
|
|
5
5
|
"files": [
|
|
6
6
|
"./*.js",
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"on-error-resume-next": "^2.0.3",
|
|
104
104
|
"simple-update-in": "^2.2.0",
|
|
105
105
|
"valibot": "^1.2.0",
|
|
106
|
-
"web-speech-cognitive-services": "^8.1.4-main.
|
|
106
|
+
"web-speech-cognitive-services": "^8.1.4-main.202512240512.82ccc40"
|
|
107
107
|
},
|
|
108
108
|
"peerDependencies": {
|
|
109
109
|
"microsoft-cognitiveservices-speech-sdk": "^1.17.0"
|