elevenlabs-m2k
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -16,4 +16,9 @@ export declare class ElevenlabsAPI { | ||
* Get all preset voices | ||
* @returns A sample Audio from voice | ||
* @returns A json array of {name, model_id, ...} and more | ||
*/ | ||
getModels(): Promise<Array<any>>; | ||
/** | ||
* Get all preset voices | ||
* @returns A sample Audio from voice url | ||
*/ | ||
getSample(voice_id: string): Promise<string>; | ||
@@ -20,0 +25,0 @@ /** |
@@ -37,3 +37,3 @@ "use strict"; | ||
const url = `${BASE_URL}/voices`; | ||
return (yield instance.get(url, this.headers)).data.voices; | ||
return (yield instance.get(url, { headers: this.headers })).data.voices; | ||
}); | ||
@@ -43,8 +43,18 @@ } | ||
* Get all preset voices | ||
* @returns A sample Audio from voice | ||
* @returns A json array of {name, model_id, ...} and more | ||
*/ | ||
getModels() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const url = `${BASE_URL}/models`; | ||
return (yield instance.get(url, { headers: this.headers })).data; | ||
}); | ||
} | ||
/** | ||
* Get all preset voices | ||
* @returns A sample Audio from voice url | ||
*/ | ||
getSample(voice_id) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const url = `${BASE_URL}/voices/${voice_id}`; | ||
const response = yield instance.get(url, this.headers); | ||
const response = yield instance.get(url, { headers: this.headers }); | ||
const voice = response.data; | ||
@@ -74,3 +84,3 @@ return voice.preview_url; | ||
}; | ||
return (yield instance.post(url, data, this.headers)).data; | ||
return (yield instance.post(url, data, { headers: this.headers, responseType: 'arraybuffer', })).data; | ||
}); | ||
@@ -77,0 +87,0 @@ } |
{ | ||
"name": "elevenlabs-m2k", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "The Nodes KS API for ElevenLabs text-to-speech.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -5,2 +5,4 @@ # Elevenlabs Nodejs | ||
## Getting Started | ||
Get your ElevenLabs API key from <a href="https://docs.elevenlabs.io/api-reference/quick-start/authentication">here</a>. | ||
``` | ||
@@ -14,4 +16,4 @@ const apiKey = process.env.API_KEY; | ||
``` | ||
elevenlabs.getVoices().then(async (data) => { | ||
const { voice_id, name } = data.voices[0]; | ||
elevenlabs.getVoices().then(async (voices) => { | ||
const { voice_id, name } = voices[0]; | ||
console.log(name, 'is speaking', `(${voice_id})`); | ||
@@ -21,7 +23,12 @@ }); | ||
# Get Sample Voice Audio URL | ||
``` | ||
elevenlabs.getSample(voice_id).then(url => console.log(url)); | ||
``` | ||
## Get Models | ||
``` | ||
elevenlabs.getModels().then(async (data) => { | ||
const { model_id, name } = data.voices[0]; | ||
const { model_id, name } = data.models[0]; | ||
console.log(name, '=', `(${model_id})`); | ||
@@ -34,3 +41,3 @@ }); | ||
``` | ||
const audio = await elevenlabs.getAudio("Hello World", voice_id); | ||
const audio = await elevenlabs.getAudio("Hello World", voice_id); // Get array buffer | ||
``` |
Sorry, the diff of this file is not supported yet
25422
120
39