Document feedback

Question document fragment

When a question document fragment contains a formula, it is displayed as a space.

Submission type
issue

It's a little complicated...

I'd like to ask someone.

PR

Just a small problem.

I can fix it online!

Please select the submission type

Problem type
Specifications and Common Mistakes

- Specifications and Common Mistakes:

- Misspellings or punctuation mistakes,incorrect formulas, abnormal display.

- Incorrect links, empty cells, or wrong formats.

- Chinese characters in English context.

- Minor inconsistencies between the UI and descriptions.

- Low writing fluency that does not affect understanding.

- Incorrect version numbers, including software package names and version numbers on the UI.

Usability

- Usability:

- Incorrect or missing key steps.

- Missing main function descriptions, keyword explanation, necessary prerequisites, or precautions.

- Ambiguous descriptions, unclear reference, or contradictory context.

- Unclear logic, such as missing classifications, items, and steps.

Correctness

- Correctness:

- Technical principles, function descriptions, supported platforms, parameter types, or exceptions inconsistent with that of software implementation.

- Incorrect schematic or architecture diagrams.

- Incorrect commands or command parameters.

- Incorrect code.

- Commands inconsistent with the functions.

- Wrong screenshots.

- Sample code running error, or running results inconsistent with the expectation.

Risk Warnings

- Risk Warnings:

- Lack of risk warnings for operations that may damage the system or important data.

Content Compliance

- Content Compliance:

- Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions.

- Copyright infringement.

Please select the type of question

Problem description

Describe the bug so that we can quickly locate the problem.

mindspore.dataset.audio.ComputeDeltas

View Source On Gitee
class mindspore.dataset.audio.ComputeDeltas(win_length=5, pad_mode=BorderType.EDGE)[source]

Compute delta coefficients, also known as differential coefficients, of a spectrogram.

Delta coefficients help to understand the dynamics of the power spectrum. It can be computed using the following formula.

dt=n=1Nn(ct+nctn)2n=1Nn2

where dt is the deltas at time t , ct is the spectrogram coefficients at time t , N is (win_length1)//2 .

Parameters
  • win_length (int, optional) – The window length used for computing delta, must be no less than 3. Default: 5.

  • pad_mode (BorderType, optional) –

    Mode parameter passed to padding, can be BorderType.CONSTANT, BorderType.EDGE, BorderType.REFLECT or BorderType.SYMMETRIC. Default: BorderType.EDGE.

    • BorderType.CONSTANT, pad with a constant value.

    • BorderType.EDGE, pad with the last value on the edge.

    • BorderType.REFLECT, reflect the value on the edge while omitting the last one. For example, pad [1, 2, 3, 4] with 2 elements on both sides will result in [3, 2, 1, 2, 3, 4, 3, 2].

    • BorderType.SYMMETRIC, reflect the value on the edge while repeating the last one. For example, pad [1, 2, 3, 4] with 2 elements on both sides will result in [2, 1, 1, 2, 3, 4, 4, 3].

Raises
Supported Platforms:

CPU

Examples

>>> import numpy as np
>>> import mindspore.dataset as ds
>>> import mindspore.dataset.audio as audio
>>>
>>> # Use the transform in dataset pipeline mode
>>> waveform = np.random.random([5, 400 // 2 + 1, 30])  # 5 samples
>>> numpy_slices_dataset = ds.NumpySlicesDataset(data=waveform, column_names=["audio"])
>>> transforms = [audio.ComputeDeltas(win_length=7, pad_mode=audio.BorderType.EDGE)]
>>> numpy_slices_dataset = numpy_slices_dataset.map(operations=transforms, input_columns=["audio"])
>>> for item in numpy_slices_dataset.create_dict_iterator(num_epochs=1, output_numpy=True):
...     print(item["audio"].shape, item["audio"].dtype)
...     break
(201, 30) float64
>>>
>>> # Use the transform in eager mode
>>> waveform = np.random.random([400 // 2 + 1, 30])  # 1 sample
>>> output = audio.ComputeDeltas(win_length=7, pad_mode=audio.BorderType.EDGE)(waveform)
>>> print(output.shape, output.dtype)
(201, 30) float64
Tutorial Examples: