python-3.x ElevenLabsLib是否有保存/导出功能?

mwecs4sa  于 2023-05-30  发布在  Python
关注(0)|答案(1)|浏览(178)

我想将Elevenlab生成的音频文件保存到一个文件夹中,但我不确定库中是否有保存或导出功能。我尝试使用pydub,因为我在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")

我只想自动将音频文件保存到savelocation文件夹中。

zzwlnbp8

zzwlnbp81#

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 save

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

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

相关问题