Skip to content

Chunking of long strings for TTS #379

Description

@tflatka

Which version of assistant are you using?

2.13.0

Which version of Nextcloud are you using?

32.0.11

Which browser are you using? In case you are using the phone App, specify the Android or iOS version and device please.

Chrome Version 148.0.7778.179

Describe the Bug

Text-to-Speech generation fails when the input text exceeds the maximum length accepted by the OpenAI TTS API.

Instead of reporting a TTS-related error, the integration returns a misleading message:

OpenAI/LocalAI's text to image generation failed

although the request is sent to the audio endpoint.

Additional information

PDF summarization using GPT-4.1-mini works correctly with large documents, so the issue appears specific to the TTS pipeline.

Expected Behavior

Expected result

The integration should automatically split long text into chunks smaller than the OpenAI TTS input limit.

  • Alternatively, the UI should prevent submission of oversized text.
  • Error messages should refer to Text-to-Speech instead of Text-to-Image.
  • The actual OpenAI validation error should be surfaced to the user.

To Reproduce

Steps to Reproduce

Configure OpenAI as AI provider.
Configure a TTS model (gpt-4o-mini-tts or tts-1).
Select a long document (e.g. PDF/manual).
Generate speech from the document.

Actual result

The job fails with:

RuntimeException
OpenAI/LocalAI's text to image generation failed with:
API request error:
[{
'type': 'string_too_long',
'loc': ('body', 'input'),
'msg': 'String should have at most 4096 characters',
'ctx': {'max_length': 4096}
}]

Other log entries also show:

Invalid URL (POST /v1/audio/speech)

and

OpenAI/LocalAI's text to image generation failed

even though the request is clearly related to Text-to-Speech.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions