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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With