ElevenLabsLib是否有保存/导出功能?

huangapple go评论49阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年4月4日 09:31:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/75924852.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定