Can a Listener Recover the Variable? Measuring Spoken Code Identifiers in Unvoweled Arabic Speech

When a developer in Cairo reads a code review aloud, or a screen reader voices a technical chat, the speech mixes three things. There is Arabic written without short vowels. There are English words. And there are invented code names such as getUserData, sometimes carrying Arabic grammatical prefixes and suffixes (the "Franken-words" documented in ArzEn). The standard automatic way to check whether synthesized speech is intelligible is to transcribe it with a speech recognizer and count word errors. For these code names that check measures the wrong thing. A recognizer cannot be expected to write getUserData as one camel-cased token. What matters to the listener is whether they can tell which variable was meant, often among near-twins like getUser and getUsers. We propose to measure that directly.

Here is the core idea in two sentences. In code-bearing text the set of identifiers that could plausibly be meant is finite: it is the names in scope in the surrounding code. That turns an unbounded-vocabulary transcription problem into a closed-set discrimination problem that a machine listener can score reliably. We build a benchmark of Arabic technical utterances with embedded identifiers and human listening tests of identifier recovery. We then test whether this scope-constrained automatic score tracks human recovery where recognizer-based word error rate does not. As a secondary question, we ask whether an identifier-aware text front end improves recovery over the obvious mask-and-reinsert pipeline.

Core Claim

Our first claim is about measurement. We expect recognizer-transcription word error rate on spoken identifiers to correlate weakly with human identifier recovery. We expect a scope-constrained score to correlate strongly. The score ranks the true identifier against hard in-scope distractors using the acoustic likelihood of each candidate's pronunciation. Our second, conditional claim is that the divergence is not just noise. Systems that differ in how they handle identifiers fused with Arabic clitics (small grammatical prefixes and suffixes attached to a word) should be ranked differently by the two scores, and humans should side with the scope-constrained one. If the first claim fails, the benchmark and human data remain useful, but the metric proposal is wrong. We will report that outcome.

Relation to Prior Work

Work on identifiers in code supplies the key structural insight. A Simple Approach for Handling Out-of-Vocabulary Identifiers in Deep Learning for Source Code replaces rare names with ordered placeholders and shows that preserving identity and repetition often matters more than the name itself. That paper outperforms 50,000-token models with a 1,000-token vocabulary on variable misuse. Pointer models that copy names from the local context (Summarizing Source Code using a Neural Attention Model, Learning to Fix Build Errors with Graph2Diff Neural Networks) rest on the same observation: the relevant names are in context. Our evaluation listener borrows this idea, judging recovery against the in-scope set rather than an open vocabulary. All of this prior work evaluates in text, through perplexity or accuracy. None asks whether the spoken form keeps identifiers distinguishable. Big Code != Big Vocabulary shows subword segmentation (byte-pair encoding, which builds words from frequent character chunks) removes unknown tokens in code. Can Identifier Splitting Improve Open-Vocabulary Language Model of Code? shows that segmentation splits names into meaningless pieces unless guided by casing conventions. We reuse casing-guided splitting in the front end. Building Language Models for Text with Named Entities first predicts an entity's type and then its surface form. We reuse that decomposition to condition Arabic clitic vowels on identifier type.

On the orthographic side, Advancing Arabic Diacritization restores short vowels with a BiLSTM. It also notes degradation on technical and foreign vocabulary, which motivates our setting. DialG2P converts Egyptian spelling to phonemes but scores only string edit distance. Textual Data Augmentation for Arabic-English Code-Switching Speech Recognition shows that splitting Arabic clitics from English stems makes hybrid words tractable for recognition language models. We use the same segmentation, but for synthesis and evaluation.

The metric-divergence literature supplies the motivation. TajweedWER shows naive word error rate saturating at or above 100% purely from orthographic conventions. Its fix is normalization: strip diacritics and restore elided letters. ArVoice finds humans prefer diacritized-input synthesis, while recognizer-based checks of some systems exceed 100% error. Correcting transcript inconsistencies alone shifted error by about 40%. Diagnose, Then Refine (LoopTTS) shows utterance-level metrics miss local defects and uses an audio language model as judge, but only for English stress and pauses. Our proposal differs from all three. Normalization cannot help when the reference token, a camel-cased identifier, has no canonical spoken spelling. And our question is discrimination among a known candidate set, not general naturalness.

Research Program

We first build the benchmark. Identifiers come from repository-split Python150k and JavaScript150k functions, each paired with its scope set: the other names visible in that function. From that set we mine hard distractors, meaning names within small edit or phonetic distance of the target. Native Egyptian Arabic-speaking developers write short technical explanations that refer to these identifiers. They are free to attach clitics, giving forms like "ha-propagate-ha" with a code name as the stem. These are added to code-switched sentence frames modeled on ArzEn. We target on the order of 1,500 utterances and 3,000 identifier slots, plus a subset read by human developers as a natural-speech reference.

The automatic listener works as follows. For an identifier slot with true identifier $x$ and scope set $S$, an Arabic-English acoustic model force-aligns the candidate pronunciations of every $c \in S$ to the slot's audio. It computes a likelihood $\ell(c)$, taking the maximum over a small set of acceptable verbalizations per identifier, such as split-and-read or partial spelling. Scope-constrained recovery is

$$R = \frac{1}{N}\sum_{i=1}^{N} \mathbf{1}\left[x_i = \arg\max_{c \in S_i} \ell_i(c)\right],$$

where $N$ is the number of slots. We report $R$ both for full scope sets and for hard-distractor-only sets.

Humans do the same task. Developer listeners hear each utterance, see the code snippet, and type or select the identifier they heard. Selection uses a free-text field graded against the scope set, so the scope list does not give the answer away. Listeners also rate naturalness. The human recovery rate is the target that every automatic metric is judged against.

The systems under test combine two acoustic models with several text front ends. The acoustic models are VITS trained on diacritized ArVoice data and Fish-Speech. The front ends are described in the baselines below. Our own front end splits identifiers by casing and subword units and separates Arabic clitics with Farasa-style segmentation. It predicts an identifier type (function, boolean, class, plain noun) from the code and conditions the vowels of the attached clitics and neighboring homographs on that type. Arabic segments go to the diacritizer; identifier segments go to an English pronunciation model.

Baselines

The naive reference point is raw text passed to each synthesizer. Unvoweled Arabic and camel-cased names go in unchanged, and the synthesizer's internal handling decides everything. This bounds how badly identifiers fare by default.

The strongest existing pipeline is mask-and-reinsert. It follows A Simple Approach for Handling OOV Identifiers. Identifiers are replaced with placeholders, and the Arabic is diacritized with the BiLSTM from Advancing Arabic Diacritization (reported WER 3.12% on WikiNews-2014). For Egyptian text it is instead converted to phonemes with DialG2P (reported 5.15% WER, 1.71% PER on Egyptian QADI tweets; a Transformer cascade reports 5.11% WER). Identifiers are reinserted, split by casing, and voiced with English pronunciations. This is the competitor a practitioner would build today, and it handles standalone identifiers well. Its weak point is clitics fused to identifiers. We run it with the same acoustic models, the same synthesizer training data and the same tuning budget as our front end. No reported result for identifier recovery in synthesized speech was found on Lacuna, so beating it means a statistically significant gain in human recovery on hard-distractor slots, at equal naturalness.

A frontier-LLM verbalizer prompts a large model to vocalize the whole sentence and spell out identifiers. The file reports GPT-4 10-shot at 33.66% WER and 10.91% PER on dialectal G2P in DialG2P. We include it because it may still do well on identifiers specifically.

On the metric side, the competitors to $R$ are three. The first is plain recognizer word error rate. The second is a normalized word error rate in the spirit of TajweedWER's Base WER, which strips diacritics, lowercases, and joins identifier pieces before comparison. The third is an audio-language-model judge asked the same closed-set question, as in LoopTTS.

Two ablations isolate the key ingredients. The first replaces the scope set with an open vocabulary, or with random rather than hard distractors; this tests whether scope constraint is what drives agreement with humans. The second removes type conditioning from our front end; this tests whether any synthesis gain comes from type information or merely from clitic segmentation.

Why not just…?

Why not just ask a frontier LLM to verbalize everything? The file's only direct evidence is unfavorable. GPT-4 had roughly six times DialG2P's word error on Egyptian phonemization (DialG2P), likely because its tokens hide the character-level units at stake. That result concerns dialect vowels, not identifiers. We therefore run the LLM verbalizer as a full baseline and report it on identifier slots separately.

Why not just mask identifiers, diacritize the Arabic, and read the names in English? This is the real threat to our synthesis claim. On standalone identifiers we expect it to match our front end. Our bet is that fused clitic forms are where it fails, because the clitic vowels depend on the stem's grammatical role. If human recovery on fused slots shows no gap, we drop the front-end claim. The paper then becomes a metric-and-benchmark paper with mask-and-reinsert as the recommended practice.

Why not just normalize word error rate, as TajweedWER did for Quranic text? Normalization works when a canonical written form exists. The spoken identifier has several acceptable verbalizations, and the decisive failure is confusing near-twins, which normalization can make worse by collapsing case and plurals. The correlation experiment below compares normalized word error rate against $R$ directly; if it matches $R$, the simpler metric wins.

Why not just use an audio-language-model judge, as LoopTTS does? It may work, and we test it on the same closed-set question. Its drawbacks are cost and latency, which LoopTTS itself acknowledges. It has also been shown only on English. If it agrees with humans as well as $R$ does, we report that the cheap forced-alignment listener is an adequate substitute, rather than claiming superiority.

Decisive Checks

The central experiment computes slot-level and system-level correlation with human recovery for plain word error rate, normalized word error rate, the audio-language-model judge, and $R$. It spans all synthesizer and front-end combinations plus the human-read reference. Bootstrap confidence intervals are taken over listeners and utterances. The metric claim holds only if $R$'s correlation interval lies above that of normalized word error rate, and only if the hard-distractor ablation shows the advantage comes from scope constraint.

The second check looks for rank reversals: pairs of systems that word error rate orders one way and humans order the other. We count how many of these $R$ resolves correctly, broken down by standalone versus clitic-fused identifiers.

The third check compares our front end against mask-and-reinsert on fused slots, with and without type conditioning. To avoid tuning to the test, the acoustic model inside $R$ is never used to select or train any front end. The final metric numbers are computed on a held-out split of repositories and listeners.