class AudioDataStream
class AudioDataStream
: public std::enable_shared_from_this< AudioDataStream >
Represents audio data stream used for operating audio data as a stream. Added in version 1.4.0.
Syntax: public const PropertyCollection & Properties;
Collection of additional SpeechSynthesisResult properties.
Syntax: public inline ~AudioDataStream ( );
Destroy the instance.
Syntax: public inline StreamStatus GetStatus ( );
Get current status of the audio data stream.
Current status
Syntax: public inline bool CanReadData ( uint32_t bytesRequested );
Check whether the stream has enough data to be read.
bytesRequested
The requested data size in bytes.
A bool indicating whether the stream has enough data to be read.
Syntax: public inline bool CanReadData ( uint32_t pos , uint32_t bytesRequested );
Check whether the stream has enough data to be read, starting from the specified position.
pos
The position counting from start of the stream.bytesRequested
The requested data size in bytes.
A bool indicating whether the stream has enough data to be read.
Syntax: public inline uint32_t ReadData ( uint8_t * buffer , uint32_t bufferSize );
Reads a chunk of the audio data and fill it to given buffer.
buffer
A buffer to receive read data.bufferSize
Size of the buffer.
Size of data filled to the buffer, 0 means end of stream
Syntax: public inline uint32_t ReadData ( uint32_t pos , uint8_t * buffer , uint32_t bufferSize );
Reads a chunk of the audio data and fill it to given buffer, starting from the specified position.
pos
The position counting from start of the stream.buffer
A buffer to receive read data.bufferSize
Size of the buffer.
Size of data filled to the buffer, 0 means end of stream
Syntax: public inline void SaveToWavFile ( const std::string & fileName );
Save the audio data to a file, synchronously.
fileName
The file name with full path.
Syntax: public inline std::future< void > SaveToWavFileAsync ( const std::string & fileName );
Save the audio data to a file, asynchronously.
fileName
The file name with full path.
An asynchronous operation representing the saving.
Syntax: public inline uint32_t GetPosition ( );
Get current position of the audio data stream.
Current position
Syntax: public inline void SetPosition ( uint32_t pos );
Set current position of the audio data stream.
pos
Position to be set.
Syntax: public inline void DetachInput ( );
Stops any more data from getting to the stream.
Syntax: public inline explicit operator SPXAUDIOSTREAMHANDLE ( );
Explicit conversion operator.
A handle.
Syntax: public inline static std::shared_ptr< AudioDataStream > FromWavFileInput ( const std::string & fileName );
Creates a memory backed AudioDataStream for the specified audio input file. Added in version 1.14.0.
fileName
Specifies the audio input file.
A shared pointer to AudioDataStream
Syntax: public inline static std::shared_ptr< AudioDataStream > FromResult ( std::shared_ptr< SpeechSynthesisResult > result );
Creates a memory backed AudioDataStream from given speech synthesis result.
result
The speech synthesis result.
A shared pointer to AudioDataStream
Syntax: public inline static std::shared_ptr< AudioDataStream > FromResult ( std::shared_ptr< KeywordRecognitionResult > result );
Obtains the memory backed AudioDataStream associated with a given KeywordRecognition result.
result
The keyword recognition result.
An audio stream with the input to the KeywordRecognizer starting from right before the Keyword.