fix: correct type-check order in _generate() to prevent AttributeError on non-string input
The previous guard `not text.strip() or not isinstance(text, str)` called .strip() before verifying that text is actually a string, causing an AttributeError (e.g. for int input) instead of the intended ValueError. Swap operand order so isinstance check short-circuits first. Closes #228
This commit is contained in:
+1
-1
@@ -200,7 +200,7 @@ class VoxCPM:
|
|||||||
Yields audio chunks for each generation step if ``streaming=True``,
|
Yields audio chunks for each generation step if ``streaming=True``,
|
||||||
otherwise yields a single array containing the final audio.
|
otherwise yields a single array containing the final audio.
|
||||||
"""
|
"""
|
||||||
if not text.strip() or not isinstance(text, str):
|
if not isinstance(text, str) or not text.strip():
|
||||||
raise ValueError("target text must be a non-empty string")
|
raise ValueError("target text must be a non-empty string")
|
||||||
|
|
||||||
if prompt_wav_path is not None:
|
if prompt_wav_path is not None:
|
||||||
|
|||||||
Reference in New Issue
Block a user