Repository navigation
fix(kokoro): refuse unreadable and unspeakable text per item - #1156
Draft
ShaiShmuel wants to merge 1 commit into
Draft
ShaiShmuel wants to merge 1 commit into
ShaiShmuel wants to merge 1 commit into
Conversation
A number too long for the number reader (more than about 300 digits in a row) raised OverflowError from num2words inside the G2P, which failed the whole extract call and every other item in it. Text the English G2P drops entirely (only other scripts, emoji or punctuation) returned success with empty or near-silent audio. Both now fail on their own with INVALID_INPUT and a short message, like an item with no text, while the rest of the batch is synthesized. ValueError and ArithmeticError raised by the G2P on the text become item errors; other failures (torch runtime and device errors, MemoryError, programming errors) still propagate. Text that is partly speakable is read as before, and the speech route returns a 400 on `input` for these items.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Before
Two kinds of text that Kokoro-82M cannot speak were not reported as item errors:
num2words, which raisesOverflowErrorfor a number of more than about 300 digits in a row. The error escaped the adapter, so the whole extract call failed with a 500 (INFERENCE_ERROR, "internal error during extraction"), including every other item in the batch.POST /v1/audio/speechreturned a 500 as well.你好世界and😀🎉👍gave a 44-byte WAV with no samples,Привет, мир!and...!?well under a second of punctuation pauses.Now
Both fail on their own with
INVALID_INPUT, the code the adapter already uses for an item with no text, while the rest of the batch is synthesized:text has a number too long to read aloud; separate long runs of digits with spacestext has nothing to speak: it has no English words, numbers or symbols, only other scripts, emoji or punctuationValueErrororArithmeticErrorraised by the G2P on the text (misaki,num2words, spaCy) intoUnreadableTextError, and the adapter reports it for that item only. Other errors, such as torch runtime and device errors,MemoryErroror programming errors, still propagate and fail the call as before.Hello 😀 world,Hello 你好 world) is read as before.INPUT_TOO_LONGrefusals.POST /v1/audio/speechalready maps an item error to a 400invalid_request_error; these messages name no option, soparamisinput. No route change was needed; a server route test covers the two messages.Behaviour change: text made only of punctuation (for example
...!?) used to return a short WAV of pauses and is now refused with the sameINVALID_INPUTerror. No existing test covered it.Testing
OverflowError,ValueErrorandArithmeticErrorfrom the G2P and the prefetch pass toUnreadableTextErrorand letsRuntimeError,torch.OutOfMemoryError,MemoryErrorandTypeErrorthrough unchanged; the speech route returns a 400 oninputfor both messages.pytest packages/sie_server/tests/adapters/test_kokoro*.py packages/sie_server/tests/api: 2994 passed.ruff checkandruff format --checkon the changed files pass.sie-server, before and after:The quick brown fox jumps over the lazy dog.1× 1000server_error; extract: whole call 500param: input, number message; extract: that itemINVALID_INPUT你好世界,今天天气很好。param: input, nothing-to-speak message😀🎉👍param: input, nothing-to-speak message...!?param: input, nothing-to-speak messageHello 😀 world[1 × 1000, sentence, 😀🎉👍]INVALID_INPUT, item 2 audioThe gateway's
/v1/audio/speechhandler already turns any item error into a 400 oninputunless the message names a sent option; it was not run for this change.