Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does ElevenLabsLib have a save/export function?

I want to save the audio file that Elevenlab generates into a folder, but I'm not sure if there is a save or export function in the library. I tried using pydub because I couldn't find an export function in elevenlabslib.

from elevenlabslib import *
from pydub import AudioSegment


user = ElevenLabsUser("Blalalal")
voice = user.get_voices_by_name("Elli")[0] 
savelocation = "C:\Users\BattleShip\Desktop\work\Voices"

voice.generate_and_play_audio("This is a Test. This means it is working.", playInBackground=False)
audio = AudioSegment.from_file(voice) #this is probably the problem where voice isn't a wav or mp3
audio.export(savelocation, format="wav")


I just want to automatically save the audio file into the savelocation folder.

like image 859
Electro Avatar asked Sep 03 '25 13:09

Electro


1 Answers

from elevenlabs import generate, play, set_api_key, save

voice = generate(
    text="Hi! I'm the world's most advanced text-to-speech system, made by 
    elevenlabs.",
    voice="Bella"
)
save(voice,'test.wav')

Format:

from elevenlabs import save

save(
    audio: bytes,               # Audio bytes (returned by generate)
    filename: str               # Filename to save audio to (e.g. "audio.wav")
) -> None

Source: https://github.com/elevenlabs/elevenlabs-python/blob/main/API.md

like image 171
Areeba Seher Avatar answered Sep 05 '25 01:09

Areeba Seher