栖居在城市的大地上,分享城市中的感想予你,在留言板留下你的足迹,希望你在这里有所收获,祝幸运

开源AudioCraft:文字生成音频、音乐以及音效,所有人都可以使用

AudioCraft由三种型号组成:MusicGen、AudioGen和EnCodec。

MusicGen接受过拥有和专门许可的音乐训练,从基于文本的用户输入生成音乐,而接受过公共音效训练的AudioGen则从基于文本的用户输入生成音频。
EnCodec解码器的改进版本,该解码器允许以更少的文件生成更高质量的音乐;
经过预先训练的AudioGen模型,可让您产生环境声音声音效果,如狗吠叫、汽车喇叭声或木地板上的脚步声;
官网地址:audiocraft.metademolab.com
github地址:github.com/facebookresearch/audiocraft

因需要16G的GPU,这里就在 Google Colaboratory 进行创建


# Colab运行代码:
# Adapted from https://github.com/camenduru/MusicGen-colab
%cd /content
!git clone https://github.com/facebookresearch/audiocraft
%cd /content/audiocraft
# DO NOT RESTART THE NOTEBOOK WHEN ASKED TO DO SO, it is not necessary at all!
!pip install -r requirements.txt
# Click on the gradio link that appear (starting with `public URL:`).
!python -m demos.musicgen_app --share
# See also https://colab.research.google.com/drive/1fxGqfg96RBUvGxZ1XXN07s3DthrKUl4-?usp=sharing
# for a Colab demo using the underlying API instead.

体验地址:huggingface.co/spaces/facebook/MusicGen


MusicGen Gradio Demo

安装:


# @title Execute first for installing AudioCraft
# @markdown Execute this cell to install AudioCraft. (**Note:** the `pip install` stage might take a while.)
from pathlib import Path
import subprocess as sp
from shutil import rmtree
import re
import time

def run_log_on_fail(name, *args, **kwargs):
    log = log_folder / (name + ".log")
    print("Running stage", name)
    try:
        sp.run(*args, **kwargs, stdout=open(log, 'w'), stderr=sp.STDOUT, check=True)
    except sp.CalledProcessError:
        print(f"Stage {name} failed, this is NOT expected, see logs hereafter.")
        print(open(log, 'r').read())
        raise
    else:
        return log

def install():
    global log_folder
    ac_folder = Path('/content/audiocraft')
    log_folder = Path('/content/logs')
    log_folder.mkdir(exist_ok=True, parents=True)
    if ac_folder.exists():
        rmtree(ac_folder)
    try:
        run_log_on_fail("git clone", ["git", "clone", "https://github.com/facebookresearch/audiocraft"], cwd=ac_folder.parent)
        run_log_on_fail("pip install", ["pip", "install", "-e", "."], cwd=ac_folder)
        pass
    except sp.CalledProcessError:
        print("INSTALLATION FAILED...")
        return
install()

演示:


#@title Execute then to launch the demo
#@markdown Wait until you see `Running on public URL: ` in the link with a *.gradio.live url. Click on the URL, and enjoy!
!cd /content/audiocraft && python -m demos.musicgen_app --share
开源AudioCraft:文字生成音频、音乐以及音效,所有人都可以使用

https://guoshuaifu.cn/archives/406.html

作者

Disheng

发布时间

2023年11月14日

许可协议

CC BY 4.0

添加新评论