Skip to main content
You can set Automatic Speech Recognition (ASR) in functions by using:
  • conv.set_asr_biasing()
  • conv.clear_asr_biasing()
Typical cases include names, booking references, product terms, medical terminology, or locations that you fetch from an API and expect the user to say next.

How it behaves

Persists across turns

ASR biasing set with conv.set_asr_biasing() stays active across turns. It will continue to apply until you:
  • call conv.clear_asr_biasing(), or
  • call conv.set_asr_biasing() again with new values.
You do not need to re-apply biasing on every turn.

Takes priority over other ASR settings

Function-set ASR biasing has the highest priority. It is merged with any ASR configuration defined elsewhere, including:
  • flow-level ASR settings
  • step-level ASR settings
  • language-specific ASR settings
If the same phrase appears in multiple places, the value set by this type of biasing takes precedence.

When to use this

Use ASR biasing from functions when:
  • You retrieve data at runtime and want ASR to reliably capture it.
  • You are about to ask the user to say something you already know, such as a reference number or surname.
  • Certain domain terms are often misheard and need extra support.
Sets ASR biasing for the current conversation.

Parameters

keywords (optional, list of strings)

A list of phrases that are all biased equally. Use this when you have a small set of expected words and do not need different strengths.

custom_biases (optional, dictionary mapping strings to numbers)

A mapping of phrase to bias weight. Use this when some phrases should be recognised more strongly than others.

Validation

Inputs are validated when the function runs:
  • keywords must be a list of strings
  • custom_biases must be a dictionary with string keys and numeric values
Invalid inputs raise a ValueError.

Examples

Bias equally toward a set of terms

Use this when all phrases are equally important.
def set_expected_terms(conv):
    conv.set_asr_biasing(
        keywords=["hotel", "restaurant", "booking", "cancellation"]
    )

Bias unevenly using custom weights

Use this when some phrases matter more than others.
def set_weighted_terms(conv):
    conv.set_asr_biasing(
        custom_biases={
            "booking reference": 3.0,
            "cancellation": 2.5,
            "non refundable": 2.0,
        }
    )

Combine keywords and custom biases

This is common when you want a general nudge plus one high-priority term:
def set_mixed_biasing(conv):
    conv.set_asr_biasing(
        keywords=["dermatology", "eczema", "psoriasis"],
        custom_biases={"isotretinoin": 3.0}
    )

Bias toward values returned from an API

Set biasing after fetching data, before asking the user to say it.
def verify_booking(conv):
    booking = conv.api.reservations.get_booking()

    conv.set_asr_biasing(
        custom_biases={
            booking["surname"]: 3.0,
            booking["reference"]: 3.0,
        }
    )

    conv.say("Could you confirm the surname and booking reference?")

conv.clear_asr_biasing()

Clears any ASR biasing that was previously set for future turns. This is recommended when biasing is only needed for a short part of the conversation, such as a verification step.

Example: set biasing, then clear it

def verify_reference(conv):
    ref = conv.api.orders.get_expected_reference()

    conv.set_asr_biasing(custom_biases={ref: 3.0})
    conv.say("Please say your reference number.")

    conv.clear_asr_biasing()