Pacote NodeJS da Eleven Labs para conversão de texto em fala!
Reportar bug · Solicitar recurso
Deixe-nos um contato no GitHub para ajudar o projeto a melhorar!
Este é um pacote NodeJS de código aberto do Eleven Labs para conversão de texto em fala usando a API Eleven Labs.
Função | Parâmetros | Ponto final |
---|---|---|
textToSpeech | ({voiceId, fileName, textInput, estabilidade, similarityBoost, modelId, estilo, speakerBoost}) | /v1/text-to-speech/{voice_id} |
textToSpeechStream | ({voiceId, textInput, estabilidade, similarityBoost, modelId, responseType, estilo, speakerBoost}) | /v1/text-to-speech/{voice_id}/stream |
editVoiceSettings | ({voiceId, estabilidade, similarityBoost}) | /v1/voices/{voice_id}/settings/edit |
getVoiceSettings | ({vozId}) | /v1/voices/{voice_id}/settings |
deleteVoice | ({vozId}) | /v1/voices/{voice_id} |
getVoice | ({vozId}) | /v1/voices/{voice_id} |
getVoices | N / D | /v1/voices |
getModels | N / D | /v1/models |
getUserInfo | N / D | /v1/user |
getUserSubscription | N / D | /v1/user/subscription |
getDefaultVoiceSettings | N / D | /v1/voices/settings/default |
Variável | Descrição | Tipo |
---|---|---|
fileName | Nome e caminho do arquivo de áudio, por exemplo ( ./gen/hello ) | String |
textInput | Texto a ser convertido em áudio, por exemplo ( Hello ) | String |
stability | Estabilidade para padrão de conversão de texto em fala ( 0 ) | Float |
similarityBoost | Aumento de similaridade para padrão de conversão de texto em fala ( 0 ) | Float |
voiceId | ID de voz ElevenLabs, por exemplo ( pNInz6obpgDQGcFmaJgB ) | String |
modelId | ID do modelo ElevenLabs, por exemplo ( eleven_multilingual_v2 ) | String |
responseType | Tipo de resposta de streaming, por exemplo ( stream ) | String |
speakerBoost | Aumento de alto-falante para conversão de texto em fala, por exemplo ( true ) | Boolean |
style | Exagero de estilo para conversão de texto em fala (0-100) padrão ( 0 ) | Integer |
Para instalar o pacote Elevenlabs, execute o seguinte comando:
npm install elevenlabs-node
Defina as configurações do ElevenLabs para o seu projeto.
Variável | Descrição | Padrão |
---|---|---|
apiKey | ( Required ) Sua chave API da Elevenlabs | N / D |
voiceId | ( Optional ) Um ID de voz da Elevenlabs | Adão ( pNInz6obpgDQGcFmaJgB ) |
const ElevenLabs = require ( "elevenlabs-node" ) ;
const voice = new ElevenLabs (
{
apiKey : "0e2c037kl8561005671b1de345s8765c" , // Your API key from Elevenlabs
voiceId : "pNInz6obpgDQGcFmaJgB" , // A Voice ID from Elevenlabs
}
) ;
Gerando um arquivo de áudio a partir de texto.
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 ) ;
} ) ;
Gerando um fluxo de áudio a partir de texto.
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 ) ) ;
} ) ;
Editando configurações de voz.
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 ) ;
} ) ;
Obtendo configurações de voz.
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 ) ;
} ) ;
Excluir voz.
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 ) ;
} ) ;
Obtendo detalhes de voz.
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 ) ;
} ) ;
Obtendo todos os detalhes de voz.
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 ) ;
} ) ;
Obtendo todos os detalhes do modelo.
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 ) ;
} ) ;
Obtendo informações do usuário associadas à chave de 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 ) ;
} ) ;
Obtendo informações de assinatura do usuário associadas à chave de 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 ) ;
} ) ;
Obtendo configurações de voz padrão.
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 ) ;
} ) ;
Contribuições são bem-vindas :)
Leia nosso CONTRIBUTING.md para saber mais.