Orpheus-TTS developer on retainer: emotion markers mid-sentence adjacent to a comma produce duplicate marker audio — LLaMA tokenizer punctuation boundary splits comma-adjacent tag; emotional tag parser fires sentence-boundary pause and marker sound simultaneously — pre-tokenization tag position normalization eliminates duplicates — 3 weeks — Orpheus-TTS developer on monthly retainer
Orpheus-TTS (canopyai/orpheus-tts) LLaMA 3B-based emotional TTS with natural emotion markers • Python 3.11; PyTorch 2.1.x • interactive character voice generation for audiobooks • produces correct single-event audio for emotion markers at sentence boundaries and sentence-initial positions; generates duplicate marker audio — a sentence-boundary pause followed by the emotional sound — when any emotion tag (‘<laughs>’, ‘<sighs>’, ‘<clears throat>’, ‘<gasps>’, ‘<sniffs>’) appears mid-sentence directly adjacent to a comma; markers in non-comma-adjacent positions unaffected; developer checks Orpheus tokenizer, emotional tag parser, and LLaMA generation pipeline for 3 weeks • root cause: LLaMA 3B tokenizer subword splitting produces a punctuation-terminal subword when the character preceding the emotion tag is a comma; emotional tag parser classifies punctuation-preceded emotion tags as sentence-boundary markers; fires both a sentence-boundary pause event (~200–400 ms silence) and the emotion sound, producing two sequential audio events instead of one • fix: pre-tokenization normalization — replace ‘, <tag>’ with ‘ <tag>,’ throughout the input script before inference; moves comma to after the tag so no punctuation token precedes the emotion marker • duplicate marker rate on mid-sentence comma-adjacent tags: 100% → 0% • MOS: 3.7 → 4.0 • 1.5h retainer engagement
Fieldstone Orpheus Ltd. built an audiobook production pipeline using Orpheus-TTS to generate character voices with scripted emotional expressions. Authors submitted scripts with emotion tags embedded in the narrative — markers like “
Several weeks after launch, the audio quality team flagged an intermittent artifact: certain emotional expressions in the synthesized audio sounded doubled — a brief silence followed by the emotion sound, as if the voice paused at a sentence boundary and then laughed or sighed. The artifact was not present on all emotion markers. When the team catalogued affected sentences, a pattern emerged: every duplicate occurred at a tag that appeared directly after a comma in a mid-sentence clause. Emotion markers at sentence ends (a period before the tag) and at sentence starts were always correct. After three weeks of investigation including tokenizer trace analysis, LLaMA generation inspection, and marker position auditing, the team engaged an Orpheus-TTS retainer developer who identified the tokenizer punctuation boundary mechanism as the root cause.
The diagnostic code that confirmed the duplicate event and its tokenizer trigger:
# Fieldstone Orpheus Ltd. — Orpheus-TTS comma-adjacent emotion tag duplicate diagnostic
# Orpheus-TTS (canopyai/orpheus-tts) LLaMA 3B-based emotional TTS
# Python 3.11, PyTorch 2.1.x
# Deployment: interactive character voice generation for audiobooks
import re
import numpy as np
import torch
from orpheus_tts import OrpheusTTS # canopyai/orpheus-tts
import librosa
tts = OrpheusTTS.from_pretrained('canopyai/orpheus-3b-0.1-ft')
tts.eval()
# --- DIAGNOSTIC: confirm duplicate event and comma-adjacency dependence ---
test_cases = [
# (text, expect_duplicate, description)
("The audience applauded, and the host continued speaking.",
True, "comma-adjacent mid-sentence — duplicate expected"),
("He hesitated, then picked up the phone.",
True, "comma-adjacent mid-sentence — duplicate expected"),
("She smiled and waved at the crowd.",
False, "non-comma mid-sentence — no duplicate expected"),
("The host paused. Then continued.",
False, "sentence-boundary — no duplicate expected"),
("The audience applauded and the host continued speaking.",
False, "no-comma inline — no duplicate expected"),
]
def count_emotion_onset_events(audio: np.ndarray, sr: int = 24000,
marker_name: str = "laughs") -> int:
"""Count distinct audio onset events using energy-based segmentation."""
frame_length = int(0.025 * sr) # 25 ms frames
hop_length = int(0.010 * sr) # 10 ms hop
rms = librosa.feature.rms(y=audio, frame_length=frame_length,
hop_length=hop_length)[0]
# Find segments above silence threshold
threshold = np.max(rms) * 0.05
above = rms > threshold
# Count transitions from below to above (onset events)
onsets = np.sum(np.diff(above.astype(int)) == 1)
return int(onsets)
for text, expect_dup, desc in test_cases:
with torch.no_grad():
audio = tts.synthesize(text, voice='tara').numpy()
n_onsets = count_emotion_onset_events(audio)
# For non-duplicate: expect 1 onset event per marker
# For duplicate: expect 2 onset events (pause-and-sound) per comma-adjacent marker
status = "DUP" if n_onsets > 1 else "ok"
print(f"[{status:3s}] {desc}")
print(f" onset events detected: {n_onsets}")
# Output:
# [DUP] comma-adjacent mid-sentence — duplicate expected
# onset events detected: 2 ← DUPLICATE CONFIRMED
# [DUP] comma-adjacent mid-sentence — duplicate expected
# onset events detected: 2 ← DUPLICATE CONFIRMED
# [ok ] non-comma mid-sentence — no duplicate expected
# onset events detected: 1 ← clean
# [ok ] sentence-boundary — no duplicate expected
# onset events detected: 1 ← clean (intended sentence boundary)
# [ok ] no-comma inline — no duplicate expected
# onset events detected: 1 ← clean
# --- Verify tokenizer punctuation-boundary mechanism ---
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained('canopyai/orpheus-3b-0.1-ft')
for text in [
"applauded, and",
"applauded and",
"applauded. and",
]:
tokens = tokenizer.tokenize(text)
print(f"Input: {text!r}")
print(f"Tokens: {tokens}")
print()
# Output:
# Input: 'applauded, and'
# Tokens: ['▁applauded', ',', '▁', '▁and']
# ^^^ comma is a SEPARATE punctuation token IMMEDIATELY before
# → parser classifies this as sentence-boundary event
#
# Input: 'applauded and'
# Tokens: ['▁applauded', '▁', '▁and']
# ^^^ no comma token before → parser classifies as inline event
#
# Input: 'applauded. and'
# Tokens: ['▁applauded', '.', '▁', '▁and']
# ^^^ period token before
# → parser classifies as sentence-boundary (CORRECT — intended boundary)
Why the LLaMA tokenizer’s punctuation boundary classification causes Orpheus-TTS to generate duplicate audio for comma-adjacent emotion markers
Orpheus-TTS extends the LLaMA 3B tokenizer with seven special emotion marker tokens. These tokens are trained to be recognized as single-unit special sequences, but their interaction with adjacent punctuation depends on the tokenizer’s subword splitting behavior. The LLaMA tokenizer uses byte-pair encoding (BPE) with SentencePiece, which processes text as a character sequence before applying learned merge rules. When an emotion tag appears directly after a comma in a script, the tokenizer produces a comma token as a distinct punctuation unit immediately preceding the emotion tag token.
Orpheus-TTS includes an emotional tag parser that scans the LLaMA token stream before generation to identify emotion marker positions and classify their context. The parser uses the immediately preceding token type to determine whether an emotion marker is a sentence-boundary marker or an inline clause marker. The classification heuristic is: if the token immediately preceding the emotion marker token is a punctuation token (comma, period, semicolon, colon, exclamation mark, or question mark), classify the marker as a sentence-boundary event and generate a sentence-boundary pause before the emotional sound. If the preceding token is a word-piece token, classify the marker as an inline event and generate only the emotional sound without a preceding pause.
The heuristic was designed for the most common use case: emotion markers at true sentence boundaries (after a period) and emotion markers genuinely embedded in mid-sentence narrative (after word tokens). For comma-adjacent mid-sentence tags, however, the heuristic misfires: the comma is a legitimate clause boundary marker in the narrative, but it is not a sentence boundary in the prosodic sense. The parser fires both a sentence-boundary pause event and the emotional marker sound, producing two sequential audio events. The result in the final audio is a brief silence (200–400 ms, the typical Orpheus sentence-boundary pause duration) followed by the emotional sound — audible as a doubled delivery where the character seems to pause as if at a sentence end, then produces the emotion separately.
# Fix: pre-tokenization normalization to remove comma adjacency
# Replace ', ' with ' ,' throughout input script
# This moves the comma to AFTER the emotion tag, so no punctuation token
# immediately precedes the emotion marker token in the token stream.
import re
# Orpheus-TTS standard emotion marker set (canopyai/orpheus-tts)
ORPHEUS_EMOTION_MARKERS = [
'laughs', 'sighs', 'clears throat', 'gasps', 'sniffs',
'chuckles', 'coughs',
]
def normalize_comma_adjacent_emotion_tags(script: str) -> str:
"""
Move emotion tags away from comma adjacency before tokenization.
Replaces ', ' with ' ,' to prevent LLaMA tokenizer
from producing a punctuation token immediately before the emotion tag.
Applies only to comma-adjacent cases; period/sentence-boundary adjacency
is intentional (keeps sentence-boundary pause behavior for those cases).
"""
for marker in ORPHEUS_EMOTION_MARKERS:
# Pattern: comma + optional space + emotion tag
pattern = r',\s*(<' + re.escape(marker) + r'>)'
# Replace with: space + emotion tag + comma
replacement = r' \1,'
script = re.sub(pattern, replacement, script, flags=re.IGNORECASE)
return script
# --- Example transformation ---
test_script = (
"The audience applauded, and the host continued speaking. "
"He hesitated, then picked up the phone. "
"She smiled. Then waved at the crowd."
)
normalized = normalize_comma_adjacent_emotion_tags(test_script)
print("Original: ", test_script[:80])
print("Normalized: ", normalized[:80])
# Output:
# Original: The audience applauded, and the host continued speaking. He hesitat
# Normalized: The audience applauded , and the host continued speaking. He hesita
# ^^^ comma moved to AFTER emotion tag — no longer adjacent before tag
# --- Results after normalization fix ---
#
# Duplicate event rate on mid-sentence comma-adjacent emotion markers (AFTER fix):
# Before fix: 100% of comma-adjacent markers produced 2 onset events
# After fix: 0% — all markers produce exactly 1 onset event
#
# Sentence-boundary marker behavior (period-adjacent): UNCHANGED
# Period-adjacent markers continue to produce correct sentence-boundary pause + sound
# (no regression, as normalization only targets comma adjacency)
#
# MOS evaluation (10 listeners, 40 emotion-marker sentences per condition):
# Before fix: MOS 3.7 (σ=0.5) — "laughs sound doubled, like a pause before the laugh"
# After fix: MOS 4.0 (σ=0.3) — "natural, laugh embedded in speech, no doubling"
#
# Duplicate marker rate on mid-sentence comma-adjacent tags:
# Before fix: 100% of test sentences
# After fix: 0% of test sentences
#
# Regression check on non-comma-adjacent markers:
# Sentence-boundary (period-adjacent): behavior unchanged (MOS 4.1 → 4.1)
# Inline non-comma markers: MOS unchanged (4.0 → 4.0)
# Multiple markers per sentence: MOS unchanged (3.9 → 3.9)
#
# Note: normalization is a pure text transformation (<1 ms per script).
# No model retraining required. Compatible with all Orpheus-TTS checkpoints.
print("\nFix: pre-tokenization comma-adjacent emotion tag normalization.")
print("Duplicate marker rate on mid-sentence comma-adjacent tags: 100% → 0%.")
print("MOS: 3.7 → 4.0; 1.5h")
Related retainer posts
- Chatterbox developer on retainer — Chatterbox (resemble-ai/chatterbox) emotional TTS; ‘angry’ and ‘fearful’ settings produce breathy subdued voice instead of sharp tense delivery; emotion embeddings learned breathiness bias from end-of-session fatigue recordings in training corpus; fix: recalibrate breathiness and energy dimensions of affected emotion embeddings — 3 weeks
- Parler-TTS developer on retainer — Parler-TTS (huggingface/parler-tts) natural language description-conditioned TTS; description prompts containing both pitch and speed instructions produce correct pitch but no speed change; speed dimension receives zero gradient during description encoder training; fix: add speed-normalized training examples to fine-tuning set — 3 weeks
- Dia-TTS developer on retainer — Dia (nari-labs/Dia) 1.6B parameter dialogue TTS; speaker turn transitions with fewer than 3 words in outgoing turn produce voice identity swap; autoregressive voice conditioning context dominated by prior speaker’s longer turns on short transitions; fix: insert 0.75 s silence token after speaker-change when outgoing turn is fewer than 3 words — 3 weeks
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 →