Integrating a Custom ASR Provider
The provider documentation is: $documentation
Use the documentation as the source of truth for the provider protocol. If it is
missing, ask for the provider's streaming ASR API documentation before implementing.
Follow links from it only when needed to resolve authentication, WebSocket messages,
audio formats, endpointing, or limits.
Workflow
- Inspect the assistant's installed Rasa version and the actual
ASREngine,
ASREngineConfig, ASREvent, and RasaAudioBytes APIs. Follow those signatures
when they differ from examples.
- Review existing custom speech components and project conventions before choosing a
module path. Default to
addons/custom_asr.py only when no convention exists.
- Read the provider documentation and complete the feasibility checks in
references/integration-framework.md.
- If a hard requirement is unsupported or undocumented, report every incompatibility
found and stop. Do not invent protocol messages, transcript semantics, or
client-side endpointing.
- Design the configuration and event mapping, then implement the custom
ASREngine.
- Configure its fully qualified class path under the voice channel's
asr key in
credentials.yml. Keep secrets in environment variables.
- Add focused tests for provider-message mapping, transcript accumulation, audio
conversion, and malformed/error events.
- Run the project's relevant tests, lint/type checks, and Rasa configuration
validation. Report any validation that could not be run.
Feasibility gate
A custom ASR integration must have:
- a documented real-time streaming API compatible with the
ASREngine connection
lifecycle;
- a documented end-of-utterance or end-of-turn signal that can produce exactly one
NewTranscript;
- an audio encoding and sample rate that the provider accepts directly or that can be
converted safely from
RasaAudioBytes;
- documented authentication suitable for a server process;
- clear partial, final, error, and connection-close message semantics.
Interim transcripts are recommended but not mandatory. If they are unavailable, note
that UserIsSpeaking cannot carry partial text and that barge-in behavior may be less
responsive. Provider-side turn detection is mandatory: do not fabricate it with an
arbitrary silence timer.
Implementation contract
- Subclass the installed version's
ASREngine and use its matching configuration
type.
- Implement every abstract/required method in that installed version. This commonly
includes connection creation, config construction, audio conversion, provider-event
conversion, end-of-audio signaling, and default configuration.
- Map partial speech to
UserIsSpeaking, completed turns to NewTranscript, and
explicit silence to UserSilence only when the provider semantics support it.
- Accumulate final fragments only when the provider sends multiple fragments for one
turn. Reset accumulation after emitting
NewTranscript.
- Treat provider error frames and unexpected socket closure explicitly. Never log API
keys, authorization headers, or raw credentials.
- Declare
required_env_vars and required_packages when supported by the installed
base class. Prefer the project's existing WebSocket stack over a vendor SDK when both
expose the same documented protocol.
- Keep provider-specific settings in the config type. Prefer
language_map for
multilingual assistants when supported by the installed Rasa version.
- Do not edit Rasa's built-in engine registry for a project-level integration.
Configuration
Reference the custom class by module path:
# credentials.yml
browser_audio:
# ... channel configuration
asr:
name: addons.custom_asr.MyASR
endpoint: wss://api.example.com/v1/speech
language: en-US
The module must be importable from the process that starts Rasa. Put secret values in
environment variables, document the required variable names, and never commit them to
credentials.yml.
For multilingual assistants, ensure every language_map key matches language or
additional_languages in config.yml.
Done criteria
- The provider protocol is supported by cited documentation.
- A documented provider turn-end event maps to one
NewTranscript.
- Audio encoding, sample rate, and channel expectations are compatible.
- The custom class imports and is referenced correctly from
credentials.yml.
- Secrets stay outside source-controlled configuration.
- Tests and available project validation pass.
1---2name: rasa-integrating-asr3description: Integrates a custom automatic speech recognition (ASR/STT) provider with Rasa voice channels from provider documentation. Use when implementing an ASREngine, mapping streaming transcripts and turn detection to Rasa events, or configuring custom ASR credentials.4license: Apache-2.05---67# Integrating a Custom ASR Provider89The provider documentation is: **$documentation**1011Use the documentation as the source of truth for the provider protocol. If it is12missing, ask for the provider's streaming ASR API documentation before implementing.13Follow links from it only when needed to resolve authentication, WebSocket messages,14audio formats, endpointing, or limits.1516## Workflow17181. Inspect the assistant's installed Rasa version and the actual `ASREngine`,19 `ASREngineConfig`, `ASREvent`, and `RasaAudioBytes` APIs. Follow those signatures20 when they differ from examples.212. Review existing custom speech components and project conventions before choosing a22 module path. Default to `addons/custom_asr.py` only when no convention exists.233. Read the provider documentation and complete the feasibility checks in24 [references/integration-framework.md](references/integration-framework.md).254. If a hard requirement is unsupported or undocumented, report every incompatibility26 found and stop. Do not invent protocol messages, transcript semantics, or27 client-side endpointing.285. Design the configuration and event mapping, then implement the custom `ASREngine`.296. Configure its fully qualified class path under the voice channel's `asr` key in30 `credentials.yml`. Keep secrets in environment variables.317. Add focused tests for provider-message mapping, transcript accumulation, audio32 conversion, and malformed/error events.338. Run the project's relevant tests, lint/type checks, and Rasa configuration34 validation. Report any validation that could not be run.3536## Feasibility gate3738A custom ASR integration must have:3940- a documented real-time streaming API compatible with the `ASREngine` connection41 lifecycle;42- a documented end-of-utterance or end-of-turn signal that can produce exactly one43 `NewTranscript`;44- an audio encoding and sample rate that the provider accepts directly or that can be45 converted safely from `RasaAudioBytes`;46- documented authentication suitable for a server process;47- clear partial, final, error, and connection-close message semantics.4849Interim transcripts are recommended but not mandatory. If they are unavailable, note50that `UserIsSpeaking` cannot carry partial text and that barge-in behavior may be less51responsive. Provider-side turn detection is mandatory: do not fabricate it with an52arbitrary silence timer.5354## Implementation contract5556- Subclass the installed version's `ASREngine` and use its matching configuration57 type.58- Implement every abstract/required method in that installed version. This commonly59 includes connection creation, config construction, audio conversion, provider-event60 conversion, end-of-audio signaling, and default configuration.61- Map partial speech to `UserIsSpeaking`, completed turns to `NewTranscript`, and62 explicit silence to `UserSilence` only when the provider semantics support it.63- Accumulate final fragments only when the provider sends multiple fragments for one64 turn. Reset accumulation after emitting `NewTranscript`.65- Treat provider error frames and unexpected socket closure explicitly. Never log API66 keys, authorization headers, or raw credentials.67- Declare `required_env_vars` and `required_packages` when supported by the installed68 base class. Prefer the project's existing WebSocket stack over a vendor SDK when both69 expose the same documented protocol.70- Keep provider-specific settings in the config type. Prefer `language_map` for71 multilingual assistants when supported by the installed Rasa version.72- Do not edit Rasa's built-in engine registry for a project-level integration.7374## Configuration7576Reference the custom class by module path:7778```yaml79# credentials.yml80browser_audio:81 # ... channel configuration82 asr:83 name: addons.custom_asr.MyASR84 endpoint: wss://api.example.com/v1/speech85 language: en-US86```8788The module must be importable from the process that starts Rasa. Put secret values in89environment variables, document the required variable names, and never commit them to90`credentials.yml`.9192For multilingual assistants, ensure every `language_map` key matches `language` or93`additional_languages` in `config.yml`.9495## Done criteria9697- The provider protocol is supported by cited documentation.98- A documented provider turn-end event maps to one `NewTranscript`.99- Audio encoding, sample rate, and channel expectations are compatible.100- The custom class imports and is referenced correctly from `credentials.yml`.101- Secrets stay outside source-controlled configuration.102- Tests and available project validation pass.