simulstream.server.speech_processors.incremental_output

Functions

merge_incremental_outputs(outputs, ...)

Merge the incremental outputs passed as input into a single incremental output.

Classes

IncrementalOutput(new_tokens, new_string, ...)

Represents the incremental output of a speech processor for a single processed chunk of audio.

class simulstream.server.speech_processors.incremental_output.IncrementalOutput(new_tokens: List[str], new_string: str, deleted_tokens: List[str], deleted_string: str)

Represents the incremental output of a speech processor for a single processed chunk of audio.

new_tokens

List of newly generated tokens in this chunk.

Type:

List[str]

new_string

Concatenated string representation of the new tokens.

Type:

str

deleted_tokens

List of tokens that were deleted/overwritten.

Type:

List[str]

deleted_string

Concatenated string representation of the deleted tokens.

Type:

str

strings_to_json() str

Serialize the incremental output to a JSON string.

Returns:

A JSON string containing the newly generated and the deleted text.

Return type:

str

simulstream.server.speech_processors.incremental_output.merge_incremental_outputs(outputs: List[IncrementalOutput], tokens_to_string: Callable[[List[str]], str]) IncrementalOutput

Merge the incremental outputs passed as input into a single incremental output. The outputs must be sorted in cronological order.

Parameters:
  • outputs (List[IncrementalOutput]) – List of incremental outputs to be merged.

  • tokens_to_string (Callable[[List[str]], str]) – A function that takes a list of tokens and returns a string that contains the detokenized text.