Class AudioInputStream
- java.lang.Object
-
- com.microsoft.cognitiveservices.speech.audio.AudioInputStream
-
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
PullAudioInputStream,PushAudioInputStream
public class AudioInputStream extends Object implements AutoCloseable
Represents audio input stream used for custom audio input configurations. Note: close() must be called in order to release underlying resources held by the object.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Explicitly frees any external resource attached to the object Note: close() must be called in order to release underlying resources held by the object.static PullAudioInputStreamcreatePullStream(PullAudioInputStreamCallback callback)Creates a PullAudioInputStream that delegates to the specified callback interface for read() and close() methods, using the default format (16 kHz, 16 bit, mono PCM).static PullAudioInputStreamcreatePullStream(PullAudioInputStreamCallback callback, AudioStreamFormat format)Creates a PullAudioInputStream that delegates to the specified callback interface for read() and close() methods.static PushAudioInputStreamcreatePushStream()Creates a memory backed PushAudioInputStream using the default format (16 kHz, 16 bit, mono PCM).static PushAudioInputStreamcreatePushStream(AudioStreamFormat format)Creates a memory backed PushAudioInputStream with the specified audio format.SafeHandlegetImpl()Internally used to get the underlying native handle of the stream.
-
-
-
Method Detail
-
createPushStream
public static PushAudioInputStream createPushStream()
Creates a memory backed PushAudioInputStream using the default format (16 kHz, 16 bit, mono PCM).- Returns:
- The audio input stream being created.
-
createPushStream
public static PushAudioInputStream createPushStream(AudioStreamFormat format)
Creates a memory backed PushAudioInputStream with the specified audio format.- Parameters:
format- The audio data format in which audio will be written to the push audio stream's write() method.- Returns:
- The audio input stream being created.
-
createPullStream
public static PullAudioInputStream createPullStream(PullAudioInputStreamCallback callback)
Creates a PullAudioInputStream that delegates to the specified callback interface for read() and close() methods, using the default format (16 kHz, 16 bit, mono PCM).- Parameters:
callback- The custom audio input object, derived from PullAudioInputStreamCallback- Returns:
- The audio input stream being created.
-
createPullStream
public static PullAudioInputStream createPullStream(PullAudioInputStreamCallback callback, AudioStreamFormat format)
Creates a PullAudioInputStream that delegates to the specified callback interface for read() and close() methods.- Parameters:
callback- The custom audio input object, derived from PullAudioInputStreamCallbackformat- The audio data format in which audio will be returned from the callback's read() method.- Returns:
- The audio input stream being created.
-
close
public void close()
Explicitly frees any external resource attached to the object Note: close() must be called in order to release underlying resources held by the object.- Specified by:
closein interfaceAutoCloseable
-
getImpl
public SafeHandle getImpl()
Internally used to get the underlying native handle of the stream.- Returns:
- The implementation of the stream.
-
-