Paket Eleven Labs NodeJS untuk mengonversi teks menjadi ucapan!
Laporkan Bug · Fitur Permintaan
Kunjungi kami di GitHub untuk membantu proyek ini menjadi lebih baik!
Ini adalah paket NodeJS Eleven Labs open source untuk mengonversi teks menjadi ucapan menggunakan API Eleven Labs.
Fungsi | Parameter | Titik akhir |
---|---|---|
textToSpeech | ({voiceId, fileName, textInput, stabilitas, kesamaanBoost, modelId, gaya, speakerBoost}) | /v1/text-to-speech/{voice_id} |
textToSpeechStream | ({voiceId, textInput, stabilitas, kesamaanBoost, modelId, responType, gaya, speakerBoost}) | /v1/text-to-speech/{voice_id}/stream |
editVoiceSettings | ({voiceId, stabilitas, kesamaanBoost}) | /v1/voices/{voice_id}/settings/edit |
getVoiceSettings | ({voiceId}) | /v1/voices/{voice_id}/settings |
deleteVoice | ({voiceId}) | /v1/voices/{voice_id} |
getVoice | ({voiceId}) | /v1/voices/{voice_id} |
getVoices | T/A | /v1/voices |
getModels | T/A | /v1/models |
getUserInfo | T/A | /v1/user |
getUserSubscription | T/A | /v1/user/subscription |
getDefaultVoiceSettings | T/A | /v1/voices/settings/default |
Variabel | Keterangan | Jenis |
---|---|---|
fileName | Nama dan jalur file untuk file audio Anda misalnya ( ./gen/hello ) | String |
textInput | Teks yang akan diubah menjadi audio misal ( Hello ) | String |
stability | Stabilitas untuk Text to Speech default ( 0 ) | Float |
similarityBoost | Peningkatan Kemiripan untuk Text to Speech default ( 0 ) | Float |
voiceId | ID Suara ElevenLabs misalnya ( pNInz6obpgDQGcFmaJgB ) | String |
modelId | ID Model ElevenLabs misalnya ( eleven_multilingual_v2 ) | String |
responseType | Jenis respons streaming misalnya ( stream ) | String |
speakerBoost | Peningkatan Speaker untuk Text to Speech misalnya ( true ) | Boolean |
style | Gaya Berlebihan untuk Text to Speech (0-100) default ( 0 ) | Integer |
Untuk menginstal paket Elevenlabs, jalankan perintah berikut:
npm install elevenlabs-node
Siapkan konfigurasi ElevenLabs untuk proyek Anda.
Variabel | Keterangan | Bawaan |
---|---|---|
apiKey | ( Required ) Kunci API Anda dari Elevenlabs | T/A |
voiceId | ( Optional ) ID Suara dari Elevenlabs | Adam ( pNInz6obpgDQGcFmaJgB ) |
const ElevenLabs = require ( "elevenlabs-node" ) ;
const voice = new ElevenLabs (
{
apiKey : "0e2c037kl8561005671b1de345s8765c" , // Your API key from Elevenlabs
voiceId : "pNInz6obpgDQGcFmaJgB" , // A Voice ID from Elevenlabs
}
) ;
Menghasilkan file audio dari teks.
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 ) ;
} ) ;
Menghasilkan aliran audio dari teks.
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 ) ) ;
} ) ;
Mengedit pengaturan suara.
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 ) ;
} ) ;
Mendapatkan pengaturan suara.
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 ) ;
} ) ;
Hapus suara.
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 ) ;
} ) ;
Mendapatkan detail suara.
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 ) ;
} ) ;
Mendapatkan semua detail suara.
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 ) ;
} ) ;
Mendapatkan semua detail model.
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 ) ;
} ) ;
Mendapatkan info pengguna yang terkait dengan Kunci 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 ) ;
} ) ;
Mendapatkan info langganan pengguna yang terkait dengan Kunci 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 ) ;
} ) ;
Mendapatkan pengaturan suara default.
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 ) ;
} ) ;
Kontribusi dipersilakan :)
Baca CONTRIBUTING.md kami untuk mempelajari lebih lanjut.