Decode a 16-bit PCM WAV file to a float tensor.
The -32768 to 32767 signed 16-bit values will be scaled to -1.0 to 1.0 in float.
When desired_channels is set, if the input contains fewer channels than this then the last channel will be duplicated to give the requested number, else if the input has more channels than requested then the additional channels will be ignored.
If desired_samples is set, then the audio will be cropped or padded with zeroes to the requested length.
The first output contains a Tensor with the content of the audio samples. The lowest dimension will be the number of channels, and the second will be the number of samples. For example, a ten-sample-long stereo WAV file should give an output shape of [10, 2].
Nested Classes
class | DecodeWav.Options |
Optional attributes for
DecodeWav
|
Constants
String | OP_NAME | The name of this op, as known by TensorFlow core engine |
Public Methods
Output < TFloat32 > |
audio
()
2-D with shape `[length, channels]`.
|
static DecodeWav |
create
(
Scope
scope,
Operand
<
TString
> contents,
Options...
options)
Factory method to create a class wrapping a new DecodeWav operation.
|
static DecodeWav.Options |
desiredChannels
(Long desiredChannels)
|
static DecodeWav.Options |
desiredSamples
(Long desiredSamples)
|
Output < TInt32 > |
sampleRate
()
Scalar holding the sample rate found in the WAV header.
|
Inherited Methods
Constants
public static final String OP_NAME
The name of this op, as known by TensorFlow core engine
Public Methods
public static DecodeWav create ( Scope scope, Operand < TString > contents, Options... options)
Factory method to create a class wrapping a new DecodeWav operation.
Parameters
scope | current scope |
---|---|
contents | The WAV-encoded audio, usually from a file. |
options | carries optional attributes values |
Returns
- a new instance of DecodeWav
public static DecodeWav.Options desiredChannels (Long desiredChannels)
Parameters
desiredChannels | Number of sample channels wanted. |
---|
public static DecodeWav.Options desiredSamples (Long desiredSamples)
Parameters
desiredSamples | Length of audio requested. |
---|