Speech-to-Speech Translation › Analysis: Latency, Speaker, and Prosody
Language AI HandbookAll chapters These analyses cover different aspects of the cascade. Latency asks how long a request waits. Timbre and pitch ask what the audio output preserves or changes. A match on the recovered words leaves these other questions open.
Latency Breakdown
To reason about full-utterance latency, add the sequential stage times. The bars below use an illustrative timing budget. Timing the tiny tone functions would describe this code and machine rather than a realistic S2ST system.
PythonIn [25]Expand
stage_ms = {"ASR": 120, "MT": 80, "TTS": 180}
total_latency_ms = sum(stage_ms.values())
rtf = (total_latency_ms / 1_000) / (source_audio.size / source_rate)ConsoleOut [26]Expand
Sequential processing budget: 380 ms Processing time / source duration: 0.38×
VisualizationOut [27]Expand

A streaming system can overlap the stages as soon as partial results are stable enough to use. User-facing delay then also depends on buffering, commitment policy, and time to the first playable audio. A sequential processing sum cannot answer those questions.
Speaker Similarity Measurement
For real speech, compare embeddings from a speaker encoder validated for the languages and channels in use. Simple acoustic features also respond to content and recording conditions. In the tone fixture, we can measure a simpler feature with a known meaning: the relative amplitude of the first three harmonics in the first segment. Resample both signals to a shared analysis rate using each signal's own original rate.
PythonIn [28]Expand
def harmonic_profile(waveform, original_rate, analysis_rate):
audio = resample_waveform(waveform, original_rate, analysis_rate)
frequencies, spectrum = frame_spectra(audio, analysis_rate)
first_frame = spectrum[0]
fundamental = frequencies[first_frame.argmax()]
harmonics = fundamental * np.arange(1, 4)
return np.interp(harmonics, frequencies, first_frame) / first_frame.max()
source_profile = harmonic_profile(source_audio, source_rate, recognizer_rate)
target_profile = harmonic_profile(target_speech, target_rate, recognizer_rate)
profile_cosine = np.dot(source_profile, target_profile) / (
np.linalg.norm(source_profile) * np.linalg.norm(target_profile)
)ConsoleOut [29]Expand
Source harmonics: [1. 0.35 0.12] Target harmonics: [1. 0.1 0.42] Tone profile cosine: 0.934
The source and target profiles differ because synthesis used a new set of harmonic weights. They can still have a high cosine because the fundamental is the largest component of both profiles. This calculation describes synthetic timbre. A speaker-identity comparison requires a speaker encoder and a separate validation protocol.
Prosody Similarity
Use the dominant frequency in each quarter-second segment as the fundamental of our test signal. Compute it using the correct rate for each signal and plot the result against elapsed time. Real speech has variable voicing, duration, and spectral structure, which calls for a pitch tracker and an alignment procedure when comparing across languages.
PythonIn [30]Expand
source_hz, source_spectrum = frame_spectra(source_audio, source_rate)
target_hz, target_spectrum = frame_spectra(target_speech, target_rate)
f0_src = source_hz[source_spectrum.argmax(axis=1)]
f0_tgt = target_hz[target_spectrum.argmax(axis=1)]
segment_centers = (np.arange(len(f0_src)) + 0.5) * word_secondsVisualizationOut [31]Expand

ConsoleOut [32]Expand
Source mean fundamental: 144.0 Hz Target mean fundamental: 214.0 Hz
The target fundamental frequencies come from the German tone inventory. In this fixture the transcript IDs also identify the original English fundamentals, because each ID has one fixed source frequency. The synthesis stage uses the target inventory and its own harmonic weights. It receives neither the original waveform nor the source harmonic weights.
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!