@imgly/plugin-ai-audio-generation-web 0.2.7 → 0.2.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/CHANGELOG.md +11 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/elevenlabs/index.mjs +10 -18
- package/dist/elevenlabs/index.mjs.map +1 -1
- package/dist/index.mjs +11 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -15
|
@@ -62,23 +62,15 @@ var Le=typeof global=="object"&&global&&global.Object===Object&&global,ge=Le,je=
|
|
|
62
62
|
`;var ke={openapi:"3.0.0",info:{title:"Elevenlabs API",version:"1.0.0",description:"Elevenlabs API"},components:{schemas:{ElevenlabsInput:{title:"TextToSpeechInput",type:"object",properties:{prompt:{title:"Prompt",type:"string","x-imgly-builder":{component:"TextArea"}},voice_id:{title:"Voice",type:"string",description:"The voice ID to use for the speech synthesis.",default:"JBFqnCBsd6RMkjVDRZzb"},speed:{title:"Speed",type:"number",description:"The speed of the speech synthesis.",default:1,"x-imgly-step":.05,minimum:.7,maximum:1.2}},"x-elevenlabs-order-properties":["prompt","style","image_size"],required:["prompt","voice_id"]}}}};var Ie={version:"2.0.0",id:"ly.img.voices.eleventlabs",assets:[{id:"JBFqnCBsd6RMkjVDRZzb",label:{en:"George"},tags:{en:["British Accent","warm","middle aged","male","narration"]},meta:{uri:"https://storage.googleapis.com/eleven-public-prod/premade/voices/JBFqnCBsd6RMkjVDRZzb/e6206d1a-0721-4787-aafb-06a6e705cac5.mp3",thumbUri:"{{base_url}}george.webp",blockType:"//ly.img.ubq/audio",mimeType:"audio/x-m4a",duration:"3.42"}},{id:"FGY2WhTYpPnrIDTdsKH5",label:{en:"Laura"},tags:{en:["American Accent","upbeat","young","female","social media"]},meta:{uri:"https://storage.googleapis.com/eleven-public-prod/premade/voices/FGY2WhTYpPnrIDTdsKH5/67341759-ad08-41a5-be6e-de12fe448618.mp3",thumbUri:"{{base_url}}laura.webp",blockType:"//ly.img.ubq/audio",mimeType:"audio/x-m4a",duration:"2.04"}},{id:"IKne3meq5aSn9XLyUdCD",label:{en:"Charlie"},tags:{en:["Australian Accent","natural","middle aged","male","conversational"]},meta:{uri:"https://storage.googleapis.com/eleven-public-prod/premade/voices/IKne3meq5aSn9XLyUdCD/102de6f2-22ed-43e0-a1f1-111fa75c5481.mp3",thumbUri:"{{base_url}}charlie.webp",blockType:"//ly.img.ubq/audio",mimeType:"audio/x-m4a",duration:"2.53"}},{id:"9BWtsMINqrJLrRacOk9x",label:{en:"Aria"},tags:{en:["American Accent","expressive","middle-aged","female","social media"]},meta:{uri:"https://storage.googleapis.com/eleven-public-prod/premade/voices/9BWtsMINqrJLrRacOk9x/405766b8-1f4e-4d3c-aba1-6f25333823ec.mp3",thumbUri:"{{base_url}}aria.webp",blockType:"//ly.img.ubq/audio",mimeType:"audio/x-m4a",duration:"3.71"}},{id:"EXAVITQu4vr4xnSDxMaL",label:{en:"Sarah"},tags:{en:["american Accent","soft","young","female","news"]},meta:{uri:"https://storage.googleapis.com/eleven-public-prod/premade/voices/EXAVITQu4vr4xnSDxMaL/01a3e33c-6e99-4ee7-8543-ff2216a32186.mp3",thumbUri:"{{base_url}}sarah2.webp",blockType:"//ly.img.ubq/audio",mimeType:"audio/x-m4a",duration:"2.53"}},{id:"SAz9YHcvj6GT2YYXdXww",label:{en:"River"},tags:{en:["American Accent","confident","middle-aged","non-binary","social media"]},meta:{uri:"https://storage.googleapis.com/eleven-public-prod/premade/voices/SAz9YHcvj6GT2YYXdXww/e6c95f0b-2227-491a-b3d7-2249240decb7.mp3",thumbUri:"{{base_url}}river.webp",blockType:"//ly.img.ubq/audio",mimeType:"audio/x-m4a",duration:"3.53"}},{id:"XrExE9yKIg1WjnnlVkGX",label:{en:"Matilda"},tags:{en:["American Accent","friendly","middle-aged","female","narration"]},meta:{uri:"https://storage.googleapis.com/eleven-public-prod/premade/voices/XrExE9yKIg1WjnnlVkGX/b930e18d-6b4d-466e-bab2-0ae97c6d8535.mp3",thumbUri:"{{base_url}}matilda.webp",blockType:"//ly.img.ubq/audio",mimeType:"audio/x-m4a",duration:"2.64"}},{id:"N2lVS1w4EtoT3dr4eOWO",label:{en:"Callum"},tags:{en:["Transatlantic Accent","intense","middle-aged","male","characters"]},meta:{uri:"https://storage.googleapis.com/eleven-public-prod/premade/voices/N2lVS1w4EtoT3dr4eOWO/ac833bd8-ffda-4938-9ebc-b0f99ca25481.mp3",thumbUri:"{{base_url}}callum.webp",blockType:"//ly.img.ubq/audio",mimeType:"audio/x-m4a",duration:"4.18"}},{id:"TX3LPaxmHKxFdv7VOQHJ",label:{en:"Liam"},tags:{en:["American Accent","articulate","young","male","narration"]},meta:{uri:"https://storage.googleapis.com/eleven-public-prod/premade/voices/TX3LPaxmHKxFdv7VOQHJ/63148076-6363-42db-aea8-31424308b92c.mp3",thumbUri:"{{base_url}}liam.webp",blockType:"//ly.img.ubq/audio",mimeType:"audio/x-m4a",duration:"4.13"}},{id:"XB0fDUnXU5powFXDhCwa",label:{en:"Charlotte"},tags:{en:["Swedish Accent","seductive","young","female","characters"]},meta:{uri:"https://storage.googleapis.com/eleven-public-prod/premade/voices/XB0fDUnXU5powFXDhCwa/942356dc-f10d-4d89-bda5-4f8505ee038b.mp3",thumbUri:"{{base_url}}charlotte.webp",blockType:"//ly.img.ubq/audio",mimeType:"audio/x-m4a",duration:"5.25"}},{id:"CwhRBWXzGAHq8TQ4Fs17",label:{en:"Roger"},tags:{en:["American Accent","confident","middle-aged","male","social media"]},meta:{uri:"https://storage.googleapis.com/eleven-public-prod/premade/voices/CwhRBWXzGAHq8TQ4Fs17/58ee3ff5-f6f2-4628-93b8-e38eb31806b0.mp3",thumbUri:"{{base_url}}roger.webp",blockType:"//ly.img.ubq/audio",mimeType:"audio/x-m4a",duration:"3.89"}},{id:"nPczCjzI2devNBz1zQrb",label:{en:"Brian"},tags:{en:["American Accent","deep","middle-aged","male","narration"]},meta:{uri:"https://storage.googleapis.com/eleven-public-prod/premade/voices/nPczCjzI2devNBz1zQrb/2dd3e72c-4fd3-42f1-93ea-abc5d4e5aa1d.mp3",thumbUri:"{{base_url}}brian.webp",blockType:"//ly.img.ubq/audio",mimeType:"audio/x-m4a",duration:"5.46"}},{id:"cgSgspJ2msm6clMCkdW9",label:{en:"Jessica"},tags:{en:["American Accent","expressive","young","female","conversational"]},meta:{uri:"https://storage.googleapis.com/eleven-public-prod/premade/voices/cgSgspJ2msm6clMCkdW9/56a97bf8-b69b-448f-846c-c3a11683d45a.mp3",thumbUri:"{{base_url}}jessica.webp",blockType:"//ly.img.ubq/audio",mimeType:"audio/x-m4a",duration:"3.89"}},{id:"Xb7hH8MSUJpSbSDYk0k2",label:{en:"Alice"},tags:{en:["British Accent","confident","middle-aged","female","news"]},meta:{uri:"https://storage.googleapis.com/eleven-public-prod/premade/voices/Xb7hH8MSUJpSbSDYk0k2/d10f7534-11f6-41fe-a012-2de1e482d336.mp3",thumbUri:"{{base_url}}alice.webp",blockType:"//ly.img.ubq/audio",mimeType:"audio/x-m4a",duration:"3.53"}},{id:"pFZP5JQG7iQjIQuC4Bku",label:{en:"Lily"},tags:{en:["British Accent","warm","middle-aged","female","narration"]},meta:{uri:"https://storage.googleapis.com/eleven-public-prod/premade/voices/pFZP5JQG7iQjIQuC4Bku/89b68b35-b3dd-4348-a84a-a3c13a3c2b30.mp3",thumbUri:"{{base_url}}lily.webp",blockType:"//ly.img.ubq/audio",mimeType:"audio/x-m4a",duration:"3.11"}},{id:"cjVigY5qzO86Huf0OWal",label:{en:"Eric"},tags:{en:["American Accent","friendly","middle-aged","male","conversational"]},meta:{uri:"https://storage.googleapis.com/eleven-public-prod/premade/voices/cjVigY5qzO86Huf0OWal/d098fda0-6456-4030-b3d8-63aa048c9070.mp3",thumbUri:"{{base_url}}eric.webp",blockType:"//ly.img.ubq/audio",mimeType:"audio/x-m4a",duration:"2.32"}},{id:"bIHbv24MWmeRgasZH58o",label:{en:"Will"},tags:{en:["American Accent","friendly","young","male","social media"]},meta:{uri:"https://storage.googleapis.com/eleven-public-prod/premade/voices/bIHbv24MWmeRgasZH58o/8caf8f3d-ad29-4980-af41-53f20c72d7a4.mp3",thumbUri:"{{base_url}}will.webp",blockType:"//ly.img.ubq/audio",mimeType:"audio/x-m4a",duration:"2.74"}},{id:"iP95p4xoKVk53GoZ742B",label:{en:"Chris"},tags:{en:["American Accent","casual","middle-aged","male","conversational"]},meta:{uri:"https://storage.googleapis.com/eleven-public-prod/premade/voices/iP95p4xoKVk53GoZ742B/3f4bde72-cc48-40dd-829f-57fbf906f4d7.mp3",thumbUri:"{{base_url}}chris.webp",blockType:"//ly.img.ubq/audio",mimeType:"audio/x-m4a",duration:"3.29"}},{id:"pqHfZKP75CvOlQylNhV4",label:{en:"Bill"},tags:{en:["American Accent","trustworthy","old","male","narration"]},meta:{uri:"https://storage.googleapis.com/eleven-public-prod/premade/voices/pqHfZKP75CvOlQylNhV4/d782b3ff-84ba-4029-848c-acf01285524d.mp3",thumbUri:"{{base_url}}bill.webp",blockType:"//ly.img.ubq/audio",mimeType:"audio/x-m4a",duration:"5.51"}},{id:"onwK4e9ZLuTAKqWW03F9",label:{en:"Daniel"},tags:{en:["British Accent","authoritative","middle-aged","male","news"]},meta:{uri:"https://storage.googleapis.com/eleven-public-prod/premade/voices/onwK4e9ZLuTAKqWW03F9/7eee0236-1a72-4b86-b303-5dcadc007ba9.mp3",thumbUri:"{{base_url}}daniel.webp",blockType:"//ly.img.ubq/audio",mimeType:"audio/x-m4a",duration:"5.75"}}]};function xe(e,t,i){return Math.min(Math.max(e,t),i)}async function U(e){return new Promise((t,i)=>{let r=new Audio;r.src=e,r.addEventListener("loadedmetadata",()=>{let n=r.duration;t(n)}),r.addEventListener("error",n=>{i(new Error(`Failed to load audio metadata: ${n.message}`))})})}var $r={width:256,height:256,backgroundColor:"transparent",waveformColor:"black",pixelsPerSecond:100};async function R(e,t={}){let{width:i,height:r,backgroundColor:n,waveformColor:u,pixelsPerSecond:a}={...$r,...t},p=new AudioContext,l=await e.arrayBuffer(),s=await p.decodeAudioData(l),d=s.duration,c=Math.max(i,Math.ceil(d*a)),P=s.sampleRate*d/c,h=document.createElement("canvas");h.width=i,h.height=r;let m=h.getContext("2d");m.fillStyle=n,m.fillRect(0,0,i,r);let Ee=s.getChannelData(0),S=r/2,Me=s.length;m.strokeStyle=u,m.beginPath(),m.moveTo(0,S);for(let b=0;b<i;b++){let E=1,v=-1;for(let F=0;F<P;F++){let X=Math.floor(b*P+F);if(X<Me){let N=Ee[X];N<E&&(E=N),N>v&&(v=N)}}let Te=S-E*S,$e=S-v*S;m.lineTo(b,$e),m.lineTo(b,Te)}return m.stroke(),new Promise((b,E)=>{h.toBlob(v=>{v?b(v):E(new Error("Canvas to Blob conversion failed"))})})}function B(e,t,i={}){let{ellipsis:r="...",preserveSentences:n=!1,minLength:u=0}=i;if(!e||e.length<=u||e.length<=t)return e;let a=t-r.length;if(n){let s=/[.!?](?:\s|$)/g,d,c=0;for(;(d=s.exec(e))!==null&&!(d.index>a);)c=d.index+1;if(c>0)return e.substring(0,c)+r}let p=e.substring(0,a),l=p.lastIndexOf(" ");return l>0&&(p=p.substring(0,l)),p+r}function Ae(e){return async({cesdk:t})=>Lr(t,e)}function Lr(e,t){let i=t.baseURL??"https://cdn.img.ly/assets/plugins/plugin-ai-audio-generation-web/v1/elevenlabs/",r="ly.img.ai.audio-generation.speech.elevenlabs",n=`${r}.voiceSelection`,u=Dr(e,i),a="elevenlabs/monolingual/v1";return e.setTranslations({en:{[`panel.${a}`]:"AI Voice",[`panel.${n}`]:"Select a Voice",[`panel.${we("elevenlabs")}`]:"AI Voice",[`libraries.${a}.history.label`]:"AI Voice","libraries.elevenlabs/sound-generation.history.label":"Generated Sound"}}),{id:a,name:"Elevenlabs Multilingual V2",kind:"audio",initialize:async()=>{e.ui.addAssetLibraryEntry({id:u,sourceIds:[u],gridColumns:3}),e.ui.registerPanel(n,({builder:l,payload:s})=>{l.Library(`${r}.voiceSelection.library`,{searchable:!0,entries:[u],onSelect:async d=>{let{id:c,label:y}=d;s?.onSelect(c,y??c,d.meta?.thumbUri),e.ui.closePanel(n)}})})},input:{panel:{type:"schema",document:ke,inputReference:"#/components/schemas/ElevenlabsInput",useFlow:"generation-only",renderCustomProperty:{voice_id:l=>{let s=l.experimental.global("voice",{voiceId:"JBFqnCBsd6RMkjVDRZzb",name:"George",thumbnail:`${i}george.webp`});return l.builder.Button(`${r}.openVoiceSelection`,{inputLabel:[`ly.img.plugin-ai-audio-generation-web.${a}.property.voice_id`,"ly.img.plugin-ai-generation-web.property.voice_id",`ly.img.plugin-ai-audio-generation-web.${a}.defaults.property.voice_id`,"ly.img.plugin-ai-generation-web.defaults.property.voice_id"],icon:"@imgly/Appearance",trailingIcon:"@imgly/ChevronRight",labelAlignment:"left",label:s.value.name,onClick:()=>{e.ui.openPanel(n,{payload:{id:s.value.voiceId,onSelect:(d,c,y)=>{s.setValue({voiceId:d,name:c,thumbnail:y})}}})}}),()=>({id:"voice_id",type:"string",value:s.value.voiceId})}},getBlockInput:async l=>({audio:{label:B(l.prompt,25)}})}},output:{abortable:!0,history:t.history??"@imgly/indexedDB",middleware:t.middlewares??t.middleware??[],generate:async(l,{abortSignal:s})=>{let d=await jr(l.prompt,l.voice_id,{speed:parseFloat(l.speed.toFixed(10))},t,s),c=URL.createObjectURL(d),[y,P]=await Promise.all([R(d,{width:512,height:128}),U(c)]),h=URL.createObjectURL(y);return{kind:"audio",url:c,duration:P,thumbnailUrl:h}}},config:t}}async function jr(e,t,i,r,n){let u=`${r.proxyUrl}/v1/text-to-speech/${t}`,a=await fetch(u,{signal:n,method:"POST",headers:{Accept:"audio/mpeg","Content-Type":"application/json",...r.headers??{}},body:JSON.stringify({text:e,model_id:"eleven_multilingual_v2",voice_settings:{speed:xe(i?.speed||1,.7,1.2),stability:i?.stability||.5,similarity_boost:i?.similarityBoost||.5}})});if(!a.ok){let p=await a.text();throw new Error(`API error: ${a.status} - ${p}`)}return a.blob()}function Dr(e,t){let{id:i,assets:r}=Ie;return e.engine.asset.addLocalSource(i),r.map(async n=>{e.engine.asset.addAssetToSource(i,{...n,meta:{...n.meta,thumbUri:n.meta.thumbUri.replace("{{base_url}}",`${t}thumbnails/`)}})}),i}var Ce={openapi:"3.0.0",info:{title:"Elevenlabs Sound Effects API",version:"1.0.0",description:"Elevenlabs Sound Effects API"},components:{schemas:{TextToSoundInput:{title:"TextToSoundInput",type:"object",properties:{text:{title:"Prompt",type:"string","x-imgly-builder":{component:"TextArea"}},duration_seconds:{title:"Duration (sec.)",type:"number",minimum:.6,maximum:22,default:2}},"x-elevenlabs-order-properties":["text"],required:["text"]}}}};function Se(e){return async({cesdk:t})=>Nr(t,e)}function Nr(e,t){let i="elevenlabs/sound-generation";return e.setTranslations({en:{[`panel.${i}`]:"Generate Sound"}}),{id:i,name:"Elevenlabs Sound Generation",kind:"audio",initialize:async()=>{},input:{panel:{type:"schema",document:Ce,inputReference:"#/components/schemas/TextToSoundInput",useFlow:"generation-only",getBlockInput:async n=>({audio:{label:B(n.text,25)}})}},output:{abortable:!0,history:t.history??"@imgly/indexedDB",middleware:t.middlewares??t.middleware??[],generate:async(n,{abortSignal:u})=>{let a=await _r(n.text,n.duration_seconds,t,u),p=URL.createObjectURL(a),[l,s]=await Promise.all([R(a,{width:512,height:128}),U(p)]),d=URL.createObjectURL(l);return{kind:"audio",url:p,duration:s,thumbnailUrl:d}}},config:t}}async function _r(e,t,i,r){let n=`${i.proxyUrl}/v1/sound-generation`,u=await fetch(n,{signal:r,method:"POST",headers:{Accept:"audio/mpeg","Content-Type":"application/json",...i.headers??{}},body:JSON.stringify({text:e,duration_seconds:t})});if(!u.ok){let a=await u.text();throw new Error(`API error: ${u.status} - ${a}`)}return u.blob()}var zr={ElevenMultilingualV2:Ae,ElevenSoundEffects:Se},hn=zr;export{hn as default};
|
|
63
63
|
/*! Bundled license information:
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
* Build: `lodash modularize exports="es" -o ./`
|
|
76
|
-
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
77
|
-
* Released under MIT license <https://lodash.com/license>
|
|
78
|
-
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
79
|
-
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
80
|
-
*)
|
|
81
|
-
*)
|
|
82
|
-
*)
|
|
65
|
+
lodash-es/lodash.js:
|
|
66
|
+
(**
|
|
67
|
+
* @license
|
|
68
|
+
* Lodash (Custom Build) <https://lodash.com/>
|
|
69
|
+
* Build: `lodash modularize exports="es" -o ./`
|
|
70
|
+
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
71
|
+
* Released under MIT license <https://lodash.com/license>
|
|
72
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
73
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
74
|
+
*)
|
|
83
75
|
*/
|
|
84
76
|
//# sourceMappingURL=index.mjs.map
|