Kokoro-FastAPI icon indicating copy to clipboard operation
Kokoro-FastAPI copied to clipboard

Static Pop at the End of Sentences / Streaming Chunks

Open User873902 opened this issue 6 months ago • 3 comments

Recent update v0.3.0 appears to have introduced a harsh static pop at the end of sentences generated via the API. Rolling back to v0.2.4-master reverted the bug.

Branch: Stable Deployment: Local, docker compose (cpu) OS: Linux

Compose:

  wyoming_openai:
    image: ghcr.io/roryeckel/wyoming_openai:latest
    container_name: wyoming_openai
    ports:
      - "10300:10300"
    restart: unless-stopped
    environment:
      TTS_SPEED: 1.2
      TTS_OPENAI_URL: http://kokoro-fastapi-cpu:8880/v1
      TTS_MODELS: "kokoro"
      TTS_STREAMING_MODELS: "kokoro"
      TTS_BACKEND: "KOKORO_FASTAPI"
      TTS_VOICES: "af_bella(3)+af_nicole(1)"
      TTS_STREAMING_MIN_WORDS: "6"
      TTS_STREAMING_MAX_CHARS: "220"

  kokoro-fastapi-cpu:
    container_name: kokoro-fastapi-cpu
    restart: unless-stopped
    ports:
      - 8880:8880
    image: ghcr.io/remsky/kokoro-fastapi-cpu:v0.2.4-master

Logs:

12:53:10 PM | INFO     | text_processor:151 | Starting smart split for 164 chars
12:53:10 PM | DEBUG    | text_processor:156 | Split raw text into 1 parts by pause tags.
12:53:10 PM | DEBUG    | text_processor:65 | Total processing took 0.51ms for chunk: 'On the other hand, the government is blaming the o...'
12:53:10 PM | INFO     | text_processor:299 | Yielding final chunk 1 for part: 'On the other hand, the government is blaming the o...' (162 tokens)
12:53:10 PM | DEBUG    | kokoro_v1:44 | Cached voice tensor from /tmp/af_bella(3)+af_nicole(1).pt
12:53:10 PM | DEBUG    | kokoro_v1:44 | Cached voice tensor from /tmp/af_bella(3)+af_nicole(1).pt
12:53:10 PM | DEBUG    | kokoro_v1:277 | Generating audio for text with lang_code 'a': 'Well, one of the biggest developments is that supporters of former president Evo Morales have joined...'
12:53:11 PM | DEBUG    | kokoro_v1:284 | Got audio chunk with shape: torch.Size([328800])
12:53:11 PM | DEBUG    | kokoro_v1:277 | Generating audio for text with lang_code 'a': 'On the other hand, the government is blaming the opposition and Morales' allies for the blockades, w...'
12:53:11 PM | DEBUG    | kokoro_v1:284 | Got audio chunk with shape: torch.Size([221400])
12:53:11 PM | INFO     | text_processor:323 | Split completed in 1881.56ms, produced 1 chunks (including pauses)
12:53:11 PM | DEBUG    | streaming_audio_writer:87 | Closed container, final page/trailer written.
12:53:11 PM | INFO     | text_processor:323 | Split completed in 1870.98ms, produced 1 chunks (including pauses)
12:53:11 PM | DEBUG    | streaming_audio_writer:87 | Closed container, final page/trailer written.

Logs:

INFO:__main__:Starting Wyoming OpenAI 0.4.4
WARNING:__main__:No ASR models specified
INFO:__main__:*** Streaming TTS Voices ***
TTS Voice Model:
  Name: af_bella(3)+af_nicole(1)
  Description: af_bella(3)+af_nicole(1)
  Model Name: kokoro
  Attribution: OpenAI-Compatible Wyoming Proxy - http://kokoro-fastapi-cpu:8880/v1
  Installed: Yes
  Languages: en
  Version: None
INFO:__main__:No Non-Streaming TTS voices specified
INFO:__main__:Starting server at tcp://0.0.0.0:10300
...
INFO:wyoming_openai.handler:Detected 1 ready sentences for immediate synthesis: ['Well, one of the biggest devel...']
INFO:wyoming_openai.handler:Processing final remaining text: 'On the other hand, the government is blaming the opposition and Morales' allies for the blockades, w...'
INFO:wyoming_openai.handler:Starting concurrent synthesis for 2 chunks
INFO:httpx:HTTP Request: POST http://kokoro-fastapi-cpu:8880/v1/audio/speech "HTTP/1.1 200 OK"
INFO:httpx:HTTP Request: POST http://kokoro-fastapi-cpu:8880/v1/audio/speech "HTTP/1.1 200 OK"
INFO:wyoming_openai.handler:Successfully completed concurrent streaming synthesis: Well, one of the biggest developments is that supporters of former president Evo Morales have joined...

User873902 avatar May 20 '26 21:05 User873902

Hey @User873902, are you able to share details on format/parameters/streaming etc during the generation? Will try to repro and determine the cause; not hearing on my end on sample e.g

stream.mp3 oneshot.wav

remsky avatar May 20 '26 23:05 remsky

My apologizes. I added the applicable docker compose yaml. I"m unsure if it is mp3. When I was using v0.3.0, I did not find the errors when generating speech with the FastKoko webpage, but rather when the speech was generated with home assistant tts.speak. I wonder/think the static pop is at the end of a streaming chunk rather than every sentence end?

User873902 avatar May 21 '26 12:05 User873902

My apologizes. I added the applicable docker compose yaml. I"m unsure if it is mp3. When I was using v0.3.0, I did not find the errors when generating speech with the FastKoko webpage, but rather when the speech was generated with home assistant tts.speak. I wonder/think the static pop is at the end of a streaming chunk rather than every sentence end?

I'm having this issue with my HA TTS as well, the output files don't seem to have the static pop, however when using HA TTS there's a pop

NikhilAlapati avatar May 24 '26 01:05 NikhilAlapati