-
-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Index out of bounds in _create_audio() #115
Labels
bug
Something isn't working
Comments
My workaround was to override class FixedKokoro(Kokoro):
# Workaround for https://github.com/thewh1teagle/kokoro-onnx/issues/115
def _split_phonemes(self, phonemes: str) -> list[str]:
batched_phonemes = []
while len(phonemes) > MAX_PHONEME_LENGTH:
# Find best split point within limit
split_idx = MAX_PHONEME_LENGTH
# Try to find the last period before MAX_PHONEME_LENGTH
period_idx = phonemes.rfind('.', 0, MAX_PHONEME_LENGTH)
if period_idx != -1:
split_idx = period_idx + 1 # Include period
else:
# Try other punctuation
match = re.search(r'[!?;,]', phonemes[:MAX_PHONEME_LENGTH][::-1]) # Search backwards
if match:
split_idx = MAX_PHONEME_LENGTH - match.start()
else:
# Try last space
space_idx = phonemes.rfind(' ', 0, MAX_PHONEME_LENGTH)
if space_idx != -1:
split_idx = space_idx
# If no good split point is found, force split at MAX_PHONEME_LENGTH
chunk = phonemes[:split_idx].strip()
batched_phonemes.append(chunk)
# Move to the next part
phonemes = phonemes[split_idx:].strip()
# Add remaining phonemes
if phonemes:
batched_phonemes.append(phonemes)
return batched_phonemes Happy to open a PR |
Although, I still get an exception if the input is exactly MAX_PHONEME_LENGTH long. Here is the updated _split_phonemes to reduce max_length by 1: class FixedKokoro(Kokoro):
# Workaround for https://github.com/thewh1teagle/kokoro-onnx/issues/115
def _split_phonemes(self, phonemes: str) -> list[str]:
max_length = MAX_PHONEME_LENGTH - 1
batched_phonemes = []
while len(phonemes) > max_length:
# Find best split point within limit
split_idx = max_length
# Try to find the last period before max_length
period_idx = phonemes.rfind('.', 0, max_length)
if period_idx != -1:
split_idx = period_idx + 1 # Include period
else:
# Try other punctuation
match = re.search(r'[!?;,]', phonemes[:max_length][::-1]) # Search backwards
if match:
split_idx = max_length - match.start()
else:
# Try last space
space_idx = phonemes.rfind(' ', 0, max_length)
if space_idx != -1:
split_idx = space_idx
# If no good split point is found, force split at max_length
chunk = phonemes[:split_idx].strip()
batched_phonemes.append(chunk)
# Move to the next part
phonemes = phonemes[split_idx:].strip()
# Add remaining phonemes
if phonemes:
batched_phonemes.append(phonemes)
return batched_phonemes |
Yes I got the same error ! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What happened?
Follow up on #95
I get an
IndexError: index 510 is out of bounds for axis 0 with size 510
error for any input text that contains a long-ish sentence.Steps to reproduce
Python script:
Run the script:
Thank you for the work on kokoro-onnx!
What OS are you seeing the problem on?
MacOS
Package version
0.4.2
Relevant log output
The text was updated successfully, but these errors were encountered: