Class SPXPushAudioInputStream

Declaration

@class SPXPushAudioInputStream : SPXAudioInputStream;

Description

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

Methods

init

Initializes a memory-backed SPXPushAudioInputStream using the default format (16 kHz, 16 bit, mono PCM).

- (instancetype _Nonnull)init

Returns

an instance of push audio input stream.

initWithAudioFormat:

Initializes a memory-backed SPXPushAudioInputStream with the specified audio format.

- (instancetype _Nullable)initWithAudioFormat:(SPXAudioStreamFormat * _Nonnull)format

Parameters

  • format - The audio data format in which audio will be written to the push audio stream's write() method.

Returns

an instance of push audio input stream.

write:

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

- (void)write:(NSData * _Nonnull)data

Parameters

  • data - The audio buffer of which this function will make a copy.

commit

Requests a segmentation boundary at the current position in the audio written so far.

The request is sent to the service inline, without ending the current turn. The service finalizes the audio up to this point and echoes the returned token on the recognition result that closes the committed segment, where it is available as the commitToken property. Match that value against the token returned here to identify the boundary.

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.

At most one commit per 100 milliseconds is accepted on a stream.

- (uint32_t)commit

Returns

the commit token, or 0 if the request was rejected outright e.g. based on the rate limit.

commitChannel:

Requests a segmentation boundary on a single channel of multichannel audio.

Behaves as commit, except that the request is scoped to one channel and the service produces one result for that channel rather than one per active channel.

- (uint32_t)commitChannel:(uint32_t)channelId

Parameters

  • channelId - The zero-based index of the channel to commit.

Returns

the commit token, or 0 if the request was rejected outright e.g. based on the rate limit.

close

Closes the stream.

- (void)close