Package ai.djl.modality.audio
Class SampledAudioFactory
- java.lang.Object
-
- ai.djl.modality.audio.AudioFactory
-
- ai.djl.modality.audio.SampledAudioFactory
-
public class SampledAudioFactory extends AudioFactory
SampledAudioFactory
is an implementation ofImageFactory
using the Java Sampled Package.
-
-
Field Summary
-
Fields inherited from class ai.djl.modality.audio.AudioFactory
channels, sampleFormat, sampleRate
-
-
Constructor Summary
Constructors Constructor Description SampledAudioFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Audio
fromFile(java.nio.file.Path path)
ReturnsAudio
from file.Audio
fromInputStream(java.io.InputStream is)
ReturnsAudio
fromInputStream
.AudioFactory
setChannels(int channel)
Sets the number of channels forAudioFactory
to use.AudioFactory
setSampleFormat(int sampleFormat)
Sets the audio sample format forAudioFactory
to use.AudioFactory
setSampleRate(int sampleRate)
Sets the sampleRate forAudioFactory
to use.-
Methods inherited from class ai.djl.modality.audio.AudioFactory
fromData, fromNDArray, fromUrl, fromUrl, getChannels, getSampleFormat, getSampleRate, newInstance
-
-
-
-
Method Detail
-
setChannels
public AudioFactory setChannels(int channel)
Sets the number of channels forAudioFactory
to use.- Overrides:
setChannels
in classAudioFactory
- Parameters:
channel
- the number of channels forAudioFactory
to use- Returns:
- this factory
-
setSampleRate
public AudioFactory setSampleRate(int sampleRate)
Sets the sampleRate forAudioFactory
to use.- Overrides:
setSampleRate
in classAudioFactory
- Parameters:
sampleRate
- the sampleRate forAudioFactory
to use- Returns:
- this factory
-
setSampleFormat
public AudioFactory setSampleFormat(int sampleFormat)
Sets the audio sample format forAudioFactory
to use.- Overrides:
setSampleFormat
in classAudioFactory
- Parameters:
sampleFormat
- the sample format- Returns:
- this factory.
-
fromFile
public Audio fromFile(java.nio.file.Path path) throws java.io.IOException
ReturnsAudio
from file.- Specified by:
fromFile
in classAudioFactory
- Parameters:
path
- the path to the audio- Returns:
Audio
- Throws:
java.io.IOException
- Audio not found or not readable
-
fromInputStream
public Audio fromInputStream(java.io.InputStream is) throws java.io.IOException
ReturnsAudio
fromInputStream
.- Specified by:
fromInputStream
in classAudioFactory
- Parameters:
is
-InputStream
- Returns:
Audio
- Throws:
java.io.IOException
- image cannot be read from input stream.
-
-