Skip to Content
变形金刚权威指南 (Chinese Edition)
book

变形金刚权威指南 (Chinese Edition)

by Nicole Koenigstein
March 2026
Intermediate
372 pages
4h 53m
Chinese
O'Reilly Media, Inc.
Content preview from 变形金刚权威指南 (Chinese Edition)

第6章 从 声音到词元再回到声音:音频领域的Transformer

本作品已使用人工智能进行翻译。欢迎您提供反馈和意见:translation-feedback@oreilly.com

本章将带您在维度轴上更进一步。您从最初的Transformer(即语言领域)起步,随后转向时间序列,接着探索了视觉与视频领域。现在,您将深入音频领域。剧透预警:Transformer再次展现出惊人的适应性。事实证明,无论您建模的是离散词元、图像块还是声谱图帧,核心逻辑始终如一。 核心逻辑依然不变。这就是 Transformer 的精妙之处。你改变的是维度,而非基本架构。我相信,到此刻,你已经亲眼见证了这一点:Transformer 不仅仅是模型,更是一个抽象框架。正因如此,它并非昙花一现的潮流,而是跨领域建模通用化与统一化的全新途径。

音频之所以特别引人入胜,在于它恰好处于时序结构与频谱表示的交汇点。乍看之下,音频可能像经典的时间序列,仅仅是随时间变化的波形,但其丰富性其实在于频域。这就是为什么许多音频模型在分词之前,会将原始波形转换为频谱图或梅尔频率特征。

频谱图展示了 信号中不同频率分量的能量随时间的变化,从而提供了声音的时频视图。梅尔频率表示法 将这些频率映射到一种感知尺度上,该尺度更能反映人类的听觉方式,并强调了人类听觉最敏感的低频区域。图6-1将电子舞曲(EDM)的频谱图和梅尔频谱图与古典音乐的进行了对比,展示了它们如何呈现出截然不同的频谱模式。 在此,您可以清晰地看到,EDM 信号呈现出密集且重复的垂直条带,表明在宽广的频率范围内存在持续的高能量节拍。相比之下,古典音乐信号包含更微妙且随时间变化的能量,这些能量主要集中在低频范围内。正是这种原始数据形式的声音,使得变压器模型能够对 环境声音进行分类、识别语音模式,甚至以连贯且可控的方式生成不同风格的音乐。

Spectrogram and mel spectrogram comparisons of EDM and classical music, showing distinct spectral patterns and frequency energy distributions over a 20-second duration.
图6-1. 电子舞曲(EDM)与古典音乐各20秒片段的对比 ,每段均以线性频谱图(左)和梅尔频谱图(右)两种形式可视化。

在本章中,您将学习一系列核心音频任务,包括文本转语音(TTS)、自动语音识别、语音转文本(S2T)、语音情感识别以及音乐生成。为了聚焦于现代架构,Whisper等经典模型仅会简要介绍。1

尽管Whisper 至今仍被许多最先进(SOTA)模型用作编码器,但我将重点转向能够通过单一架构处理多种任务的新型音频基础模型。这些大型音频语言模型(LALMs) 包括Qwen2-Audio2 和 Kimi-Audio,3 ,它们已超越特定任务的处理范畴,在识别、生成、分类以及音频-语言对齐等方面展现出统一的能力。本章还将探讨基于Transformer的音乐生成模型,展示如何利用这些模型通过文本生成具有长程结构和风格控制的音乐连贯序列。

与时间序列模型类似,音频模型必须能够处理长上下文、适应不同的采样率,并处理可变长度的输入。但与时间序列不同,音频数据密度更高、感知细节更丰富,且通常具有多声道特性。这增加了处理复杂性,同时也为生成模型创造了强大的机遇,使其能够生成极其逼真的输出。

从波形到频谱图: 理解音频数据的结构

在处理音频数据时,尤其是基于Transformer的建模场景中,理解音频信号的结构与特性至关重要。本节将从概念和数学角度概述数字音频,包括其时域和频域特性,以及在将数据输入模型前通常会进行的变换。 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

LLM 网格 (Chinese Edition)

LLM 网格 (Chinese Edition)

Kurt Muehmel

Publisher Resources

ISBN: 0642572364274