FelixWaweru / elevenlabs-node

Eleven Labs text to speech package for NodeJS. You can use the official package at: https://www.npmjs.com/package/elevenlabs
https://www.npmjs.com/package/elevenlabs-node
MIT License
169 stars 25 forks source link

Alternative Audio Storage Option #36

Closed dcts closed 11 months ago

dcts commented 1 year ago

Is your feature request related to a problem? Please describe. I would like to generate speech using text-to-speech API, then store the mp3 not locally on my machine, but on a server (or in a amazon bucket or firease storage bucket). The way the repo is currently structured, this seems not to be supported.

Describe the solution you'd like Ideally an alternative return value in form of the blob audio should be provided (instead of writing to the filesystem).

Describe alternatives you've considered Using elevenlabs API directly (which I'm doing currently).

FelixWaweru commented 12 months ago

Thanks for raising the issue @dcts

If you're using V1, you can change the response type like this

const voiceResponse = voice.textToSpeechStream({
    textInput:       "mozzy is cool",                // The text you wish to convert to speech
    responseType:    "arraybuffer",               // The streaming type (arraybuffer, stream, json)
  });

We're using Axios to make our requests which has limited support for Blob streaming however you can use ArrayBuffers instead.

You can also check the V2 docs to reference different variables you can pass.