将 signal 的 axis 维度扩展为 frame_length 的框架。
用法
tf.signal.frame(
signal, frame_length, frame_step, pad_end=False, pad_value=0, axis=-1, name=None
)参数
-
signal一个[..., samples, ...]Tensor。等级和维度可能是未知的。排名必须至少为 1。 -
frame_length样本中的帧长度。整数或标量Tensor。 -
frame_step样本中的帧跳大小。整数或标量Tensor。 -
pad_end是否用pad_value填充signal的末尾。 -
pad_value当pad_end为真时,在输入信号不存在的地方使用可选标量Tensor。 -
axis一个标量整数Tensor,指示要框架的轴。默认为最后一个轴。支持从末尾开始索引的负值。 -
name操作的可选名称。
返回
-
A
Tensor形状为[..., num_frames, frame_length, ...]的帧。
抛出
-
ValueError如果frame_length,frame_step,pad_value或axis不是标量。
在 signal 的 axis 维度上滑动大小为 frame_length 的窗口,步长为 frame_step ,将 axis 维度替换为 [frames, frame_length] 帧。
如果 pad_end 为 True,则超过 axis 维度末尾的窗口位置将使用 pad_value 填充,直到窗口完全移动到维度末尾。否则,只会生成与axis 维度完全重叠的窗口位置。
例如:
# A batch size 3 tensor of 9152 audio samples.
audio = tf.random.normal([3, 9152])
# Compute overlapping frames of length 512 with a step of 180 (frames overlap
# by 332 samples). By default, only 49 frames are generated since a frame
# with start position j*180 for j > 48 would overhang the end.
frames = tf.signal.frame(audio, 512, 180)
frames.shape.assert_is_compatible_with([3, 49, 512])
# When pad_end is enabled, the final two frames are kept (padded with zeros).
frames = tf.signal.frame(audio, 512, 180, pad_end=True)
frames.shape.assert_is_compatible_with([3, 51, 512])
如果沿 axis 的维度为 N,并且 pad_end=False ,则可以通过以下方式计算帧数:
num_frames = 1 + (N - frame_size) // frame_step
如果 pad_end=True ,则可以通过以下方式计算帧数:
num_frames = -(-N // frame_step) # ceiling division
相关用法
- Python tf.signal.fftshift用法及代码示例
- Python tf.signal.overlap_and_add用法及代码示例
- Python tf.signal.linear_to_mel_weight_matrix用法及代码示例
- Python tf.signal.inverse_mdct用法及代码示例
- Python tf.signal.mfccs_from_log_mel_spectrograms用法及代码示例
- Python tf.signal.ifftshift用法及代码示例
- Python tf.signal.inverse_stft用法及代码示例
- Python tf.size用法及代码示例
- Python tf.summary.scalar用法及代码示例
- Python tf.strings.substr用法及代码示例
- Python tf.strings.reduce_join用法及代码示例
- Python tf.sparse.cross用法及代码示例
- Python tf.sparse.mask用法及代码示例
- Python tf.strings.regex_full_match用法及代码示例
- Python tf.sparse.split用法及代码示例
- Python tf.strings.regex_replace用法及代码示例
- Python tf.strings.length用法及代码示例
- Python tf.strided_slice用法及代码示例
- Python tf.sparse.to_dense用法及代码示例
- Python tf.strings.bytes_split用法及代码示例
注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.signal.frame。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
