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許可證獲得許可的 - 有關詳細信息,請參見許可證文件。