Skip to content

Fix random voice/engine selection off-by-one and global RNG seeding#4

Open
phyceClaw wants to merge 1 commit into
phyce:mainfrom
phyceClaw:fix/voice-selection-rng
Open

Fix random voice/engine selection off-by-one and global RNG seeding#4
phyceClaw wants to merge 1 commit into
phyce:mainfrom
phyceClaw:fix/voice-selection-rng

Conversation

@phyceClaw

Copy link
Copy Markdown

Summary

In app/tts/profile/calculate.go:

  • Random selection used rand.Intn(len(x)-1), which never picks the last element and panics when len == 1. Now uses rand.Intn(len(x)).
  • setRandSeed called the global rand.Seed per call, racing under concurrent voice allocation. Replaced with a local *rand.Rand.

Testing

CGO_ENABLED=1 go build ./... passes; go vet clean.

🤖 Generated with Claude Code

rand.Intn(len-1) never selected the last element (and would panic
for len 1); use rand.Intn(len). Replace per-call global rand.Seed
with a local *rand.Rand to avoid races and global state mutation
during concurrent voice allocation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant