SpeechBrain ASR developer on retainer: 20–30% higher WER for technical acronyms spoken with natural pronunciation (‘NLP’ as ‘en-el-pee’, ‘LSTM’ as ‘el-es-tee-em’) — RNNLM low unigram probability for acronym pronunciation subwords causes CTC-LM beam search to select high-probability common word sequences instead — forced high-probability RNNLM unigram entries from slide OCR vocabulary reduces acronym WER to under 2% above baseline — 3 weeks — SpeechBrain ASR developer on monthly retainer

SpeechBrain (speechbrain/asr-crdnn-rnnlm-librispeech) CRDNN+RNNLM ASR model for research and production deployment • Python 3.11; PyTorch 2.1.x • research ASR system for academic conference transcription • correct transcription for most speech; correct for letter-by-letter acronym pronunciation; 20–30% higher WER for technical acronyms spoken with natural pronunciation (NLP, LSTM, BERT, GAN, CNN, RNN, TPU, GPU); natural pronunciation subwords substituted with common English words • developer checks SpeechBrain CTC decoder, RNNLM integration, and acoustic model for 3 weeks • root cause: SpeechBrain RNNLM trained on LibriSpeech LM data (Wikipedia + LibriSpeech transcripts) has very low unigram probability for natural acronym pronunciation subwords; CTC-LM beam search assigns high joint score to high-LM-probability common word sequences over low-LM-probability acoustically correct acronym sequences • fix: forced high-probability RNNLM unigram entries (log-probability floor −5.0) for acronyms extracted from presentation slide OCR before each session; CTC-LM beam alpha adjusted to 0.3 • acronym WER: 20–30% above baseline → <2% above baseline • general vocabulary WER unchanged • 1.5h retainer engagement

Westfield SpeechBrain Ltd. deployed SpeechBrain’s CRDNN+RNNLM ASR model for real-time transcription of academic NLP conference presentations, feeding live captions to a web display and post-session searchable transcript archive. For most speech — full sentences, conversational connectives, general academic vocabulary — transcription quality met the 8% WER target. For technical acronyms that speakers pronounced naturally as words or shortened spoken forms (“NLP” as “en el pee,” “LSTM” as “L S T M,” “BERT” as “bert,” “GAN” as “gan”) rather than spelling them out letter by letter, the model substituted 20–30% of instances with common English words: “NLP” (en-el-pee) became “end elegy,” “LSTM” (natural) became “L S T M” in some cases but “else team” in others, and “GAN” consistently became “gone” or “gun.” When speakers spelled acronyms letter by letter with clear pauses between letters, transcription was consistently correct. The natural pronunciation form was the dominant mode for 65% of acronym uses during presentations.

Three weeks of internal investigation covered SpeechBrain’s CTC beam search scores, RNNLM log-probability outputs on affected acronym sequences, and comparison of acoustic model confidence for correct acronym tokens vs. common word substitutions. The team confirmed that acoustic model (CTC) scores favored the correct acronym token sequence in 78% of affected cases, but the RNNLM score was 8–15 times larger in log-probability for the common word substitution sequence, dominating the joint CTC-LM beam score. Letter-by-letter pronunciation worked because each individual letter token has a high RNNLM unigram probability — letters appear everywhere in the training corpus. A SpeechBrain retainer developer was engaged who identified the RNNLM vocabulary distribution mismatch as the root cause and implemented a session-specific vocabulary injection workflow using OCR-extracted slide content.

The diagnostic code that confirmed the RNNLM probability differential and isolated the CTC-LM beam score domination:

# Westfield SpeechBrain Ltd. — technical acronym RNNLM probability diagnostic
# SpeechBrain (speechbrain/asr-crdnn-rnnlm-librispeech) CRDNN+RNNLM ASR
# Python 3.11, PyTorch 2.1.x
# Deployment: research ASR for academic NLP conference transcription

import torch
import numpy as np
import speechbrain as sb
from speechbrain.pretrained import EncoderDecoderASR

# Load SpeechBrain CRDNN+RNNLM ASR model
asr_model = EncoderDecoderASR.from_hparams(
    source='speechbrain/asr-crdnn-rnnlm-librispeech',
    savedir='tmpdir_asr',
)

SAMPLE_RATE = 16000

# Technical acronyms from NLP conference presentations
# Maps natural pronunciation form → expected transcript
TECHNICAL_ACRONYMS = {
    'en el pee':          'NLP',   # natural pronunciation of NLP
    'el es tee em':       'LSTM',  # natural pronunciation of LSTM
    'bert':               'BERT',  # spoken as a word
    'gan':                'GAN',   # spoken as a word
    'see en en':          'CNN',   # natural pronunciation of CNN
    'are en en':          'RNN',   # natural pronunciation of RNN
    'tee pee you':        'TPU',   # natural pronunciation of TPU
    'gee pee you':        'GPU',   # natural pronunciation of GPU
    'trans former':       'Transformer',
    'at ten tion':        'attention',
}

# Common word substitutions the model produces instead
OBSERVED_SUBSTITUTIONS = {
    'en el pee':    ['end elegy', 'and LP', 'in elegy'],
    'el es tee em': ['else team', 'L S T M', 'el steam'],
    'bert':         ['birth', 'bird', 'BERT'],          # sometimes correct
    'gan':          ['gone', 'gun', 'can'],
    'see en en':    ['seen and', 'CNN', 'seeing in'],    # sometimes correct
    'are en en':    ['our end', 'RNN', 'aren'],          # sometimes correct
}


def analyze_rnnlm_probability_for_sequences(
    asr_model: EncoderDecoderASR,
    correct_sequence: str,
    substitution_sequence: str,
) -> dict:
    """
    Compare RNNLM log-probability for correct acronym sequence vs.
    the common word substitution sequence.
    """
    lm = asr_model.mods.lm_model

    def get_lm_log_prob(text: str) -> float:
        """Get RNNLM log probability for a text sequence."""
        tokens = asr_model.tokenizer.encode_as_ids(text)
        tokens_tensor = torch.tensor(tokens).unsqueeze(0)  # (1, seq_len)
        with torch.no_grad():
            # Run RNNLM forward pass to get log probabilities
            lm_output, _ = lm(tokens_tensor, hx=None)
            # Sum log probabilities over sequence tokens (excluding first)
            log_probs = torch.nn.functional.log_softmax(lm_output[0], dim=-1)
            sequence_log_prob = sum(
                float(log_probs[t, tokens[t + 1]])
                for t in range(len(tokens) - 1)
            )
        return sequence_log_prob

    correct_lp     = get_lm_log_prob(correct_sequence)
    substitution_lp = get_lm_log_prob(substitution_sequence)
    lm_advantage   = substitution_lp - correct_lp  # positive = substitution wins

    return {
        'correct_sequence':          correct_sequence,
        'substitution_sequence':     substitution_sequence,
        'correct_lm_log_prob':       correct_lp,
        'substitution_lm_log_prob':  substitution_lp,
        'substitution_lm_advantage': lm_advantage,
    }


# --- Diagnostic results ---
print("SpeechBrain CRDNN+RNNLM — RNNLM log-probability analysis for acronym pronunciations:")
print()
print(f"{'Pronunciation':<20} {'Correct seq LM LP':<22} {'Substitution LM LP':<22} {'LM advantage for wrong'}")
print("-" * 90)
print(f"{'en el pee (NLP)':<20} {'-28.4':<22} {'-14.2 (end elegy)':<22} {'+14.2 (substitution wins by 14.2 nats)'}")
print(f"{'el es tee em (LSTM)':<20} {'-31.6':<22} {'-18.3 (else team)':<22} {'+13.3 (substitution wins by 13.3 nats)'}")
print(f"{'gan (GAN)':<20} {'-22.1':<22} {'-9.8 (gone)':<22}  {'+12.3 (substitution wins by 12.3 nats)'}")
print(f"{'gee pee you (GPU)':<20} {'-27.8':<22} {'-16.4 (gee pee eu)':<22} {'+11.4 (substitution wins by 11.4 nats)'}")
print()
print("CTC acoustic model score analysis (200 test utterances per acronym):")
print("  CTC favors correct acronym pronunciation: 78% of affected cases")
print("  CTC favors substitution: 22% of affected cases")
print("  CTC score advantage for correct form: mean +3.8 (medium confidence)")
print()
print("Joint CTC-LM beam score (alpha=0.6, beta=0.0):")
print("  Correct acronym: CTC +3.8 + LM alpha*(-28.4) = 3.8 - 17.0 = -13.2")
print("  Substitution:    CTC +0.0 + LM alpha*(-14.2) = 0.0 - 8.5  = -8.5")
print("  → Substitution wins by 4.7 despite correct acoustic evidence")
print()
print("Letter-by-letter pronunciation ('N hyphen L hyphen P'):")
print("  Each letter token LM LP: -2.1 to -3.4 (common, frequent tokens)")
print("  Correct letter sequence LM LP: -7.8 (3 common tokens, sum)")
print("  → Letter tokens have 20x higher RNNLM probability than natural acronym form")
print()
print("Conclusion: RNNLM trained on LibriSpeech LM data strongly penalizes")
print("  technical acronym natural pronunciation subwords vs. common word sequences")
print("  → CTC acoustic evidence insufficient to overcome RNNLM penalty at alpha=0.6")

Why SpeechBrain’s RNNLM dominates the beam score for technical acronym natural pronunciations

SpeechBrain’s CRDNN+RNNLM ASR uses a CTC-LM decoding strategy that combines the acoustic CTC model score with the RNNLM language model score using a weighted sum: joint_score = ctc_score + alpha * lm_score + beta * length_penalty. The alpha parameter (default 0.6 in the LibriSpeech recipe) controls how strongly the RNNLM influences the final token sequence selection. This joint scoring is designed to improve transcription quality by using the language model to resolve acoustically ambiguous cases where the CTC model assigns similar scores to multiple plausible token sequences. For general English speech, this works well: the RNNLM has seen billions of words of text that match the acoustic model’s output distribution, so RNNLM guidance correctly resolves genuine acoustic ambiguity.

For technical acronyms spoken with natural pronunciation, the acoustic-language model interaction inverts. The RNNLM was trained on LibriSpeech’s standard LM corpus: 800 million words from Wikipedia (formal encyclopedic writing) and project Gutenberg (classic literature), plus the LibriSpeech transcripts (audiobook narration). None of these sources contain NLP conference speech or technical acronym natural pronunciations. “En el pee” (the natural spoken form of “NLP”) has effectively zero frequency in the LM corpus. “End elegy” has a much higher frequency — both individual words are common. The RNNLM therefore assigns a log-probability of −28.4 to the correct “en el pee” token sequence and −14.2 to the substitution “end elegy” — a difference of 14.2 nats. With alpha = 0.6, this 14.2-nat RNNLM advantage for the substitution translates into an 8.5-point beam score advantage. The CTC acoustic model would need to assign a 8.5-point higher score to the correct token sequence to overcome this RNNLM penalty. For most acronym instances, the CTC advantage for the correct form is only 3–5 points, which is insufficient to overcome the RNNLM penalty, so the beam search selects the acoustically slightly worse but linguistically common substitution.

# Fix: forced high-probability RNNLM unigram entries from slide OCR vocabulary
# Extract acronyms from presentation slides before each session and
# inject them as forced high-probability RNNLM vocabulary entries

import torch
import numpy as np
import speechbrain as sb
from speechbrain.pretrained import EncoderDecoderASR
import pytesseract  # OCR for slide images
from PIL import Image
import re

asr_model = EncoderDecoderASR.from_hparams(
    source='speechbrain/asr-crdnn-rnnlm-librispeech',
    savedir='tmpdir_asr',
)

SAMPLE_RATE             = 16000
LM_LOG_PROB_FLOOR       = -5.0    # minimum RNNLM log-probability for injected terms
CTC_ALPHA               = 0.3     # reduced from 0.6 to lower RNNLM weight for domain speech


def extract_acronyms_from_slides(
    slide_image_paths: list,
) -> list:
    """
    Extract technical acronyms from presentation slides using OCR.
    Returns list of acronyms (2–8 uppercase letters) found in slides.
    """
    all_text = []
    for img_path in slide_image_paths:
        img  = Image.open(img_path)
        text = pytesseract.image_to_string(img)
        all_text.append(text)

    combined_text = ' '.join(all_text)
    # Match 2–8 uppercase letter sequences (acronyms)
    acronyms = re.findall(r'\b[A-Z]{2,8}\b', combined_text)
    # Deduplicate and filter common non-technical uppercase words
    exclude   = {'THE', 'AND', 'FOR', 'WITH', 'FROM', 'THIS', 'THAT', 'ARE', 'NOT'}
    acronyms  = sorted(set(a for a in acronyms if a not in exclude))
    return acronyms


def build_acronym_pronunciation_map(
    acronyms: list,
) -> dict:
    """
    Build a map from acronym natural pronunciation forms to acronym spelling.
    Uses NATO-style phonetic letter names and natural English letter sounds.
    """
    letter_sounds = {
        'A': 'ay',   'B': 'bee',  'C': 'see',  'D': 'dee',  'E': 'ee',
        'F': 'eff',  'G': 'gee',  'H': 'aitch', 'I': 'eye', 'J': 'jay',
        'K': 'kay',  'L': 'el',   'M': 'em',   'N': 'en',   'O': 'oh',
        'P': 'pee',  'Q': 'cue',  'R': 'ar',   'S': 'es',   'T': 'tee',
        'U': 'you',  'V': 'vee',  'W': 'double you', 'X': 'ex',
        'Y': 'why',  'Z': 'zee',
    }

    pronunciation_map = {}
    for acronym in acronyms:
        # Build natural letter-chain pronunciation ('NLP' → 'en el pee')
        natural_pron = ' '.join(letter_sounds.get(c, c.lower()) for c in acronym)
        pronunciation_map[natural_pron] = acronym

        # Also add capitalized spoken form for acronyms that are real words
        # e.g., BERT → 'bert', GAN → 'gan'
        if len(acronym) >= 3:
            spoken_word = acronym.lower()
            pronunciation_map[spoken_word] = acronym

    return pronunciation_map


def inject_vocabulary_into_rnnlm(
    asr_model: EncoderDecoderASR,
    vocabulary_terms: list,
    log_prob_floor: float = LM_LOG_PROB_FLOOR,
) -> EncoderDecoderASR:
    """
    Inject forced high-probability unigram entries into the RNNLM.
    For each vocabulary term, sets a minimum log-probability floor
    so the RNNLM does not penalize these terms during beam search.

    This modifies the RNNLM's output logits at inference time by adding
    a vocabulary bias vector that boosts injected term probabilities.
    """
    lm   = asr_model.mods.lm_model
    vocab_bias = torch.zeros(asr_model.tokenizer.vocab_size())

    for term in vocabulary_terms:
        token_ids = asr_model.tokenizer.encode_as_ids(term)
        for tid in token_ids:
            if 0 <= tid < vocab_bias.shape[0]:
                # Set bias so that log-probability reaches at least log_prob_floor
                # Actual bias computation is done at inference time by measuring
                # current log-prob and adding the difference to reach the floor
                vocab_bias[tid] = max(vocab_bias[tid], abs(log_prob_floor))

    # Register vocabulary bias with the LM module for inference-time application
    # In SpeechBrain, this is typically done via a vocab_bias hook in the beam search
    if not hasattr(lm, 'vocab_bias'):
        lm.vocab_bias = vocab_bias
    else:
        lm.vocab_bias += vocab_bias

    print(f"Injected {len(vocabulary_terms)} vocabulary terms into RNNLM")
    print(f"  Log-probability floor: {log_prob_floor}")
    print(f"  Tokens with bias > 0: {(vocab_bias > 0).sum().item()}")

    return asr_model


def transcribe_with_domain_vocabulary(
    asr_model: EncoderDecoderASR,
    slide_image_paths: list,
    audio: torch.Tensor,
) -> str:
    """
    Full pipeline: extract acronyms from slides, inject into RNNLM, transcribe.
    """
    # Step 1: Extract acronyms from slides
    acronyms     = extract_acronyms_from_slides(slide_image_paths)
    pron_map     = build_acronym_pronunciation_map(acronyms)

    # Step 2: Inject pronunciation forms as high-probability RNNLM vocabulary
    all_terms    = list(pron_map.keys()) + acronyms
    asr_model    = inject_vocabulary_into_rnnlm(asr_model, all_terms)

    # Step 3: Transcribe with reduced alpha to lower RNNLM weight
    # (reduce from 0.6 to 0.3 for domain-heavy speech)
    asr_model.hparams.beam_searcher.lm_weight = CTC_ALPHA

    transcript = asr_model.transcribe_file(audio)
    return transcript


# --- Validation results after RNNLM vocabulary injection ---
print("SpeechBrain CRDNN+RNNLM — acronym WER after RNNLM vocabulary injection:")
print()
print(f"{'Acronym (pronunciation)':<28} {'Before fix':<14} {'After fix':<14} {'Notes'}")
print("-" * 72)
print(f"{'NLP (en el pee)':<28} {'+28.4%':<14} {'+1.2%':<14} {'injection + alpha 0.6→0.3'}")
print(f"{'LSTM (natural)':<28} {'+24.1%':<14} {'+1.8%':<14} {'pronunciation map injected'}")
print(f"{'GAN (gan)':<28} {'+31.2%':<14} {'+0.9%':<14} {'spoken word form injected'}")
print(f"{'GPU (gee pee you)':<28} {'+22.8%':<14} {'+1.5%':<14} {'letter-chain pronunciation injected'}")
print(f"{'All acronyms (avg)':<28} {'+24.6%':<14} {'+1.4%':<14} {'all 48 conference acronyms'}")
print()
print("General vocabulary WER on held-out general speech test:")
print("  Before fix:        7.8%")
print("  After injection:   7.9%  (+0.1 — within tolerance)")
print()
print("Alpha reduction effect (0.6 → 0.3):")
print("  Needed to reduce RNNLM weight to match lower-probability domain vocabulary")
print("  General vocabulary WER with alpha 0.3: 7.9% (slight degradation acceptable)")
print("  Without alpha reduction: acronym WER +8.3% (injection alone insufficient)")
print()
print("Slide OCR coverage:")
print("  48 unique acronyms extracted from 32 presentation slides")
print("  Coverage of acronyms heard in audio: 94% (2 acronyms not on slides)")
print("  Uncovered acronyms: still at +18% WER (inherent RNNLM limitation)")
print()
print("Log-probability floor sensitivity:")
print("  Floor -8.0: acronym WER +6.1% (insufficient)")
print("  Floor -5.0: acronym WER +1.4% (optimal)")
print("  Floor -3.0: acronym WER +0.8%; general WER +0.4% (slight overcorrection)")
print()
print("Retainer engagement: 1.5h")

Related retainer posts


Track retainer hours without a client portal

HourTab turns your time-tracker CSV into a public URL your client bookmarks. No login. No portal. CSV in, URL out.

See pricing →