Skip to content

Commit fbfd8aa

Browse files
authored
processing empty text like "\r \r" (#49)
1 parent 18fa93f commit fbfd8aa

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

KokoroSharp/HighLevel/KokoroTTS.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ void EnqueueWithCallbacks(float[] samples, string text, List<int[]> allTokens, K
103103
handle.OnInferenceStepCompleted?.Invoke(step, playbackHandle); // Notify end users that the step is complete, and pass the handle.
104104

105105
// Finally, if the segment is gracefully ended with a punctuation token, add some pause to it, to emulate natural pause.
106-
bool shouldAddPause = NicifyAudio && pipelineConfig != null && Tokenizer.PunctuationTokens.Contains(step.Tokens[^1]);
106+
bool shouldAddPause = NicifyAudio && pipelineConfig != null && step.Tokens.Any() && Tokenizer.PunctuationTokens.Contains(step.Tokens[^1]);
107107
if (shouldAddPause) {
108108
var secondsToWait = pipelineConfig.SecondsOfPauseBetweenProperSegments[Tokenizer.TokenToChar[step.Tokens[^1]]];
109109
var pauseHandle = playbackInstance.Enqueue(new float[(int) (secondsToWait * KokoroPlayback.waveFormat.SampleRate)], null, null, null);

0 commit comments

Comments
 (0)