01

引言

上海交大x-lance跨媒体语言智能实验室联合剑桥大学、吉利汽车研究院(宁波)公司开源了一种基于流匹配的扩散变换器(Diffusion Transformer,DiT)的完全非自回归TTS模型-F5-TTS。F5-TTS不需要复杂的模型设计,如持续时间模型、文本编码器和音素对齐等,只需要将输入文本填充为与输入语音相同的长度,并进行去噪以生成语音,这最初由E2-TTS证明是可行的。然而,E2-TTS的设计使得其收敛速度慢且鲁棒性低。为了解决这些问题,F5-TTS首先使用ConvNeXt来细化文本表示,使其更容易与语音对齐。

 

此外,F5-TTS还提出了一种在推理时采样的策略,显著提高了模型性能和效率。这种flow step的采样策略可以轻松应用于现有的基于flow matching的模型而无需重新训练。F5-TTS的设计允许更快的训练并实现0.15的推理RTF,相比最先进的扩散式TTS模型有了很大的提高。在公共的多语言100万小时数据集上训练后,F5-TTS生成的语音具有高度自然和表达性的零样本能力、无缝代码切换能力和速度控制效率。

代码链接:

https://github.com/SWivid/F5-TTS

模型链接:

https://modelscope.cn/models/SWivid/F5-TTS_Emilia-ZH-EN

https://modelscope.cn/models/SWivid/E2-TTS_Emilia-ZH-EN

体验链接(pc访问):

https://modelscope.cn/studios/modelscope/E2-F5-TTS

论文链接:

https://arxiv.org/abs/2410.06885

02

模型效果

零样本生成

Prompt

Same Language Generation

I don't really care what you call me. I've been a silent spectator, watching species evolve, empires rise and fall. But always remember, I am mighty and enduring. Respect me and I'll nurture you; ignore me and you shall face the consequences.

Cross-linugal Generation

顿时,气氛变得沉郁起来。乍看之下,一切的困扰仿佛都围绕在我身边。我皱着眉头,感受着那份压力,但我知道我不能放弃,不能认输。于是,我深吸一口气,心底的声音告诉我:“无论如何,都要冷静下来,重新开始。”

 

速度控制

Prompt

Text

I don't really care what you call me. I've been a silent spectator, watching species evolve, empires rise and fall. But always remember, I am mighty and enduring. Respect me and I'll nurture you; ignore me and you shall face the consequences.

情感

Emotion

Calm/冷静的

Prompt

Text

So, I was, like, at the, um, grocery store, and, uh, I saw this, like, really yummy-looking, um, cake, y’know? And I, uh, totally wanted to, like, buy it, but, um, I was, like, on a diet, so, uh, I just, like, stared at it for a while, y’know?

 

鲁棒性等更多效果,请至合集查看:

https://swivid.github.io/F5-TTS/#zero-shot

03

魔搭最佳实践

在魔搭社区的PAI-DSW免费算力(A10)上体验F5-TTS

目前单次生成支持 30 秒,即提示音频和生成音频的总inference-cli长度。和支持使用块进行批量推理gradio_app。

  • 为了避免可能出现的推理失败,请确保您已阅读完以下说明。

  • 较长的提示音允许生成较短的输出。超过 30 秒的部分无法正常生成。请考虑使用小于 15 秒的提示音。

  • 大写字母会逐个字母地发音,因此对于普通单词请使用小写字母。

  • 添加一些空格(空白:“”)或标点符号(例如“,” “。”)以明确引入一些停顿。如果在代码转换生成中跳过前几个单词(因为不同语言的速度不同),这可能会有所帮助。

环境安装

下载repo

git clone https://github.com/SWivid/F5-TTS.git
cd F5-TTS

安装其他依赖:

pip install -r requirements.txt

模型下载

下载vocos-mel-24khz模型:

modelscope download --model=pengzhendong/vocos-mel-24khz --local_dir ../checkpoints/charactr/vocos-mel-24khz

下载模型文件:

modelscope download --model=SWivid/F5-TTS_Emilia-ZH-EN  --local_dir ./ckpts/ F5TTS_Base/model_1200000.bin
modelscope download --model=SWivid/E2-TTS_Emilia-ZH-EN  --local_dir ./ckpts/ E2TTS_Base/model_1200000.bin

模型推理

使用inference-cli推理

python inference-cli.py \
--model "F5-TTS" \
--ref_audio "tests/ref_audio/test_en_1_ref_short.wav" \
--load_vocoder_from_local \
--ref_text "Some call me nature, others call me mother nature." \
--gen_text "I don't really care what you call me. I've been a silent spectator, watching species evolve, empires rise and fall. But always remember, I am mighty and enduring. Respect me and I'll nurture you; ignore me and you shall face the consequences."

python inference-cli.py \
--model "E2-TTS" \
--ref_audio "tests/ref_audio/test_zh_1_ref_short.wav" \
--load_vocoder_from_local \
--ref_text "对,这就是我,万人敬仰的太乙真人。" \
--gen_text "突然,身边一阵笑声。我看着他们,意气风发地挺直了胸膛,甩了甩那稍显肉感的双臂,轻笑道,我身上的肉,是为了掩饰我爆棚的魅力,否则,岂不吓坏了你们呢?"

模型WebUI

目前支持的功能:

  • 模型推理

  • Podcast Generation

  • Multiple Speech-Type Generation

可以启动 Gradio 应用程序(Web 界面)来启动 GUI 进行推理,目前一次加载 ASR 模型、F5-TTS 和 E2 TTS,因此比 使用的 GPU 内存更多inference-cli。

git clone https://www.modelscope.cn/studios/modelscope/E2-F5-TTS.git
cd E2-F5-TTS
python app.py

注:如涉及Vocos.from_pretrained不支持local_dir,可以尝试修改Vocos源码

@classmethod
    def from_pretrained(cls, local_dir: str, repo_id: str = None, revision: Optional[str] = None) -> Vocos:
        """
        Class method to create a new Vocos model instance from a pre-trained model stored in the Hugging Face model hub.
        """
        if local_dir:
            config_path = os.path.join(local_dir, "config.yaml")
            model_path = os.path.join(local_dir, "pytorch_model.bin")
        elif repo_id:
            config_path = hf_hub_download(repo_id=repo_id, filename="config.yaml", revision=revision)
            model_path = hf_hub_download(repo_id=repo_id, filename="pytorch_model.bin", revision=revision)

 

点击链接👇,即可跳转体验~

https://modelscope.cn/studios/modelscope/E2-F5-TTS

Logo

ModelScope旨在打造下一代开源的模型即服务共享平台,为泛AI开发者提供灵活、易用、低成本的一站式模型服务产品,让模型应用更简单!

更多推荐