Automatic Speech Recognition (ASR)
This section describes the supported integrations with Automatic Speech Recognition (ASR) or speech-to-text (STT) services. Configure an ASR engine underasr in a Voice Stream channel in credentials.yml. Each engine accepts keep_alive_interval (seconds, default 5) and a language_map that maps the assistant language keys from config.yml to provider settings. The top-level language and model options are deprecated; set provider-specific language and model values inside language_map instead.
Deepgram
Use the environment variableDEEPGRAM_API_KEY for Deepgram API Key. You can
request a key from Deepgram. It can be configured in a Voice Stream channel
as follows:
credentials.yml
Deepgram v1 models (Nova)
Deepgram v1 models, including Nova models, use Deepgram’s/v1/listen endpoint.
Turn DetectionDeepgram v1 models use two mechanisms to detect when a speaker has finished talking:
- Endpointing: Uses Voice Activity Detection (VAD) to detect silence after speech
- UtteranceEnd: Looks at word timings to detect gaps between words
endpointing and utterance_end_ms control these features respectively. For noisy environments, utterance_end_ms may be more reliable as it ignores non-speech audio. Read more on Deepgram DocumentationConfiguration parameters
endpoint: Optional, defaults toapi.deepgram.com- The endpoint URL for the Deepgram API.endpointing: Optional, defaults to400- Number of milliseconds of silence to determine the end of speech.smart_format: Optional, defaults totrue- Boolean value to enable or disable Deepgram’s smart formatting.utterance_end_ms: Optional, defaults to1000- Time in milliseconds to wait before considering an utterance complete.language_map: Optional. By default, Rasa maps the assistant language to Deepgram languageenand modelnova-3. Use each entry’slanguageandmodelfields to configure another provider language or model.
Deepgram v1 multilingual support
To configure Deepgram v1 for multilingual agent uselanguage_map property. Keys listed in the map
must match languages (language and additional_languages) mentioned in config.yml.
Deepgram v1 supports language and model as configuration parameters inside language_map.
config.yml
credentials.yml
Deepgram Flux (v2)
Use the separatedeepgram_flux engine for Deepgram Flux models. Flux uses Deepgram’s /v2/listen endpoint and model-integrated end-of-turn detection.
Turn DetectionDeepgram v2 models use model-integrated end-of-turn detection.
Configuration parameters
endpoint: Optional, defaults toapi.deepgram.com- The endpoint URL for the Deepgram API.eot_threshold: Optional - Confidence threshold for end-of-turn detection. When omitted, Deepgram uses its default.eot_timeout_ms: Optional - Maximum silence before forcing end-of-turn detection. When omitted, Deepgram uses its default.language_map: Optional. By default, Rasa maps the assistant language to modelflux-general-en. Each entry supportsmodeland an optionallanguagehint.
Deepgram Flux multilingual support
To configure Deepgram Flux for a multilingual agent, use thelanguage_map
property. Keys in the map must match the languages (language and
additional_languages) defined in config.yml.
Rasa’s Deepgram Flux integration supports model and an optional language inside language_map.
When language is set, Rasa passes it to Deepgram as a language_hint.
Omit language for single-language modelsOnly set
language for the multilingual flux-general-multi model. For single-language
models such as flux-general-en, omit language, as the model is already English-only.flux-* model inside language_map:
credentials.yml
flux-general-multi model and set language
on each entry to pass a Deepgram language_hint:
credentials.yml
Azure
Requires the python libraryazure-cognitiveservices-speech. The API Key can be set with the environment variable AZURE_SPEECH_API_KEY.
Sample configuration looks as follows:
credentials.yml
Configuration parameters
speech_region: Optional. The region identifier for the Azure Speech service, such aswestus. If you omit all connection fields, Rasa useseastus.speech_endpoint: Optional. A custom Azure Speech service endpoint, such as an endpoint behind a reverse proxy.speech_host: Optional. A custom service host inprotocol://host:portformat. The port is optional.language_map: Optional. Each entry must set Azure’slanguagecode. By default, Rasa maps the assistant language toen-US.
speech_region, speech_endpoint, or speech_host, make sure the value matches your Azure Speech resource. If you omit all three, Rasa uses the eastus region.
When connecting to Azure Cloud, speech_region is enough. For example:
credentials.yml
Azure ASR Multilingual Support
New in Rasa 3.16.0
language_map property. Keys listed in the map
must match languages (language and additional_languages) mentioned in config.yml.
Azure ASR supports language as configuration parameter inside language_map.
config.yml
credentials.yml
ElevenLabs
ElevenLabs Scribe v2 Realtime transcribes streamed voice audio. Set theELEVENLABS_API_KEY environment variable. The default endpoint is wss://api.elevenlabs.io/v1/speech-to-text/realtime.
credentials.yml
Configuration parameters
endpoint: Optional. The ElevenLabs WebSocket endpoint. Defaults towss://api.elevenlabs.io/v1/speech-to-text/realtime.commit_strategy: Optional. Usevad(default) to commit transcripts based on voice activity detection, ormanualto commit when the audio turn ends.include_timestamps: Optional, defaults tofalse. Ask ElevenLabs to include word timestamps.include_language_detection: Optional, defaults tofalse. Ask ElevenLabs to detect the language from audio. When enabled, Rasa does not send the configured language code.language_map: Optional. Each entry supportslanguageandmodel. The default model isscribe_v2_realtime.
Others
Looking for integration with a different ASR service? You can create your own custom ASR component.Custom ASR
You can implement your own custom ASR component as a Python class to integrate with any third-party speech recognition service. A custom ASR component must subclass theASREngine class from rasa.core.channels.voice_stream.asr.asr_engine.
Your custom ASR component receives audio in the RasaAudioBytes format
and may need to convert it to your service’s expected format.
Required Methods
Your custom ASR component must implement the following methods:open_websocket_connection(): Establish a websocket connection to your ASR servicefrom_config_dict(config: Dict): Class method to create an instance from configuration dictionarysignal_audio_done(): Signal to the ASR service that audio input has endedrasa_audio_bytes_to_engine_bytes(chunk: RasaAudioBytes): Convert Rasa audio format to your engine’s expected formatengine_event_to_asr_event(event: Any): Convert your engine’s events to Rasa’sASREventformatget_default_config(): Static method that returns the default configuration for your component
Optional Methods
You may also override these methods as needed:send_keep_alive(): Send keep-alive messages to maintain the connection. The default implementation is only apassstatement.close_connection(): Custom cleanup when closing the connection. Default implementation is as follows,
ASR Events
Yourengine_event_to_asr_event method should return appropriate ASREvent objects:
UserIsSpeaking(transcript): For interim/partial transcripts while the user is speakingNewTranscript(transcript): For final transcripts when the user has finished speaking
Example Implementation
Here’s an example based on the Deepgram implementation structure:custom_asr.py
Configure a custom ASR component
To use a custom ASR component, configure its module path and settings in yourcredentials.yml file. The configuration should contain the module path of your custom class and any required configuration parameters.
The module path follows the format path.to.module.ClassName. For example, a class MyASR in addons/custom_asr.py has module path addons.custom_asr.MyASR.
Custom ASR Configuration Example
credentials.yml