テキストを音声に変換するための イレブン ラボ NodeJS パッケージ!
バグ報告・機能リクエスト
プロジェクトの改善に協力するために GitHub に投稿してください。
これは、イレブン ラボ API を使用してテキストを音声に変換するためのオープン ソースの イレブン ラボ NodeJS パッケージです。
関数 | パラメータ | 終点 |
---|---|---|
textToSpeech | ({voiceId、fileName、textInput、安定性、similarityBoost、modelId、style、speakerBoost}) | /v1/text-to-speech/{voice_id} |
textToSpeechStream | ({voiceId、textInput、安定性、similarityBoost、modelId、responseType、style、speakerBoost}) | /v1/text-to-speech/{voice_id}/stream |
editVoiceSettings | ({voiceId、安定性、類似性ブースト}) | /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 | 該当なし | /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 | Text to Speech の安定性のデフォルト ( 0 ) | Float |
similarityBoost | テキスト読み上げの類似性ブーストのデフォルト ( 0 ) | Float |
voiceId | イレブンラボの音声ID 例: ( pNInz6obpgDQGcFmaJgB ) | String |
modelId | イレブンラボのモデルID 例: ( eleven_multilingual_v2 ) | String |
responseType | ストリーミング応答タイプ 例: ( stream ) | String |
speakerBoost | Text to Speech のスピーカー ブースト 例 ( true ) | Boolean |
style | テキスト読み上げのスタイル誇張 (0-100) デフォルト ( 0 ) | Integer |
イレブンラボ パッケージをインストールするには、次のコマンドを実行します。
npm install elevenlabs-node
プロジェクトの Celebrities 構成をセットアップします。
変数 | 説明 | デフォルト |
---|---|---|
apiKey | ( Required ) イレブンラボからの API キー | 該当なし |
voiceId | ( Optional ) イレブンラボの音声 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 をお読みください。