Class SPXAudioDataStream
@class SPXAudioDataStream : NSObject;
Represents audio data stream used for operating audio data as a stream.
Added in version 1.7.0
Initializes an audio data stream from given speech synthesis result.
- (instancetype _Nullable)initFromSynthesisResult:(SPXSpeechSynthesisResult * _Nonnull)result
result
- the speech synthesis result.
an instance of audio data stream.
Initializes an audio data stream from given speech synthesis result.
- (instancetype _Nullable)initFromSynthesisResult:(SPXSpeechSynthesisResult * _Nonnull)result
error:(NSError * _Nullable * _Nullable)outError
result
- the speech synthesis result.outError
- error information.
an instance of audio data stream.
Obtains the memory backed AudioDataStream associated with a given KeywordRecognition result.
- (instancetype _Nullable)initFromKeywordRecognitionResult:(SPXKeywordRecognitionResult * _Nonnull)result
result
- the keyword recognition result.
An audio stream with the input to the KeywordRecognizer starting from right before the Keyword.
Obtains the memory backed AudioDataStream associated with a given KeywordRecognition result.
- (instancetype _Nullable)initFromKeywordRecognitionResult:(SPXKeywordRecognitionResult * _Nonnull)result
error:(NSError * _Nullable * _Nullable)outError
result
- the keyword recognition result.outError
- error information.
An audio stream with the input to the KeywordRecognizer starting from right before the Keyword.
Get current status of the audio data stream.
- (SPXStreamStatus)getStatus
current status.
Check wheather the stream has enough data to be read.
- (BOOL)canReadData:(NSUInteger)bytesRequested
bytesRequested
- the request data size in bytes.
a bool indicating whether the stream has enough data to be read.
Check whether the stream has enough data to be read, starting from the specified position.
- (BOOL)canReadDataFromPosition:(NSUInteger)pos bytesRequested:(NSUInteger)bytesRequested
pos
- the position counting from start of the stream.bytesRequested
- the request data size in bytes.
a bool indicating whether the stream has enough data to be read.
Reads a chunk of the audio data and fill it to given buffer.
- (NSUInteger)readData:(NSMutableData * _Nonnull)data length:(NSUInteger)length
data
- a buffer to receive read data.length
- length of the data to be received.
length of data filled to the buffer, 0 means end of stream.
Reads a chunk of the audio data and fill it to given buffer, starting from the specified position.
- (NSUInteger)readDataFromPosition:(NSUInteger)pos data:(NSMutableData * _Nonnull)data
length:(NSUInteger)length
pos
- the position counting from start of the stream.data
- a buffer to receive read data.length
- length of the data to be received.
length of data filled to the buffer, 0 means end of stream.
Save the audio data to a file.
- (void)saveToWavFile:(NSString * _Nonnull)fileName
fileName
- the file name with full path.
Get current position of the audio data stream.
- (NSUInteger)getPosition
current position
Set current position of the audio data stream.
- (void)setPosition:(NSUInteger)pos
pos
- position to be set.
Stops any more data from getting to the stream.
- (void)detachInput
Stops any more data from getting to the stream.
- (void)detachInput:(NSError * _Nullable * _Nullable)outError
outError
- error information.