TranscriberSherpa

processing extra: transcriber-sherpa

Streaming speech recognition with sherpa-onnx, on CPU and without torch. One message is transmitted for each sentence, when the speaker stops talking.

Node type:

TranscriberSherpa

Input:

AudioPayload

Output:

ObjectPayload

Extra:

transcriber-sherpa

$ pip install "juturna-nodes[transcriber-sherpa]"

The node downloads its default model on first use. The node README describes the model cache, the input and output messages, and the licenses of the code and the weights.

Model

By default the node downloads the English streaming zipformer (Apache-2.0) on first use: the int8 encoder, decoder and joiner and tokens.txt, 73 MB, from the Hugging Face repository at a pinned revision. Each file is checked against its size and SHA-256 on download. The files are kept in ~/.cache/juturna/models/<model>/ (or under $XDG_CACHE_HOME), and later runs reuse them after checking their size and SHA-256.

To use a model you already have, set model_dir to its folder; model is then ignored. The folder must hold tokens.txt and one encoder*.onnx, decoder*.onnx and joiner*.onnx file each; when both are present, the .int8. files are used.

Arguments

Argument

Type

Default

Description

model

str

"sherpa-onnx-streaming-zipformer-en-2023-06-26"

Model downloaded into the cache; the default is the only model this node supports

model_dir

str

""

Folder of a streaming transducer model, used instead of model

num_threads

int

2

CPU threads used by the recognizer

min_trailing_silence

float

0.8

Seconds of silence after speech that close a sentence

Input message

Field

Use

payload.audio

Mono float32 samples in [-1, 1], required

payload.sampling_rate

Rate of audio, required; resampled to the model rate internally

meta is not read. The node keeps one recognition stream for all the messages it receives, so it expects a single audio source. A sentence is transmitted after enough silence, or when the node stops: when the pipeline is stopped, the sentence still open is transmitted to the next nodes, which are stopped after it. An audio source that stops sending while the pipeline keeps running (a caller hanging up, for example) leaves the sentence open until more audio comes.

Output message

Field

Content

payload['text']

The sentence, in lower case, without punctuation

payload['transcript']

List of words, each {'word', 'start', 'end'}: word starts with a space (as in TranscriberWhisper), start and end are seconds from the start of the stream

The message keeps the version and the timers of the audio message that closed the sentence. meta is empty.

License

Pipeline usage

{
  "name": "stt",
  "type": "TranscriberSherpa",
  "configuration": {}
}

Configuration

Default node arguments, as defined in the node config.toml file. Any of them can be overridden in the node configuration of a pipeline.

[arguments]
model = "sherpa-onnx-streaming-zipformer-en-2023-06-26"
model_dir = ""
num_threads = 2
min_trailing_silence = 0.8

[meta]

Reference

class TranscriberSherpa(
model: str,
model_dir: str,
num_threads: int,
min_trailing_silence: float,
**kwargs,
)

Transcribe audio with a streaming sherpa-onnx transducer model