英文:
Does ElevenLabsLib have a save/export function?
问题
audio.export(savelocation, format="wav")
英文:
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.
答案1
得分: 2
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')
英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论