Unit Selection Synthesis: Finding the Lowest-Cost Sequence of Speech Units
See how unit selection scores target matches and joins, why local greedy choices can lose to a globally better sequence, how Viterbi dynamic programming accumulates costs, and what pruning trades away.
Unit Selection Synthesis: Finding the Lowest-Cost Sequence of Speech Units
Unit selection synthesis chooses a recorded candidate for each target phone in an utterance, then finds the candidate sequence with the lowest total cost. It scores both how well each candidate matches its target and how naturally neighboring candidates join. That is why dynamic programming over the whole sequence is useful: independently choosing the best-scoring candidate at each position can miss a better global path.
Candidate lattice and costs
Text normalization and pronunciation prediction produce a target phone sequence, often annotated with prosodic goals such as pitch, duration, and power. Matching database candidates of the required phone identity are placed at each target position. Possible joins between candidates in neighboring positions form edges; the layers and edges make a search lattice (trellis).
**Target cost T(tᵢ,uᵢ):** estimates how different target tᵢ is from recorded candidate uᵢ. Features can include phone identity, surrounding phonetic context, pitch, duration, and power.
**Join cost J(uᵢ₋₁,uᵢ):** estimates discontinuity at the boundary of adjacent candidates. Spectral or cepstral, energy, and pitch differences may be features.
A path’s total cost sums target costs for its candidates and join costs for each adjacent pair. Systems may also include costs at the initial and final silence boundaries. The score is an objective function designed or trained to approximate naturalness; it is not a direct measurement of what listeners prefer.
Why not pick the lowest local score?
The following illustrative toy example shows the calculation; its numbers are invented and are not speech-quality measurements. Suppose the target sequence is A→B→C and the first candidate A has cost 0.
| Position | Candidate | Target cost |
|---|---|---|
| B | B1 | 0 |
| B | B2 | 2 |
| C | C1 | 1 |
| C | C2 | 0 |
Set join costs to A→B1=8, A→B2=0, B1→C1=0, B1→C2=6, B2→C1=4, and B2→C2=0. Choosing by target cost alone gives B1 and C2, but path A→B1→C2 costs 0+0+0+8+6=14. B2 is two points worse as a target match, yet its joins are smoother: A→B2→C2 costs 0+2+0+0+0=2. Here the less target-like candidate yields the much lower total.
That is the point of global selection: a candidate’s local rank does not determine the final choice. The cost accumulated so far and the next join both matter.
How Viterbi accumulates cost
Let Dᵢ(v) be the lowest cumulative cost for reaching candidate v at target position i. For a one-dimensional phone sequence:
Dᵢ(v) = T(tᵢ,v) + minᵤ [ Dᵢ₋₁(u) + J(u,v) ]For each previous candidate u, add the best cost up to u to the cost of joining u to v. Keep the minimum, then add v’s target cost. Store a backpointer to the minimizing previous candidate; at the last position, follow these pointers backward to recover the selected sequence. Start and end silence costs can be added in the first and final steps.
Hunt and Black’s CHATR paper models database units as states and joins as transitions, with target cost as state cost and join cost as transition cost, then applies Viterbi search. Keeping every database unit makes the candidate and join space large, so the paper describes pruning in stages: first find candidates with similar phonetic contexts, then prune by target cost and join cost. Exact search order and limits vary by implementation.
Weighting and pruning trade-offs
Both costs can be weighted sums of subfeatures. Target cost may include context mismatch, duration, or pitch; join cost may use cepstral, energy, and pitch differences at the boundary. Changing weights can change the selected path.
If target cost dominates, individual units may fit well but the joins can click or sound discontinuous. If join cost dominates, the boundary may be smooth while the prosody or duration is wrong. A system should preserve phone identity as a hard constraint or strong penalty; otherwise, a poorly designed phone constraint can admit the wrong unit.
Pruning candidates speeds search but may remove a unit needed for the best path. The Aalto speech-processing text describes removing high-target-cost candidates or keeping only top candidates at each stage with beam search. A narrower beam can be faster but leaves fewer options for later joins. Compare quality and speed together.
Festival’s cluster-unit-selection documentation describes another acceleration strategy: precompute candidate clusters in CART trees instead of calculating every target cost at synthesis time, then still search for the best overall path through the candidate groups. Candidate generation may differ, while the broader steps remain: build the candidate set, score candidate sequences, and choose a join path.
Debugging an awkward result
Use the same sentence and database conditions while checking:
Confirm the candidate phone labels match the target identity and that context/prosody features reflect the actual target.
Inspect top candidates at each position; check whether target-cost pruning removed candidates needed for a smooth join.
Print target and boundary costs separately for the chosen path to find which terms drive the total up.
Compare source fragments and boundary spectra or cepstra, energy, and pitch. A join score alone does not determine perceived quality; listen to the waveform.
Compare several weight settings on the same sentences. An improvement on one sentence may not generalize.
Widen the beam or relax pruning and see whether the path changes. If it does, the speed optimization may affect the output.
Unit selection finds the minimum-cost path under a given inventory, features, costs, and pruning strategy. A lower cost does not guarantee speech that listeners find more natural. Cost definitions and weights need evaluation against held-out natural utterances and listening judgments; a search algorithm cannot repair missing data or incorrect labels by itself.
References
[Hunt & Black (1996), Unit selection in a concatenative speech synthesis system using a large speech database](https://www.ee.columbia.edu/~dpwe/e6820/papers/HuntB96-speechsynth.pdf)
[Aalto University, Introduction to Speech Processing: Concatenative speech synthesis](https://speechprocessingbook.aalto.fi/synthesis/concatenative-speech-synthesis/)
[Black & Lenzo, Building Voices in the Festival Speech Synthesis System: Unit selection databases](https://www.cs.cmu.edu/afs/cs/user/lenzo/html/areas/papers/festvox/festvox_6.html)