@jokio/sdk 0.2.3 → 0.2.4

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.
@@ -8538,7 +8538,7 @@ class Ho {
8538
8538
  const oi = {
8539
8539
  debug: !1,
8540
8540
  authUrl: "https://auth.jok.io",
8541
- natsUrl: "https://natsx.jok.io",
8541
+ natsUrl: "https://nats.jok.io",
8542
8542
  storage: new ii()
8543
8543
  }, Mr = new Fr(oi), Jo = {
8544
8544
  setup(r) {
@@ -36,4 +36,4 @@ Path:ssml\r
36
36
  Content-Type:application/json; charset=utf-8\r
37
37
  Path:speech.config\r
38
38
  \r
39
- {"context":{"synthesis":{"audio":{"metadataoptions":{"sentenceBoundaryEnabled":false,"wordBoundaryEnabled":true},"outputFormat":"audio-24khz-48kbitrate-mono-mp3"}}}}`,Eo=(r,e,t={})=>{var o;t.pitch=(o=t.pitch)==null?void 0:o.replace("hz","Hz");const s=t.pitch||"0Hz",i=t.rate||"0%",n=t.volume||"0%";return`<speak version='1.0' xml:lang='en-US'><voice name='${e}'><prosody pitch='${s}' rate='${i}' volume='${n}'>${r}</prosody></voice></speak>`};function Ao(r,e){for(let t=0;t<=r.length-e.length;t++){let s=!0;for(let i=0;i<e.length;i++)if(r[t+i]!==e[i]){s=!1;break}if(s)return t}return-1}class Po{constructor(e){this.config=e}async getAudioBuffer(e,t){const s=await fetch(`${this.config.voicevoxUrl}/audio_query?text=${encodeURIComponent(e)}&speaker=${t||3}`,{method:"POST",headers:{Accept:"application/json"}});if(!s.ok)throw new Error(`Audio query failed: ${s.statusText}`);const i=await s.json(),n=await fetch(`${this.config.voicevoxUrl}/synthesis?speaker=${t}`,{method:"POST",headers:{Accept:"audio/wav","Content-Type":"application/json"},body:JSON.stringify(i)});if(!n.body)return null;const o=n.body.getReader(),a=[];for(;;){const{done:y,value:x}=await o.read();if(y)break;a.push(x)}const d=a.reduce((y,x)=>y+x.length,0),p=new Uint8Array(d);let _=0;for(const y of a)p.set(y,_),_+=y.length;return p.buffer}async getAudio(e,t){return this.getAudioBuffer(e,t).then(s=>s?Gr(s):null)}async getVoices(){return(await fetch(`${this.config.voicevoxUrl}/speakers`).then(t=>t.json())).flatMap(t=>t.styles.map(s=>({id:s.id.toString(),locale:"ja-JP",description:`${t.name} - ${s.name}`})))}}const Kr={debug:!1,authUrl:"https://auth.jok.io",natsUrl:"https://natsx.jok.io",storage:new zr},Vr=new er(Kr),ko={setup(r){(r.authUrl||r.storage)&&(this.auth=new er({authUrl:r.authUrl??this.auth.url,storage:r.storage??this.storage})),(r.natsUrl||r.storage)&&(this.nats=new Ls({natsUrl:r.natsUrl??this.nats.url,auth:this.auth}))},auth:Vr,storage:new zr,tts:new So,nats:new Ls({...Kr,auth:Vr}),crypto:new yi};me.NatsService=Ls,me.VoicevoxTtsService=Po,me.jok=ko,Object.defineProperty(me,Symbol.toStringTag,{value:"Module"})});
39
+ {"context":{"synthesis":{"audio":{"metadataoptions":{"sentenceBoundaryEnabled":false,"wordBoundaryEnabled":true},"outputFormat":"audio-24khz-48kbitrate-mono-mp3"}}}}`,Eo=(r,e,t={})=>{var o;t.pitch=(o=t.pitch)==null?void 0:o.replace("hz","Hz");const s=t.pitch||"0Hz",i=t.rate||"0%",n=t.volume||"0%";return`<speak version='1.0' xml:lang='en-US'><voice name='${e}'><prosody pitch='${s}' rate='${i}' volume='${n}'>${r}</prosody></voice></speak>`};function Ao(r,e){for(let t=0;t<=r.length-e.length;t++){let s=!0;for(let i=0;i<e.length;i++)if(r[t+i]!==e[i]){s=!1;break}if(s)return t}return-1}class Po{constructor(e){this.config=e}async getAudioBuffer(e,t){const s=await fetch(`${this.config.voicevoxUrl}/audio_query?text=${encodeURIComponent(e)}&speaker=${t||3}`,{method:"POST",headers:{Accept:"application/json"}});if(!s.ok)throw new Error(`Audio query failed: ${s.statusText}`);const i=await s.json(),n=await fetch(`${this.config.voicevoxUrl}/synthesis?speaker=${t}`,{method:"POST",headers:{Accept:"audio/wav","Content-Type":"application/json"},body:JSON.stringify(i)});if(!n.body)return null;const o=n.body.getReader(),a=[];for(;;){const{done:y,value:x}=await o.read();if(y)break;a.push(x)}const d=a.reduce((y,x)=>y+x.length,0),p=new Uint8Array(d);let _=0;for(const y of a)p.set(y,_),_+=y.length;return p.buffer}async getAudio(e,t){return this.getAudioBuffer(e,t).then(s=>s?Gr(s):null)}async getVoices(){return(await fetch(`${this.config.voicevoxUrl}/speakers`).then(t=>t.json())).flatMap(t=>t.styles.map(s=>({id:s.id.toString(),locale:"ja-JP",description:`${t.name} - ${s.name}`})))}}const Kr={debug:!1,authUrl:"https://auth.jok.io",natsUrl:"https://nats.jok.io",storage:new zr},Vr=new er(Kr),ko={setup(r){(r.authUrl||r.storage)&&(this.auth=new er({authUrl:r.authUrl??this.auth.url,storage:r.storage??this.storage})),(r.natsUrl||r.storage)&&(this.nats=new Ls({natsUrl:r.natsUrl??this.nats.url,auth:this.auth}))},auth:Vr,storage:new zr,tts:new So,nats:new Ls({...Kr,auth:Vr}),crypto:new yi};me.NatsService=Ls,me.VoicevoxTtsService=Po,me.jok=ko,Object.defineProperty(me,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jokio/sdk",
3
3
  "description": "pure js/ts sdk for building decentralised localfirst web apps. Provides tts ai model integrations, realtime p2p communication & crypto encryptions.",
4
- "version": "0.2.3",
4
+ "version": "0.2.4",
5
5
  "license": "MIT",
6
6
  "main": "dist/jokio.sdk.umd.js",
7
7
  "module": "dist/jokio.sdk.es.js",