AudioDataStream Class
Represents audio data stream used for operating audio data as a stream.
Generates an audio data stream from a speech synthesis result (type SpeechSynthesisResult) or a keyword recognition result (type KeywordRecognitionResult).
- Inheritance
-
builtins.objectAudioDataStream
Constructor
AudioDataStream(result=None)
Parameters
Name | Description |
---|---|
result
|
The speech synthesis or keyword recognition result. Default value: None
|
Methods
can_read_data |
Check whether the stream has enough data to be read, starting from the specified position (if specified). |
detach_input |
Stop any more data from getting to the stream. |
read_data |
Reads the audio data from the audio data stream, starting from the specified position (if specified). The maximal number of bytes to be read is determined by the size of audio_buffer. If there is no data immediately available, read_data() blocks until the next data becomes available. |
save_to_wav_file |
Save the audio data to a file, synchronously. |
save_to_wav_file_async |
Save the audio data to a file, asynchronously. |
can_read_data
Check whether the stream has enough data to be read, starting from the specified position (if specified).
can_read_data(requested_bytes: int, pos: int | None = None) -> bool
Parameters
Name | Description |
---|---|
requested_bytes
Required
|
The requested data size in bytes. |
pos
|
The position to start with. Will start from current position if this param is not given. Default value: None
|
Returns
Type | Description |
---|---|
A bool indicating the result |
detach_input
Stop any more data from getting to the stream.
detach_input()
read_data
Reads the audio data from the audio data stream, starting from the specified position (if specified). The maximal number of bytes to be read is determined by the size of audio_buffer. If there is no data immediately available, read_data() blocks until the next data becomes available.
read_data(audio_buffer: bytes, pos: int | None = None) -> int
Parameters
Name | Description |
---|---|
audio_buffer
Required
|
The buffer to receive the audio data. |
pos
|
The position to start with. Will start from current position if this param is not given. Default value: None
|
Returns
Type | Description |
---|---|
The number of bytes filled, or 0 in case the stream hits its end and there is no more data available. |
save_to_wav_file
Save the audio data to a file, synchronously.
save_to_wav_file(file_name: str)
Parameters
Name | Description |
---|---|
file_name
Required
|
Name of the file to be saved to |
save_to_wav_file_async
Save the audio data to a file, asynchronously.
save_to_wav_file_async(file_name: str)
Parameters
Name | Description |
---|---|
file_name
Required
|
Name of the file to be saved to |
Returns
Type | Description |
---|---|
An asynchronous operation representing the saving. |
Attributes
cancellation_details
The reason why speech synthesis was cancelled.
Returns None if there was no cancellation.
position
Current position of the audio data stream.
properties
A collection of properties and their values defined for this AudioDataStream.
status
Current status of the audio data stream.
Azure SDK for Python