你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
AudioDataStream Class
- java.
lang. Object - com.
microsoft. cognitiveservices. speech. AudioDataStream
- com.
Implements
public final class AudioDataStream
implements java.lang.AutoCloseable
Represents audio data stream used for operating audio data as a stream. Note: close() must be called in order to release underlying resources held by the object. Added in version 1.7.0
Method Summary
Modifier and Type | Method and Description |
---|---|
boolean |
canReadData(long bytesRequested)
Check whether the stream has enough data to be read. |
boolean |
canReadData(long pos, long bytesRequested)
Check whether the stream has enough data to be read, starting from the specified position. |
void |
close()
Dispose of associated resources. |
void |
detachInput()
Stops any more data from getting to the stream. |
static
Audio |
fromResult(KeywordRecognitionResult result)
Obtains the memory backed Audio |
static
Audio |
fromResult(SpeechSynthesisResult result)
Creates a memory backed Audio |
Safe |
getImpl()
Returns the audio data stream implementation. |
long |
getPosition()
Get current position of the audio data stream. |
Property |
getProperties()
The collection of properties and their values defined for this audio data stream. |
Stream |
getStatus()
Get current status of the audio data stream. |
long |
readData(byte[] dataBuffer)
Reads the audio data specified by making an internal copy of the data. |
long |
readData(long pos, byte[] dataBuffer)
Reads the audio data specified by making an internal copy of the data, starting from the specified position. |
void |
saveToWavFile(String fileName)
Save the audio data to a file, synchronously. |
java.util.concurrent.Future<java.lang.Void> |
saveToWavFileAsync(String fileName)
Save the audio data to a file, asynchronously. |
void |
setPosition(long pos)
Set current position of the audio data stream. |
Methods inherited from java.lang.Object
Method Details
canReadData
public boolean canReadData(long bytesRequested)
Check whether the stream has enough data to be read.
Parameters:
Returns:
canReadData
public boolean canReadData(long pos, long bytesRequested)
Check whether the stream has enough data to be read, starting from the specified position.
Parameters:
Returns:
close
public void close()
Dispose of associated resources.
detachInput
public void detachInput()
Stops any more data from getting to the stream.
fromResult
public static AudioDataStream fromResult(KeywordRecognitionResult result)
Obtains the memory backed AudioDataStream associated with a given KeywordRecognition result.
Parameters:
Returns:
fromResult
public static AudioDataStream fromResult(SpeechSynthesisResult result)
Creates a memory backed AudioDataStream from given speech synthesis result.
Parameters:
Returns:
getImpl
public SafeHandle getImpl()
Returns the audio data stream implementation.
Returns:
getPosition
public long getPosition()
Get current position of the audio data stream.
Returns:
getProperties
public PropertyCollection getProperties()
The collection of properties and their values defined for this audio data stream.
Returns:
getStatus
public StreamStatus getStatus()
Get current status of the audio data stream.
Returns:
readData
public long readData(byte[] dataBuffer)
Reads the audio data specified by making an internal copy of the data. The maximal number of bytes to be read is determined by the size of dataBuffer. If there is no data immediately available, read() blocks until the next data becomes available.
Parameters:
Returns:
readData
public long readData(long pos, byte[] dataBuffer)
Reads the audio data specified by making an internal copy of the data, starting from the specified position. The maximal number of bytes to be read is determined by the size of dataBuffer. If there is no data immediately available, read() blocks until the next data becomes available.
Parameters:
Returns:
saveToWavFile
public void saveToWavFile(String fileName)
Save the audio data to a file, synchronously.
Parameters:
saveToWavFileAsync
public Future
Save the audio data to a file, asynchronously.
Parameters:
Returns:
setPosition
public void setPosition(long pos)
Set current position of the audio data stream.
Parameters: