web-speech-cognitive-services 8.0.0-main.478b2e9 → 8.0.0-main.85313be
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.
|
@@ -25665,7 +25665,7 @@
|
|
|
25665
25665
|
}
|
|
25666
25666
|
var meta = document.createElement("meta");
|
|
25667
25667
|
meta.setAttribute("name", "web-speech-cognitive-services");
|
|
25668
|
-
meta.setAttribute("content", `version=${"8.0.0-main.
|
|
25668
|
+
meta.setAttribute("content", `version=${"8.0.0-main.85313be"}`);
|
|
25669
25669
|
document.head.appendChild(meta);
|
|
25670
25670
|
|
|
25671
25671
|
// src/index.umd.js
|
|
@@ -1254,7 +1254,7 @@ function createSpeechServicesPonyfill(options = {}, ...args) {
|
|
|
1254
1254
|
}
|
|
1255
1255
|
var meta = document.createElement("meta");
|
|
1256
1256
|
meta.setAttribute("name", "web-speech-cognitive-services");
|
|
1257
|
-
meta.setAttribute("content", `version=${"8.0.0-main.
|
|
1257
|
+
meta.setAttribute("content", `version=${"8.0.0-main.85313be"}`);
|
|
1258
1258
|
document.head.appendChild(meta);
|
|
1259
1259
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1260
1260
|
0 && (module.exports = {
|
|
@@ -1220,7 +1220,7 @@ function createSpeechServicesPonyfill(options = {}, ...args) {
|
|
|
1220
1220
|
}
|
|
1221
1221
|
var meta = document.createElement("meta");
|
|
1222
1222
|
meta.setAttribute("name", "web-speech-cognitive-services");
|
|
1223
|
-
meta.setAttribute("content", `version=${"8.0.0-main.
|
|
1223
|
+
meta.setAttribute("content", `version=${"8.0.0-main.85313be"}`);
|
|
1224
1224
|
document.head.appendChild(meta);
|
|
1225
1225
|
export {
|
|
1226
1226
|
SpeechToText_default as createSpeechRecognitionPonyfill,
|
|
@@ -27,5 +27,5 @@ File System access not available, please use Push or PullAudioOutputStream`),thi
|
|
|
27
27
|
${r}
|
|
28
28
|
</prosody>
|
|
29
29
|
</voice>
|
|
30
|
-
</speak>`}var bO=/^\s*<speak(\s|\/?>)/u,OO=/^\s*<\?xml\s/u;function jf(i){return bO.test(i)||OO.test(i)}var MO="en-US",DO="riff-16khz-16bit-mono-pcm",kO="Microsoft Server Speech Text to Speech Voice (en-US, AriaNeural)",NO="SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU3LjU2LjEwMQAAAAAAAAAAAAAA//tAwAAAAAAAAAAAAAAAAAAAAAAASW5mbwAAAA8AAAACAAABhgC7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7//////////////////////////////////////////////////////////////////8AAAAATGF2YzU3LjY0AAAAAAAAAAAAAAAAJAUHAAAAAAAAAYYoRBqpAAAAAAD/+xDEAAPAAAGkAAAAIAAANIAAAARMQU1FMy45OS41VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7EMQpg8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV";async function jR({deploymentId:i,fetchCredentials:e,lang:t=MO,outputFormat:r=DO,pitch:n,rate:s,text:o,voice:a=kO,volume:c}){if(!o)return zR(NO);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=jf(o)?o:zf({lang:t,pitch:n,rate:s,text:o,voice:a,volume:c}),w=d||(i?`${encodeURI(h)}.voice.speech.microsoft.com`:`${encodeURI(h)}.tts.speech.microsoft.com`),k=i?`?deploymentId=${encodeURI(i)}`:"",ae=`https://${w}/cognitiveservices/v1${k}`,Z=await fetch(ae,{headers:{"Content-Type":"application/ssml+xml","X-Microsoft-OutputFormat":r,...u?{Authorization:`Bearer ${u}`}:{"Ocp-Apim-Subscription-Key":v}},method:"POST",body:g});if(!Z.ok)throw new Error(`web-speech-cognitive-services: Failed to syntheis speech, server returned ${Z.status}`);return Z.arrayBuffer()}function Lf(i,e,t){return i.addEventListener(e,t),()=>i.removeEventListener(e,t)}function qO(i,e){return new Promise((t,r)=>{let n=i.decodeAudioData(e,t,r);n&&typeof n.then=="function"&&t(n)})}function xO(i,e,t){return new Promise((r,n)=>{let s=new Bf.default,o=new Bf.default,a=Lf(i,"statechange",({target:{state:c}})=>c==="closed"&&s.eventListener());try{t.buffer=e,t.onended=o.eventListener,t.connect(i.destination),t.start(0),Promise.race([s.upcoming(),o.upcoming()]).then(r)}catch(c){n(c)}finally{a()}})}var Ff=class extends pt{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 Q(this,"boundary")}set onboundary(e){Y(this,"boundary",e)}get onend(){return Q(this,"end")}set onend(e){Y(this,"end",e)}get onerror(){return Q(this,"error")}set onerror(e){Y(this,"error",e)}get onmark(){return Q(this,"mark")}set onmark(e){Y(this,"mark",e)}get onpause(){return Q(this,"pause")}set onpause(e){Y(this,"pause",e)}get onresume(){return Q(this,"resume")}set onresume(e){Y(this,"resume",e)}get onstart(){return Q(this,"start")}set onstart(e){Y(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:r}){this.arrayBufferPromise=jR({fetchCredentials:t,deploymentId:e,lang:this.lang||window.navigator.language,outputFormat:r,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 Xt("start"));let t=e.createBufferSource(),r=await qO(e,await this.arrayBufferPromise);this._playingSource=t,await xO(e,r,t),this._playingSource=null,this.dispatchEvent(new Xt("end"))}catch(t){this.dispatchEvent(new ErrorEvent("error",{error:"synthesis-failed",message:t.stack}))}}stop(){this._playingSource&&this._playingSource.stop()}},Vf=Ff;var zO="audio-24khz-160kbitrate-mono-mp3",jO=[],LR=i=>{let{audioContext:e,fetchCredentials:t,ponyfill:r={AudioContext:window.AudioContext||window.webkitAudioContext},speechSynthesisDeploymentId:n,speechSynthesisOutputFormat:s=zO}=Qn(i);if(!e&&!r.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 pt{constructor(){super(),this.queue=new Tp({audioContext:e,ponyfill:r}),this.updateVoices()}cancel(){this.queue.stop()}getVoices(){return jO}get onvoiceschanged(){return Q(this,"voiceschanged")}set onvoiceschanged(c){Y(this,"voiceschanged",c)}pause(){this.queue.pause()}resume(){this.queue.resume()}speak(c){if(!(c instanceof Vf))throw new Error("invalid utterance");let{reject:u,resolve:h,promise:d}=Gn(),v=({error:g,message:w})=>{let k=new Error(g);k.stack=w,u(k)};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(0,Uf.default)(async()=>{let v=await OR({customVoiceHostname:c,deploymentId:n,region:u,speechSynthesisHostname:h,subscriptionKey:d});this.getVoices=()=>v})):await(0,Uf.default)(async()=>{let v=await Nf(await t());this.getVoices=()=>v}),this.dispatchEvent(new Xt("voiceschanged"))}}return{speechSynthesis:new o,SpeechSynthesisEvent:Xt,SpeechSynthesisUtterance:Vf}};var Wf=LR;function Ap(i={},...e){return{...Df(i,...e),...Wf(i,...e)}}var Hf=document.createElement("meta");Hf.setAttribute("name","web-speech-cognitive-services");Hf.setAttribute("content","version=8.0.0-main.
|
|
30
|
+
</speak>`}var bO=/^\s*<speak(\s|\/?>)/u,OO=/^\s*<\?xml\s/u;function jf(i){return bO.test(i)||OO.test(i)}var MO="en-US",DO="riff-16khz-16bit-mono-pcm",kO="Microsoft Server Speech Text to Speech Voice (en-US, AriaNeural)",NO="SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU3LjU2LjEwMQAAAAAAAAAAAAAA//tAwAAAAAAAAAAAAAAAAAAAAAAASW5mbwAAAA8AAAACAAABhgC7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7//////////////////////////////////////////////////////////////////8AAAAATGF2YzU3LjY0AAAAAAAAAAAAAAAAJAUHAAAAAAAAAYYoRBqpAAAAAAD/+xDEAAPAAAGkAAAAIAAANIAAAARMQU1FMy45OS41VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVf/7EMQpg8AAAaQAAAAgAAA0gAAABFVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV";async function jR({deploymentId:i,fetchCredentials:e,lang:t=MO,outputFormat:r=DO,pitch:n,rate:s,text:o,voice:a=kO,volume:c}){if(!o)return zR(NO);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=jf(o)?o:zf({lang:t,pitch:n,rate:s,text:o,voice:a,volume:c}),w=d||(i?`${encodeURI(h)}.voice.speech.microsoft.com`:`${encodeURI(h)}.tts.speech.microsoft.com`),k=i?`?deploymentId=${encodeURI(i)}`:"",ae=`https://${w}/cognitiveservices/v1${k}`,Z=await fetch(ae,{headers:{"Content-Type":"application/ssml+xml","X-Microsoft-OutputFormat":r,...u?{Authorization:`Bearer ${u}`}:{"Ocp-Apim-Subscription-Key":v}},method:"POST",body:g});if(!Z.ok)throw new Error(`web-speech-cognitive-services: Failed to syntheis speech, server returned ${Z.status}`);return Z.arrayBuffer()}function Lf(i,e,t){return i.addEventListener(e,t),()=>i.removeEventListener(e,t)}function qO(i,e){return new Promise((t,r)=>{let n=i.decodeAudioData(e,t,r);n&&typeof n.then=="function"&&t(n)})}function xO(i,e,t){return new Promise((r,n)=>{let s=new Bf.default,o=new Bf.default,a=Lf(i,"statechange",({target:{state:c}})=>c==="closed"&&s.eventListener());try{t.buffer=e,t.onended=o.eventListener,t.connect(i.destination),t.start(0),Promise.race([s.upcoming(),o.upcoming()]).then(r)}catch(c){n(c)}finally{a()}})}var Ff=class extends pt{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 Q(this,"boundary")}set onboundary(e){Y(this,"boundary",e)}get onend(){return Q(this,"end")}set onend(e){Y(this,"end",e)}get onerror(){return Q(this,"error")}set onerror(e){Y(this,"error",e)}get onmark(){return Q(this,"mark")}set onmark(e){Y(this,"mark",e)}get onpause(){return Q(this,"pause")}set onpause(e){Y(this,"pause",e)}get onresume(){return Q(this,"resume")}set onresume(e){Y(this,"resume",e)}get onstart(){return Q(this,"start")}set onstart(e){Y(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:r}){this.arrayBufferPromise=jR({fetchCredentials:t,deploymentId:e,lang:this.lang||window.navigator.language,outputFormat:r,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 Xt("start"));let t=e.createBufferSource(),r=await qO(e,await this.arrayBufferPromise);this._playingSource=t,await xO(e,r,t),this._playingSource=null,this.dispatchEvent(new Xt("end"))}catch(t){this.dispatchEvent(new ErrorEvent("error",{error:"synthesis-failed",message:t.stack}))}}stop(){this._playingSource&&this._playingSource.stop()}},Vf=Ff;var zO="audio-24khz-160kbitrate-mono-mp3",jO=[],LR=i=>{let{audioContext:e,fetchCredentials:t,ponyfill:r={AudioContext:window.AudioContext||window.webkitAudioContext},speechSynthesisDeploymentId:n,speechSynthesisOutputFormat:s=zO}=Qn(i);if(!e&&!r.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 pt{constructor(){super(),this.queue=new Tp({audioContext:e,ponyfill:r}),this.updateVoices()}cancel(){this.queue.stop()}getVoices(){return jO}get onvoiceschanged(){return Q(this,"voiceschanged")}set onvoiceschanged(c){Y(this,"voiceschanged",c)}pause(){this.queue.pause()}resume(){this.queue.resume()}speak(c){if(!(c instanceof Vf))throw new Error("invalid utterance");let{reject:u,resolve:h,promise:d}=Gn(),v=({error:g,message:w})=>{let k=new Error(g);k.stack=w,u(k)};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(0,Uf.default)(async()=>{let v=await OR({customVoiceHostname:c,deploymentId:n,region:u,speechSynthesisHostname:h,subscriptionKey:d});this.getVoices=()=>v})):await(0,Uf.default)(async()=>{let v=await Nf(await t());this.getVoices=()=>v}),this.dispatchEvent(new Xt("voiceschanged"))}}return{speechSynthesis:new o,SpeechSynthesisEvent:Xt,SpeechSynthesisUtterance:Vf}};var Wf=LR;function Ap(i={},...e){return{...Df(i,...e),...Wf(i,...e)}}var Hf=document.createElement("meta");Hf.setAttribute("name","web-speech-cognitive-services");Hf.setAttribute("content","version=8.0.0-main.85313be");document.head.appendChild(Hf);globalThis.WebSpeechCognitiveServices={create:Ap,createSpeechRecognitionPonyfillFromRecognizer:Ki};})();
|
|
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.0.0-main.
|
|
3
|
+
"version": "8.0.0-main.85313be",
|
|
4
4
|
"description": "Polyfill Web Speech API with Cognitive Services Speech-to-Text service",
|
|
5
5
|
"files": [
|
|
6
6
|
"./dist/**/*"
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"memoize-one": "6.0.0",
|
|
95
95
|
"on-error-resume-next": "^1.1.0",
|
|
96
96
|
"simple-update-in": "2.2.0",
|
|
97
|
-
"web-speech-cognitive-services": "^8.0.0-main.
|
|
97
|
+
"web-speech-cognitive-services": "^8.0.0-main.85313be"
|
|
98
98
|
},
|
|
99
99
|
"peerDependencies": {
|
|
100
100
|
"microsoft-cognitiveservices-speech-sdk": "^1.17.0"
|