十一實驗室 NodeJS 套件用於將文字轉換為語音!
報告錯誤·請求功能
在 GitHub 上給我們留言,以幫助專案改進!
這是一個開源 Eleven Labs NodeJS 包,用於使用 Eleven Labs API 將文字轉換為語音。
功能 | 參數 | 端點 |
---|---|---|
textToSpeech | ({voiceId、檔案名稱、textInput、穩定性、similarBoost、modelId、風格、speakerBoost}) | /v1/text-to-speech/{voice_id} |
textToSpeechStream | ({voiceId、textInput、穩定性、similarBoost、modelId、responseType、風格、speakerBoost}) | /v1/text-to-speech/{voice_id}/stream |
editVoiceSettings | ({voiceId,穩定性,相似度Boost}) | /v1/voices/{voice_id}/settings/edit |
getVoiceSettings | ({語音ID}) | /v1/voices/{voice_id}/settings |
deleteVoice | ({語音ID}) | /v1/voices/{voice_id} |
getVoice | ({語音ID}) | /v1/voices/{voice_id} |
getVoices | 不適用 | /v1/voices |
getModels | 不適用 | /v1/models |
getUserInfo | 不適用 | /v1/user |
getUserSubscription | 不適用 | /v1/user/subscription |
getDefaultVoiceSettings | 不適用 | /v1/voices/settings/default |
多變的 | 描述 | 類型 |
---|---|---|
fileName | 音訊檔案的名稱和檔案路徑,例如 ( ./gen/hello ) | String |
textInput | 要轉換為音訊的文字例如( Hello ) | String |
stability | 文字轉語音的穩定性預設值 ( 0 ) | Float |
similarityBoost | 文字轉語音的相似度提升預設值 ( 0 ) | Float |
voiceId | ElevenLabs 語音 ID 例如 ( pNInz6obpgDQGcFmaJgB ) | String |
modelId | ElevenLabs 模型 ID 例如 ( eleven_multilingual_v2 ) | String |
responseType | 流響應類型例如( stream ) | String |
speakerBoost | 文字轉語音的揚聲器增強例如( true ) | Boolean |
style | 文字轉語音的樣式誇張 (0-100) 預設值 ( 0 ) | Integer |
若要安裝 Elevenlabs 軟體包,請執行以下命令:
npm install elevenlabs-node
為您的專案設定 ElevenLabs 配置。
多變的 | 描述 | 預設 |
---|---|---|
apiKey | ( Required )您來自 Elevenlabs 的 API 金鑰 | 不適用 |
voiceId | ( Optional )Elevenlabs 的語音 ID | 亞當 ( pNInz6obpgDQGcFmaJgB ) |
const ElevenLabs = require ( "elevenlabs-node" ) ;
const voice = new ElevenLabs (
{
apiKey : "0e2c037kl8561005671b1de345s8765c" , // Your API key from Elevenlabs
voiceId : "pNInz6obpgDQGcFmaJgB" , // A Voice ID from Elevenlabs
}
) ;
從文字生成音訊檔案。
const ElevenLabs = require ( "elevenlabs-node" ) ;
const voice = new ElevenLabs (
{
apiKey : "0e2c037kl8561005671b1de345s8765c" , // Your API key from Elevenlabs
voiceId : "pNInz6obpgDQGcFmaJgB" , // A Voice ID from Elevenlabs
}
) ;
voice . textToSpeech ( {
// Required Parameters
fileName : "audio.mp3" , // The name of your audio file
textInput : "mozzy is cool" , // The text you wish to convert to speech
// Optional Parameters
voiceId : "21m00Tcm4TlvDq8ikWAM" , // A different Voice ID from the default
stability : 0.5 , // The stability for the converted speech
similarityBoost : 0.5 , // The similarity boost for the converted speech
modelId : "eleven_multilingual_v2" , // The ElevenLabs Model ID
style : 1 , // The style exaggeration for the converted speech
speakerBoost : true // The speaker boost for the converted speech
} ) . then ( ( res ) => {
console . log ( res ) ;
} ) ;
從文字產生音訊串流。
const ElevenLabs = require ( "elevenlabs-node" ) ;
const fs = require ( "fs-extra" ) ;
const voice = new ElevenLabs (
{
apiKey : "0e2c037kl8561005671b1de345s8765c" , // Your API key from Elevenlabs
voiceId : "pNInz6obpgDQGcFmaJgB" , // A Voice ID from Elevenlabs
}
) ;
const voiceResponse = voice . textToSpeechStream ( {
// Required Parameters
textInput : "mozzy is cool" , // The text you wish to convert to speech
// Optional Parameters
voiceId : "21m00Tcm4TlvDq8ikWAM" , // A different Voice ID from the default
stability : 0.5 , // The stability for the converted speech
similarityBoost : 0.5 , // The similarity boost for the converted speech
modelId : "eleven_multilingual_v2" , // The ElevenLabs Model ID
style : 1 , // The style exaggeration for the converted speech
responseType : "stream" , // The streaming type (arraybuffer, stream, json)
speakerBoost : true // The speaker boost for the converted speech
} ) . then ( ( res ) => {
res . pipe ( fs . createWriteStream ( fileName ) ) ;
} ) ;
編輯語音設定。
const ElevenLabs = require ( "elevenlabs-node" ) ;
const voice = new ElevenLabs (
{
apiKey : "0e2c037kl8561005671b1de345s8765c" , // Your API key from Elevenlabs
}
) ;
const voiceResponse = voice . editVoiceSettings ( {
// Required Parameters
voiceId : "pNInz6obpgDQGcFmaJgB" , // The ID of the voice you want to edit
stabilityBoost : 0.5 , // The Stability Boost for the voice
similarityBoost : 0.5 , // The Similarity Boost for the voice
} ) . then ( ( res ) => {
console . log ( res ) ;
} ) ;
取得語音設定。
const ElevenLabs = require ( "elevenlabs-node" ) ;
const voice = new ElevenLabs (
{
apiKey : "0e2c037kl8561005671b1de345s8765c" , // Your API key from Elevenlabs
}
) ;
const voiceResponse = voice . getVoiceSettings ( {
// Required Parameters
voiceId : "pNInz6obpgDQGcFmaJgB" // The ID of the voice you want to get
} ) . then ( ( res ) => {
console . log ( res ) ;
} ) ;
刪除語音。
const ElevenLabs = require ( "elevenlabs-node" ) ;
const voice = new ElevenLabs (
{
apiKey : "0e2c037kl8561005671b1de345s8765c" , // Your API key from Elevenlabs
}
) ;
const voiceResponse = voice . deleteVoice ( {
// Required Parameters
voiceId : "pNInz6obpgDQGcFmaJgB" // The ID of the voice you want to delete
} ) . then ( ( res ) => {
console . log ( res ) ;
} ) ;
取得語音詳細資訊。
const ElevenLabs = require ( "elevenlabs-node" ) ;
const voice = new ElevenLabs (
{
apiKey : "0e2c037kl8561005671b1de345s8765c" , // Your API key from Elevenlabs
}
) ;
const voiceResponse = voice . getVoice ( {
// Required Parameters
voiceId : "pNInz6obpgDQGcFmaJgB" // The ID of the voice you want to get
} ) . then ( ( res ) => {
console . log ( res ) ;
} ) ;
取得所有語音詳細資訊。
const ElevenLabs = require ( "elevenlabs-node" ) ;
const voice = new ElevenLabs (
{
apiKey : "0e2c037kl8561005671b1de345s8765c" , // Your API key from Elevenlabs
}
) ;
const voiceResponse = voice . getVoices ( ) . then ( ( res ) => {
console . log ( res ) ;
} ) ;
取得所有模型詳細資訊。
const ElevenLabs = require ( "elevenlabs-node" ) ;
const voice = new ElevenLabs (
{
apiKey : "0e2c037kl8561005671b1de345s8765c" , // Your API key from Elevenlabs
}
) ;
const voiceResponse = voice . getModels ( ) . then ( ( res ) => {
console . log ( res ) ;
} ) ;
取得與 API 金鑰關聯的使用者資訊。
const ElevenLabs = require ( "elevenlabs-node" ) ;
const voice = new ElevenLabs (
{
apiKey : "0e2c037kl8561005671b1de345s8765c" , // Your API key from Elevenlabs
}
) ;
const voiceResponse = voice . getUserInfo ( ) . then ( ( res ) => {
console . log ( res ) ;
} ) ;
取得與 API 金鑰關聯的使用者訂閱資訊。
const ElevenLabs = require ( "elevenlabs-node" ) ;
const voice = new ElevenLabs (
{
apiKey : "0e2c037kl8561005671b1de345s8765c" , // Your API key from Elevenlabs
}
) ;
const voiceResponse = voice . getUserSubscription ( ) . then ( ( res ) => {
console . log ( res ) ;
} ) ;
取得預設語音設定。
const ElevenLabs = require ( "elevenlabs-node" ) ;
const voice = new ElevenLabs (
{
apiKey : "0e2c037kl8561005671b1de345s8765c" , // Your API key from Elevenlabs
}
) ;
const voiceResponse = voice . getDefaultVoiceSettings ( ) . then ( ( res ) => {
console . log ( res ) ;
} ) ;
歡迎貢獻:)
請閱讀我們的 CONTRIBUTING.md 以了解更多資訊。