#I d need more information like the code

1 messages · Page 1 of 1 (latest)

jade basin
#

Yeah ofcourse let me share that

#

This is the conversion func :

def convert_to_wav(mp3_data):
# Read MP3 audio data into an AudioSegment object
mp3_audio = AudioSegment.from_file(io.BytesIO(mp3_data))
# Create a BytesIO object to hold the WAV data
wav_io = io.BytesIO()
# Export the audio to WAV format into the BytesIO object
mp3_audio.export(wav_io, format="wav")
# Get the WAV byte data
wav_data = wav_io.getvalue()
return wav_data

#

for audio in elevenlabs.generate(text_gen):
yield convert_to_wav(audio)

thorn citrus
#

so text_gen() is a string iterator, right? So you're doing input streaming?

jade basin
#

yes

thorn citrus
#

and you mentioned you were already decoding the base64 data

#

I think the problem is that you're assuming each chunk of audio you get back is a complete mp3 file

#

which it isn't

#

doing on the fly conversion like that is a lot harder, I believe

#

my suggestions are:

  1. if you specifically need wav audio, use the pcm output_format
  2. if you just want to stream the audio, look into some other method
#

it depends on what you're trying to achieve

jade basin
#

I see so just to summarize even though we are receiving audio chunks, it might be that the chunks are not complete but are partial files.

thorn citrus
#

for example, only the very first chunk will contain the header

#

(it might be split across multiple chunks even but still, you get the picture)

jade basin
#

Yes now I get the whole picture

#

btw when you said looking into other methods? what else is there for streaming?

#

I mean I have come across the generate_stream and generate_stream_input functions

#

Thank you so much @thorn citrus

thorn citrus
#

you'd either need to do something custom, or maybe look into how the unofficial elevenlabslib wrapper (mine) does it

#

which is...complicated, to say the least, but it does work well

#

like I said, depends on your usecase