读见

深入了解 Phonon TTS:推出高品质端侧语音,基准测试表现领先

原题A Closer Look at Phonon TTS. Launching High-Quality On-Device Speech That Tops the Benchmarks.

约 6 分钟约 1,318 字原文英文已翻译

读前速览

5 个要点

Phonon TTS 是一款开放权重文本转语音模型,可在端侧生成高品质语音,支持 5 种语言,并在 Hugging Face Open TTS Leaderboard 的清晰度和速度排名中领先,同时支持自定义声音克隆。

  1. 无需依赖云端的端侧语音

    Phonon 完全在用户设备上运行,无需服务器或网络连接。文本留在本地,有助于保护隐私,也能用于没有信号的移动设备等离线场景。

  2. 清晰度与速度方面的基准测试领先

    Phonon 在 Hugging Face Open TTS Leaderboard 的德语和西班牙语清晰度排名中位居第一,并在 CPU 流式速度方面领先,首音频延迟最低可达 28ms,表现优于规模大至其 100 倍的模型。

  3. 流匹配架构兼顾小体积与高品质

    Phonon 延续 Pocket TTS 的技术路线,采用流匹配技术自回归生成音频潜变量。这种方法让仅有 31M 参数的紧凑模型也能生成高品质音频,打破了模型规模与音频保真度之间的传统权衡。

  4. 支持自定义声音克隆与模块化集成

    Phonon 通过预计算的说话人潜变量支持创建自定义声音,并以模块化模型的形式集成到 Transformers 中。它与 Pocket TTS 的差异仅涉及 200 行代码,便于开发者采用和扩展。

  5. ptts 框架提供广泛的硬件支持

    ptts 推理框架支持 10 多种后端,包括 CPU(Intel、Arm、WebAssembly)、GPU(CUDA、Vulkan、Metal、WebGPU)和 NPU(Apple Core ML、Snapdragon),可部署在从手机到单板计算机等多种设备上。

完整摘要

Phonon TTS 是一款面向端侧部署的开放权重文本转语音模型,无需云服务器或网络连接。模型提供两种规格(31M 和 40M 参数),支持英语、法语、德语、西班牙语和葡萄牙语,并内置 100 多种声音。Phonon 在基准测试中表现出色,在德语和西班牙语清晰度方面排名第一,并在 CPU 流式速度方面领先,首音频延迟最低可达 28ms。Phonon 基于 Pocket TTS 的技术脉络构建,采用流匹配技术,突破了模型大小与音频质量之间的传统权衡。它支持通过预计算的说话人潜变量克隆自定义声音,并从 Transformers v5.21 起以模块化模型形式集成其中。配套的 ptts 推理框架支持 10 多种后端,包括 CPU、GPU 和 NPU,可部署在手机、笔记本电脑和浏览器等设备上。开发者已将 Phonon 用于从离线移动体验到基于浏览器的 AI 集成等多种应用;该模型在推出后的前两周下载量超过 200,000 次。

目录 · 6 节

查看原文
Two weeks ago, we opened up Phonon, our small text-to-speech model that runs on your own device. It needs no server and no network, and what you type stays with you.

到目前为止,大家的反响让我们非常满意。下面就来讲讲这次发布:我们为什么打造 Phonon、它能做什么、随之推出的演示,以及它在 Hugging Face 的 Open TTS Leaderboard 上的表现。We've been very happy with the reception so far. So here's the story of the launch: why we built Phonon, what it can do, the demos that came with it, and how it did on Hugging Face's Open TTS Leaderboard.

为什么语音应该保留在你的设备上 Why a voice should live on your device

大多数语音 AI 都运行在云端:每句话都要往返服务器。Phonon 则直接在你的设备上运行。文本会留在设备上,即使没有网络,语音功能也能正常使用。我们还开放了模型权重。Phonon 31m 采用 Apache 2.0 许可,因此你可以免费使用,甚至用于商业产品。其他模型采用 CC BY-NC 许可,可免费用于非商业项目。如果你想用它们开发商业产品,定价依据是用户数量,而不是生成的语音时长。Most voice AI lives in the cloud: every sentence makes a round trip to a server. Phonon runs on your own device instead. Your text stays there and the voice works without a network. We’ve also opened the weights. Phonon 31m is Apache 2.0, so you can use it for free, even in a commercial product. The other models are CC BY-NC, so they’re free for non-commercial projects. If you’re building something commercial with those, pricing is based on your number of users, not how much speech you generate.

让高质量语音在小型设备上运行一直很难。你可以缩小模型,但声音效果就不够好;也可以追求出色的音质,但模型又装不下。我们同时解决了这两个问题。Getting a good voice to run on a small device has always been hard. You could make the model small, but then it didn’t sound great. Or you could make it sound great, but then it wouldn’t fit. We addressed both.

我们于四月发布了 Phonon,随后六个月与合作伙伴和早期用户共同持续完善它。他们的反馈帮助我们打磨了这一版本。模型变得更小巧,我们还增加了更多语言,并通过语音克隆和语音设计支持自定义声音。We announced Phonon in April and spent the next six months building on it with partners and early users. Their feedback helped us to shape this release. The models got smaller, and we added more languages and support for custom voices through voice cloning and voice design.

Phonon 源自 Pocket TTS 技术体系,因此采用流匹配来生成音频,这与其他 TTS 系统使用的建模技术截然不同。正是这种方法让我们得以在如此小的模型中实现这样的质量,但也给模型训练带来了新的挑战。训练过程最初数值不稳定,需要采用一些技巧,才能在全部五种语言上取得高质量的结果。Phonon is based on the Pocket TTS lineage and as such uses flow matching to generate the audio which is very different from the modeling techniques used in other TTS systems. This is what allowed us to bring this level of quality to such a small model but it created new challenges while training the models. The training was initially numerically unstable and required several tricks to produce quality results on all five languages.

我们发布的内容 What we released

Phonon 有两种规格,大小约为 65 MB 和 75 MB。两者合起来支持英语、法语、德语、西班牙语和葡萄牙语。它内置了 100 多种语音,你也可以在 Gradium Studio 中创建自己的语音。Phonon 还能准确处理许多其他 TTS 系统常常难以应对的重要内容,例如电话号码、日期和代码。Phonon comes in two sizes, at about 65 MB and 75 MB. Together they speak English, French, German, Spanish and Portuguese. There are more than 100 built-in voices, and you can create your own in Gradium Studio. Phonon also handles the important things that most other TTS systems often stumble on, like phone numbers, dates and codes.

它可以在手机、笔记本电脑、单板计算机和浏览器标签页中运行,因此你现在就可以听到它。Phonon 31m 支持英语,采用 Apache 2.0 许可证,因此你可以自由地基于它进行开发,包括用于商业产品。Phonon 40m 支持全部五种语言,但采用非商业许可证。It runs on phones, laptops, single-board computers and in a browser tab, so you can hear it right now. Phonon 31m speaks English and is Apache 2.0, so you can build on it freely, including for commercial products. Phonon 40m covers all five languages under a non-commercial license.

演示和首批项目 Demos and first projects

发布时,我们展示了朋友和团队成员制作的演示。在关闭 Wi-Fi 的 Apple Watch 上,Phonon 会一步步指导你冲咖啡。在没有信号的 iPhone 上,它会帮你数训练次数,并鼓励你坚持下去。Autonomous 推出的机器人 Lamp 戴着一顶分院帽,用角色的口吻说话。在浏览器中,离线恐龙跑酷游戏变成了由 Rex 主持的广播节目。此外,还有一款在玩家自己的设备上配音的科幻游戏,以及逐页朗读的普鲁斯特作品。The launch came with demos from friends and from our own team. On an Apple Watch with Wi-Fi off, Phonon talks you through a coffee brew step by step. On an iPhone with no signal, it counts your reps and keeps you going. A robot called Lamp, from Autonomous, wears a sorting hat and talks in character. In a browser, an offline dino runner becomes a radio show hosted by Rex. There's also a sci-fi game voiced on the player's own machine, and Proust read aloud page by page.

Hugging Face 团队构建了 Transformers 集成,因此开发者从第一天起就能在 Transformers 中使用 Phonon。The Hugging Face team built the Transformers integration, so developers could use Phonon in Transformers from day one.

开发者也开始基于它进行开发。通过 ExecuTorch 转换,可以在浏览器中利用访客的 GPU 运行 Phonon;Micdrop 则将它引入 Node.js 应用,而 smallest-s2s 等 Spaces 也构建于其之上。Developers have started building on it too. An ExecuTorch conversion runs Phonon on a visitor's GPU in the browser, Micdrop brings it to Node.js apps, and Spaces like smallest-s2s build on it.

Phonon 在上线后的前两周下载量超过 20 万次,目前仍在 Hugging Face 上持续走红。Phonon was downloaded more than 200,000 times in its first two weeks, and it’s still trending on Hugging Face.

Phonon 在 Hugging Face Open TTS 排行榜上的表现 How Phonon did on the Hugging Face Open TTS Leaderboard

Open TTS Leaderboard 是 Hugging Face 推出的一个全新项目,我们非常喜欢它。Hugging Face Hub 上有超过 9,000 个 TTS 模型,这个排行榜为开发者提供了一个统一的平台,可以比较开放模型并试听它们的效果。排行榜涵盖 23 种语言,从可懂度(输出内容的词错误率)、速度(实时因子的倒数和首段音频生成时间)以及自然度(英语的 UTMOS 和韩语的 KOMOS)等方面对模型进行评估。评估对象包括固定音色和声音克隆;对于后者,还会额外评估说话人相似度。排行榜还设有“试听”标签页,方便你亲自比较 TTS 输出,并为最喜欢的结果投票。The Open TTS Leaderboard is a very new project from Hugging Face, and we love it. With more than 9,000 TTS models on the Hugging Face Hub, the leaderboard gives developers one place to compare open models and hear them side by side. Across 23 languages, models are evaluated on intelligibility (word error rate of the outputs), speed (inverse real-time factor and time-to-first audio), and naturalness (UTMOS for English and KOMOS for Korean). Fixed-voice and voice cloning are evaluated, with an additional speaker similarity metric for the latter. The leaderboard also has a Listen tab, where you can conveniently compare TTS outputs yourself and vote for the ones you like the most.

在可懂度方面,Phonon 在德语和西班牙语中排名第一,在我们评测的所有语言中均跻身前三,与规模最大可达其 100 倍的模型并驾齐驱。On intelligibility, Phonon ranks first in German and Spanish, and in the top three in every language we evaluated, next to models up to 100 times its size.

速度是 Phonon 真正大放异彩的领域:这些模型在 CPU 流式处理基准测试的首个音频输出时间指标上名列前茅。Speed is where we see Phonon truly shine, as the models top the CPU streaming benchmark on time-to-first audio.

Bar chart of the top 10 models by 95th-percentile time to first audio. Phonon 31m en is first at 28 ms and Phonon 40m en is second at 38 ms, ahead of Pocket TTS at 165 ms. Lower is better.

推理 Inference

我们专门为 Phonon 构建了一个全新的推理框架 ptts。ptts 旨在让各种设备都能实现最佳性能,因此支持 10 多种后端:CPU(Intel、Arm、WebAssembly)、GPU(CUDA、Vulkan、Metal、WebGPU)和 NPU(Apple Core ML、Snapdragon®)。We built a new inference framework, ptts, specifically for Phonon. The goal of ptts is to get the best performance on a wide variety of devices and as such supports more than 10 backends: CPU (Intel, Arm, WebAssembly), GPU (CUDA, Vulkan, Metal, WebGPU), and NPU (Apple Core ML, Snapdragon®).

从 v5.21 起,🤗 Transformers 也提供 Phonon,作为其参考 PyTorch 实现。ptts 在设备上运行单个流,而 Transformers 面向 GPU 吞吐量:支持批量生成和全图 torch.compile,例如大规模合成语音数据集。作为原生 PyTorch 实现,它也为后续开发提供了基础,无论是将 Phonon 集成到你自己的技术栈中,还是研究模型本身。Phonon is also available in 🤗 Transformers, from v5.21, as its reference PyTorch implementation. Where ptts runs a single stream on device, Transformers targets GPU throughput: batched generation, full-graph torch.compile, e.g., for synthesizing speech datasets at scale. Being native PyTorch, it is a base to build upon, whether to integrate Phonon into your own stack or to study the model itself.

它属于 Pocket TTS 系列,因此我们首先将 Pocket TTS 添加到了 Transformers 中。Phonon 则作为一个模块化模型构建在其之上:大约 200 行代码,只描述与之不同的部分。It belongs to the Pocket TTS lineage, so we first added Pocket TTS to Transformers. Phonon sits on top as a modular model: about 200 lines describing only what differs.

Phonon 以自回归方式生成音频潜变量:每一步都会输出一个潜变量,并将其反馈为下一步的输入,同时训练损失也在这些潜变量上计算。潜变量是模型的输入、输出和目标,正如文本 token 对语言模型而言一样,因此将音频映射为潜变量的编解码器扮演着分词器的角色。Transformers 也将其作为音频分词器提供,由处理器与文本分词器一同持有:Phonon generates audio latents autoregressively: each step outputs a latent that is fed back as the next input, and the training loss is computed on them. Latents are the model's inputs, outputs and targets, as text tokens are for a language model, so the codec mapping audio to latents plays the role of a tokenizer. Transformers ships it as such: an audio tokenizer, held by the processor next to the text tokenizer:

from transformers import AutoProcessor, GradiumPhononTTSForConditionalGeneration

model_id = "gradium/phonon-31m-en"
processor = AutoProcessor.from_pretrained(model_id, device_map="auto")
model = GradiumPhononTTSForConditionalGeneration.from_pretrained(model_id, device_map="auto")

print(f"{model.num_parameters():,}")  # 30,788,354
print(f"{processor.audio_tokenizer.num_parameters():,}")  # 10,305,313

声音并非一段录音,而是一个说话人潜变量张量。Phonon 从不使用其音频分词器直接对音频进行编码;该分词器随附时仅支持解码,而语音则是预先计算好的:gradium/phonon-voices。A voice is not a recording but a tensor of speaker latents. Phonon never encodes audio directly with its audio tokenizer, which ships decoder-only, and voices come precomputed: gradium/phonon-voices.

from huggingface_hub import hf_hub_download
from safetensors.torch import load_file

path = hf_hub_download("gradium/phonon-voices", "voices/LMDIYE0Oa377Qh6Z.safetensors")
voice = load_file(path)["speaker_wavs"][0].T  # (num_frames, 512)

提示布局(语音位置、文本,然后是用于开启音频的 token)作为聊天模板随检查点一起提供,这与 Transformers 中的其他多模态模型相同。你只需编写标准对话,在语音所在位置放置一个空音频项,代码便可在不同检查点之间保持不变。随后,处理器会将语音占位符扩展为每帧一个位置,对文本进行规范化和分词,并将输入组成批次:The prompt layout (voice positions, text, then a token opening the audio) ships with the checkpoint as a chat template, as for other multimodal models in Transformers. You write a standard conversation, with an empty audio item where the voice goes, and your code stays the same across checkpoints. The processor then expands the voice placeholder to one position per frame, normalizes and tokenizes the text, and batches the inputs:

conversation = [
    {"role": "user", "content": [{"type": "audio"}, {"type": "text", "text": "Hello from Phonon."}]}
]
inputs = processor.apply_chat_template(
    conversation,
    tokenize=True,
    return_dict=True,
    add_generation_prompt=True,
    processor_kwargs={"audio_prompt_latents": [voice]},
).to(model.device)
# prompt: <|audio_prompt|> × num_frames, "Hello from Phonon.", <|audio_bos|>

generate 会返回潜变量,处理器会将其解码为音频:generate returns latents, which the processor decodes to audio:

outputs = model.generate(**inputs)  # audio_latents: (batch_size, num_frames, 32)
audio = processor.decode(outputs.audio_latents, outputs.audio_latents_mask)
processor.save_audio(audio, "phonon.wav")

查看更多内容,请参阅文档 🤗!See the docs 🤗 for more!

接下来是什么? What's next

Phonon 可以使用任何声音进行语音合成。经说话者同意后,你可以从一段短录音中克隆声音,也可以在 Gradium Studio 中用纯文本描述一种新声音。然后下载声音文件并加载到 Phonon 中,即可完全在设备本地运行。Phonon can speak with any voice. Clone one from a short recording with the speaker’s consent, or describe a new one in plain text in Gradium Studio. Then download the voice file, load it in Phonon, and it runs fully on the device.

我们还会与设计合作伙伴共同训练定制的 Phonon 模型。如果你的内存预算有限,我们可以缩小模型。如果你需要韩语、阿拉伯语或日语,我们也可以针对这些语言进行训练。如果你的产品有自己的词汇,我们还可以用这些词汇对模型进行微调。联系我们,告诉我们你的需求。We also train custom Phonon models with design partners. If your memory budget is tight, we can make the model smaller. If you need Korean, Arabic or Japanese, we can train for that too. And if your product has its own vocabulary, we can fine-tune on it. Get in touch and tell us what you need.

感谢 Hugging Face 团队,也感谢所有在 Phonon 发布后的前两周内试用它的人。Thank you to the Hugging Face team, and to everyone who tried Phonon in its first two weeks.

Phonon 是我们的首个开放版本。试用一下,并告诉我们你用它构建了什么。Phonon is our first open release. Try it out and tell us what you build.

值得记下

  1. Phonon 则直接在你自己的设备上运行。文本留在设备本地,即使没有网络,语音也能正常工作。
  2. Phonon 31m 可以说英语,采用 Apache 2.0 许可,因此你可以自由地基于它进行开发,包括将其用于商业产品。
  3. 在清晰度方面,Phonon 的德语和西班牙语排名第一,在我们评测的每种语言中都位居前三,表现可与规模大至其 100 倍的模型比肩。
  4. 速度是 Phonon 真正大放异彩的地方:这些模型在 CPU 流式基准测试的首音频延迟指标上名列前茅。
  5. 声音不是一段录音,而是一个说话人潜变量张量。Phonon 从不通过其仅附带解码器的音频分词器直接编码音频;声音都是预先计算好的。