PushAudioInputStream Class

Represents memory backed push audio input stream used for custom audio input configurations.

Constructor

PushAudioInputStream(stream_format: AudioStreamFormat | None = None)

Parameters

Name Description
stream_format

The AudioStreamFormat the stream uses for audio data.

Default value: None

Methods

close

Closes the stream.

commit

Requests the service to finalize the current audio segment at the point in the stream reached by the audio written so far, without stopping recognition or closing the stream.

The commit is anchored to the audio written before this call, so write the audio for the segment first, then call this method.

The request is advisory. A token is issued as soon as the request is recorded, but there is no guarantee that it will be acknowledged: the service may not support inline commit, or the session may end first. Applications must tolerate a token that is never echoed.

commit_channel

Requests the service to finalize the current audio segment on a single channel of a multichannel input. Otherwise identical to commit.

set_property
write

Writes the audio data specified by making an internal copy of the data. The buffer should not contain any audio header.

close

Closes the stream.

close()

commit

Requests the service to finalize the current audio segment at the point in the stream reached by the audio written so far, without stopping recognition or closing the stream.

The commit is anchored to the audio written before this call, so write the audio for the segment first, then call this method.

The request is advisory. A token is issued as soon as the request is recorded, but there is no guarantee that it will be acknowledged: the service may not support inline commit, or the session may end first. Applications must tolerate a token that is never echoed.

commit() -> int

Returns

Type Description

A token identifying this commit request. The recognition result that acknowledges it carries the same value in its commit_token property. Returns 0 if the request was rejected, outright which happens e.g. when commits are issued faster than the SDK's internal rate limit allows.

commit_channel

Requests the service to finalize the current audio segment on a single channel of a multichannel input. Otherwise identical to commit.

commit_channel(channel_id: int) -> int

Parameters

Name Description
channel_id
Required

0-based index of the channel to commit.

Returns

Type Description

A token identifying this commit request, or 0 if the request was rejected outright e.g. based on the SDK's internal rate limit.

set_property

set_property(name: str, value: str)

Parameters

Name Description
name
Required
value
Required

write

Writes the audio data specified by making an internal copy of the data. The buffer should not contain any audio header.

write(buffer: bytes)

Parameters

Name Description
buffer
Required

The audio data.