elevenlabs js
1.0.0
这是elevenlabs.io文本到语音API的开源nodejs软件包。您可以在此处找到官方API文档:https://api.elevenlabs.io/docs
如果您喜欢这个项目,请考虑主演。星星是对该项目表示赞赏和兴趣的一种方式。谁知道,我可能更倾向于进一步改善它。
无论您是使用这个项目,从中学到了一些东西,还是像它一样,请考虑通过给我买咖啡来支持它,这样我就可以花更多时间在这样的开源项目上花费更多的时间:)
| 方法 | 参数 | 端点 | HTTP方法 |
|---|---|---|---|
textToSpeech() | voiceId , text , modelId , voiceSettings | /v1/text-to-speech/{voice_id}/stream | 邮政 |
getModels() | N/A。 | /v1/models | 得到 |
getVoices() | N/A。 | /v1/voices | 得到 |
getDefaultVoiceSettings() | N/A。 | /v1/voices/settings/default | 得到 |
getVoiceSettings() | voiceId | /v1/voices/{voiceId}/settings | 得到 |
getVoice() | voiceId , withSettings | /v1/voices/{voiceId} | 得到 |
deleteVoice() | voiceId | /v1/voices/{voiceId} | 删除 |
editVoiceSettings() | voiceId , voiceSettings | /v1/voices/{voiceId}/settings/edit | 邮政 |
getUserSubscription() | N/A。 | /v1/user/subscription | 得到 |
getUser() | N/A。 | /v1/user | 得到 |
| 范围 | 类型 | 描述 | 必需的 | 默认 |
|---|---|---|---|---|
| 旁白 | 细绳 | 要使用的声音ID。您可以使用getVoices()获取可用声音的列表。 | 是的 | N/A。 |
| 文本 | 细绳 | 转换为语音的文字。 | 是的 | N/A。 |
| ModelId | 细绳 | 要使用的模型的ID。您可以使用getModels()获取可用型号的列表。 | 不 | eleven_multilingual_v2 |
| 声音 | 目的 | 用于语音的设置。 | 不 | {stability: 0.95, similarity_boost: 0.75, style: 0.06, use_speaker_boost: true} |
| 范围 | 类型 | 描述 | 默认 |
|---|---|---|---|
| 稳定 | 漂浮 | 声音的稳定性。 | 0.95 |
| samelity_boost | 漂浮 | 相似性提高了声音。 | 0.75 |
| 风格 | 漂浮 | 声音的风格。 | 0.06 |
| use_speaker_boost | 布尔 | 是否使用扬声器提升。 | 真的 |
npm i elevenlabs-js安装软件包。const elevenLabs = require('elevenlabs-js')导入软件包。elevenLabs.setApiKey('YOUR_API_KEY')设置API键。生成语音音频文件的文本。您可以保存文件或获取管道并使用该管道做任何您想做的事情。
const elevenLabs = require ( 'elevenlabs-js' ) ;
const fs = require ( "fs" ) ;
// Set your API key
elevenLabs . setApiKey ( 'YOUR_API_KEY' ) ;
elevenLabs . textToSpeech ( "YOUR_VOICE_ID" , "Hello World!" , "elevenlabs_multilingual_v2" , {
stability : 0.95 ,
similarity_boost : 0.75 ,
style : 0.06 ,
use_speaker_boost : true
} ) . then ( async ( res ) => {
// You can save the file
await res . saveFile ( "test.mp3" )
// Or get the pipe and do whatever you want with it (like streaming it to the client)
const pipe = await res . pipe ;
pipe ( fs . createWriteStream ( "test-with-pipe.mp3" ) ) ;
} ) ;获取可用型号的列表。
const elevenLabs = require ( 'elevenlabs-js' ) ;
// Set your API key
elevenLabs . setApiKey ( 'YOUR_API_KEY' ) ;
elevenLabs . getModels ( ) . then ( ( res ) => {
console . log ( "models" , res ) ;
} ) ;获取可用声音的列表。
const elevenLabs = require ( 'elevenlabs-js' ) ;
// Set your API key
elevenLabs . setApiKey ( 'YOUR_API_KEY' ) ;
elevenLabs . getVoices ( ) . then ( ( res ) => {
console . log ( "voices" , res ) ;
} ) ;获取默认的语音设置。
const elevenLabs = require ( 'elevenlabs-js' ) ;
// Set your API key
elevenLabs . setApiKey ( 'YOUR_API_KEY' ) ;
elevenLabs . getDefaultVoiceSettings ( ) . then ( ( res ) => {
console . log ( "default voice settings" , res ) ;
} ) ;获取声音的声音设置。
const elevenLabs = require ( 'elevenlabs-js' ) ;
// Set your API key
elevenLabs . setApiKey ( 'YOUR_API_KEY' ) ;
elevenLabs . getVoiceSettings ( "YOUR_VOICE_ID" ) . then ( ( res ) => {
console . log ( "voice settings" , res ) ;
} ) ;得到一个声音。
const elevenLabs = require ( 'elevenlabs-js' ) ;
// Set your API key
elevenLabs . setApiKey ( 'YOUR_API_KEY' ) ;
elevenLabs . getVoice ( "YOUR_VOICE_ID" ) . then ( ( res ) => {
console . log ( "voice" , res ) ;
} ) ;删除声音。
const elevenLabs = require ( 'elevenlabs-js' ) ;
// Set your API key
elevenLabs . setApiKey ( 'YOUR_API_KEY' ) ;
elevenLabs . deleteVoice ( "YOUR_VOICE_ID" ) . then ( ( res ) => {
console . log ( "voice" , res ) ;
} ) ;编辑声音的声音设置。
const elevenLabs = require ( 'elevenlabs-js' ) ;
// Set your API key
elevenLabs . setApiKey ( 'YOUR_API_KEY' ) ;
elevenLabs . editVoiceSettings ( "YOUR_VOICE_ID" , {
stability : 0.95 ,
similarity_boost : 0.75 ,
style : 0.06 ,
use_speaker_boost : true
} ) . then ( ( res ) => {
console . log ( "voice settings" , res ) ;
} ) ;获取用户订阅信息。
const elevenLabs = require ( 'elevenlabs-js' ) ;
// Set your API key
elevenLabs . setApiKey ( 'YOUR_API_KEY' ) ;
elevenLabs . getUserSubscription ( ) . then ( ( res ) => {
console . log ( "user subscription" , res ) ;
} ) ;获取用户信息。
const elevenLabs = require ( 'elevenlabs-js' ) ;
// Set your API key
elevenLabs . setApiKey ( 'YOUR_API_KEY' ) ;
elevenLabs . getUser ( ) . then ( ( res ) => {
console . log ( "user" , res ) ;
} ) ; 另外,您可以在此处找到此软件包的其他语言:
该项目是根据MIT许可证获得许可的 - 有关详细信息,请参见许可证文件。