Package ai.djl.modality.audio
Class AudioFactory
- java.lang.Object
-
- ai.djl.modality.audio.AudioFactory
-
- Direct Known Subclasses:
SampledAudioFactory
public abstract class AudioFactory extends java.lang.ObjectAudioFactorycontains audio creation mechanism on top of different platforms like PC and Android. System will choose appropriate Factory based on the supported audio type.
-
-
Constructor Summary
Constructors Constructor Description AudioFactory()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract AudiofromData(float[] data)ReturnsAudiofrom raw data.abstract AudiofromFile(java.nio.file.Path path)ReturnsAudiofrom file.abstract AudiofromInputStream(java.io.InputStream is)ReturnsAudiofromInputStream.abstract AudiofromNDArray(NDArray array)AudiofromUrl(java.lang.String url)ReturnsAudiofrom URL.AudiofromUrl(java.net.URL url)ReturnsAudiofrom URL.static AudioFactorygetInstance()Gets new instance of Audio factory from the provided factory implementation.
-
-
-
Method Detail
-
getInstance
public static AudioFactory getInstance()
Gets new instance of Audio factory from the provided factory implementation.- Returns:
AudioFactory
-
fromFile
public abstract Audio fromFile(java.nio.file.Path path) throws java.io.IOException
ReturnsAudiofrom file.- Parameters:
path- the path to the audio- Returns:
Audio- Throws:
java.io.IOException- Audio not found or not readable
-
fromUrl
public Audio fromUrl(java.net.URL url) throws java.io.IOException
ReturnsAudiofrom URL.- Parameters:
url- the URL to load from- Returns:
Audio- Throws:
java.io.IOException- URL is not valid.
-
fromUrl
public Audio fromUrl(java.lang.String url) throws java.io.IOException
ReturnsAudiofrom URL.- Parameters:
url- the String represent URL to load from- Returns:
Audio- Throws:
java.io.IOException- URL is not valid.
-
fromInputStream
public abstract Audio fromInputStream(java.io.InputStream is) throws java.io.IOException
ReturnsAudiofromInputStream.- Parameters:
is-InputStream- Returns:
Audio- Throws:
java.io.IOException- image cannot be read from input stream.
-
fromData
public abstract Audio fromData(float[] data)
ReturnsAudiofrom raw data.- Parameters:
data- the raw data in float array form.- Returns:
Audio
-
-