Short summary
extractPlainText() iterates $display->getComponents() assuming it returns fields in weight order (per the inline comment), but EntityDisplayBase::getComponents() simply returns the raw $content array as stored in config — it is never sorted by weight. The weight ordering seen in normal entity rendering only happens because EntityViewBuilder::buildMultiple() stamps #weight onto each field's render array and Drupal's render system sorts children by #weight at render time. Since TextExtractor calls viewField() directly per component instead of going through the full render pipeline, the extracted TTS text is joined in arbitrary config-array order rather than the order configured in Manage Display, so the generated audio doesn't follow the field order editors expect.
Steps to reproduce:
1. Configure a content type's tts view mode in Manage Display with several fields, setting explicit non-default weights (e.g. body before field_summary).
2. Generate TTS audio for a node of that type.
3. Observe the audio narrates fields out of the configured order.
Proposed fix: sort $display->getComponents() by weight (e.g. uasort()) before iterating in extractPlainText().
Issue fork ai_audio_generator-3613637
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
nnevill