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
SampledAudioFactoryis an implementation ofImageFactoryusing 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 AudiofromFile(java.nio.file.Path path)ReturnsAudiofrom file.AudiofromInputStream(java.io.InputStream is)ReturnsAudiofromInputStream.AudioFactorysetChannels(int channel)Sets the number of channels forAudioFactoryto use.AudioFactorysetSampleFormat(int sampleFormat)Sets the audio sample format forAudioFactoryto use.AudioFactorysetSampleRate(int sampleRate)Sets the sampleRate forAudioFactoryto 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 forAudioFactoryto use.- Overrides:
setChannelsin classAudioFactory- Parameters:
channel- the number of channels forAudioFactoryto use- Returns:
- this factory
-
setSampleRate
public AudioFactory setSampleRate(int sampleRate)
Sets the sampleRate forAudioFactoryto use.- Overrides:
setSampleRatein classAudioFactory- Parameters:
sampleRate- the sampleRate forAudioFactoryto use- Returns:
- this factory
-
setSampleFormat
public AudioFactory setSampleFormat(int sampleFormat)
Sets the audio sample format forAudioFactoryto use.- Overrides:
setSampleFormatin classAudioFactory- Parameters:
sampleFormat- the sample format- Returns:
- this factory.
-
fromFile
public Audio fromFile(java.nio.file.Path path) throws java.io.IOException
ReturnsAudiofrom file.- Specified by:
fromFilein 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
ReturnsAudiofromInputStream.- Specified by:
fromInputStreamin classAudioFactory- Parameters:
is-InputStream- Returns:
Audio- Throws:
java.io.IOException- image cannot be read from input stream.
-
-