fix: resolve voice ID detection and flag handling bugs #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fix an issue preventing voice IDs without integers from being recognized, plus two minor flag validation fixes.
Bug Fixes
1. Voice ID detection without digits
Problem: Voice IDs containing only letters were not recognized as IDs because the detection logic required at least one digit. This caused such IDs to be treated as voice names, triggering an unnecessary API call and falling back to the first available voice instead of using the specified ID.
Solution: Changed detection logic to identify voice IDs by:
This correctly identifies voice IDs regardless of their character composition.
2. Flag default value inconsistency
Problem: The
--voiceflag used a variable reference (opts.voiceID) as its default value instead of an empty string literal. This could cause issues with cobra's flag parsing when both--voice-idand--voiceflags point to the same variable.Solution: Changed to use
""for consistency with the--voice-idflag.3. Speed vs rate validation order
Problem:
--speedvalidation happened before--rateprocessing, causing false validation errors when both flags were provided. For example,--speed 0.3 --rate 200would fail validation even though--rate 200(which maps to speed 1.14) is valid and would override the invalid--speedvalue.Solution: Process and validate
--ratefirst if provided, and only validate--speedif--ratewas not provided. This matches the intended behavior where--rateoverrides--speed.