¡Paquete NodeJS de Eleven Labs para convertir texto a voz!
Informar error · Solicitar función
¡Envíanos un mensaje en GitHub para ayudar a mejorar el proyecto!
Este es un paquete NodeJS de Eleven Labs de código abierto para convertir texto a voz utilizando la API de Eleven Labs.
Función | Parámetros | Punto final |
---|---|---|
textToSpeech | ({voiceId, fileName, textInput, estabilidad, similarityBoost, modelId, estilo, altavozBoost}) | /v1/text-to-speech/{voice_id} |
textToSpeechStream | ({voiceId, textInput, estabilidad, similarityBoost, modelId, ResponseType, estilo, SpeakerBoost}) | /v1/text-to-speech/{voice_id}/stream |
editVoiceSettings | ({voiceId, estabilidad, similitudBoost}) | /v1/voices/{voice_id}/settings/edit |
getVoiceSettings | ({identificador de voz}) | /v1/voices/{voice_id}/settings |
deleteVoice | ({identificador de voz}) | /v1/voices/{voice_id} |
getVoice | ({identificador de voz}) | /v1/voices/{voice_id} |
getVoices | N / A | /v1/voices |
getModels | N / A | /v1/models |
getUserInfo | N / A | /v1/user |
getUserSubscription | N / A | /v1/user/subscription |
getDefaultVoiceSettings | N / A | /v1/voices/settings/default |
Variable | Descripción | Tipo |
---|---|---|
fileName | Nombre y ruta del archivo de audio, por ejemplo ( ./gen/hello ) | String |
textInput | Texto que se convertirá en audio, por ejemplo ( Hello ) | String |
stability | Estabilidad para texto a voz predeterminada ( 0 ) | Float |
similarityBoost | Aumento de similitud para texto a voz predeterminado ( 0 ) | Float |
voiceId | ID de voz de ElevenLabs, por ejemplo ( pNInz6obpgDQGcFmaJgB ) | String |
modelId | ID de modelo de ElevenLabs, por ejemplo ( eleven_multilingual_v2 ) | String |
responseType | Tipo de respuesta de transmisión, por ejemplo ( stream ) | String |
speakerBoost | Aumento del altavoz para texto a voz, por ejemplo ( true ) | Boolean |
style | Exageración de estilo para texto a voz (0-100) predeterminado ( 0 ) | Integer |
Para instalar el paquete Elevenlabs, ejecute el siguiente comando:
npm install elevenlabs-node
Configura las configuraciones de ElevenLabs para tu proyecto.
Variable | Descripción | Por defecto |
---|---|---|
apiKey | ( Required ) Tu clave API de Elevenlabs | N / A |
voiceId | ( Optional ) Un ID de voz de Elevenlabs | Adán ( pNInz6obpgDQGcFmaJgB ) |
const ElevenLabs = require ( "elevenlabs-node" ) ;
const voice = new ElevenLabs (
{
apiKey : "0e2c037kl8561005671b1de345s8765c" , // Your API key from Elevenlabs
voiceId : "pNInz6obpgDQGcFmaJgB" , // A Voice ID from Elevenlabs
}
) ;
Generando un archivo de audio 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 ) ;
} ) ;
Generar una secuencia de audio 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 ) ) ;
} ) ;
Edición de configuraciones 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 ) ;
} ) ;
Obteniendo configuración 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 ) ;
} ) ;
Eliminar 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 ) ;
} ) ;
Obteniendo detalles 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 ) ;
} ) ;
Obteniendo todos los detalles 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 ) ;
} ) ;
Obteniendo todos los detalles del 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 ) ;
} ) ;
Obtener información del usuario asociada con la clave 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 ) ;
} ) ;
Obtener información de suscripción del usuario asociada con la clave 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 ) ;
} ) ;
Obteniendo la configuración de voz predeterminada.
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 ) ;
} ) ;
Se aceptan aportes :)
Lea nuestro CONTRIBUTING.md para obtener más información.