Text To Speech Issue [auto play] #6451

Closed
opened 2026-02-21 18:15:48 -05:00 by yindo · 5 comments
Owner

Originally created by @asrguru20 on GitHub (Oct 30, 2024).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.10.2

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

enable the TTS with auto play enabled feature in a agent chat bot

✔️ Expected Behavior

When You ask the chat bot which has TTS feature enabled with auto play it should automatically start to play the audio smoothly

Actual Behavior

while generating text in chat bot it starts to generate audio of that text simultaneously most of the case it has at least one delay or lag but mostly two lags at the beginning of the audio

Originally created by @asrguru20 on GitHub (Oct 30, 2024). ### Self Checks - [X] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.10.2 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce enable the TTS with auto play enabled feature in a agent chat bot ### ✔️ Expected Behavior When You ask the chat bot which has TTS feature enabled with auto play it should automatically start to play the audio smoothly ### ❌ Actual Behavior while generating text in chat bot it starts to generate audio of that text simultaneously most of the case it has at least one delay or lag but mostly two lags at the beginning of the audio
yindo added the 🐞 bugstt & tts labels 2026-02-21 18:15:48 -05:00
yindo closed this issue 2026-02-21 18:15:48 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Oct 30, 2024):

I found a similar issue related to audio lag when using the Text To Speech feature with auto play enabled in a self-hosted Dify version 0.10.2 chat bot. To resolve this, you can adjust the TTS_AUTO_PLAY_TIMEOUT and TTS_AUTO_PLAY_YIELD_CPU_TIME settings in the api/constants/tts_auto_play_timeout.py file.

The current settings are:

TTS_AUTO_PLAY_TIMEOUT = 5
TTS_AUTO_PLAY_YIELD_CPU_TIME = 0.02

Consider reducing the TTS_AUTO_PLAY_TIMEOUT value to decrease the delay before the audio starts playing. Additionally, you might want to experiment with the TTS_AUTO_PLAY_YIELD_CPU_TIME to optimize CPU yield time for smoother playback. Adjust these values incrementally and test the performance to find the optimal configuration for your setup [1].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Oct 30, 2024): <!-- Answer --> I found a similar issue related to audio lag when using the Text To Speech feature with auto play enabled in a self-hosted Dify version 0.10.2 chat bot. To resolve this, you can adjust the `TTS_AUTO_PLAY_TIMEOUT` and `TTS_AUTO_PLAY_YIELD_CPU_TIME` settings in the `api/constants/tts_auto_play_timeout.py` file. The current settings are: ```python TTS_AUTO_PLAY_TIMEOUT = 5 TTS_AUTO_PLAY_YIELD_CPU_TIME = 0.02 ``` Consider reducing the `TTS_AUTO_PLAY_TIMEOUT` value to decrease the delay before the audio starts playing. Additionally, you might want to experiment with the `TTS_AUTO_PLAY_YIELD_CPU_TIME` to optimize CPU yield time for smoother playback. Adjust these values incrementally and test the performance to find the optimal configuration for your setup <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/constants/tts_auto_play_timeout.py)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@asrguru20 commented on GitHub (Oct 30, 2024):

what is suggested values for those two variables ? should I increase the TTS_AUTO_PLAY_TIMEOUT and TTS_AUTO_PLAY_YIELD_CPU_TIME ?

@asrguru20 commented on GitHub (Oct 30, 2024): what is suggested values for those two variables ? should I increase the TTS_AUTO_PLAY_TIMEOUT and TTS_AUTO_PLAY_YIELD_CPU_TIME ?
Author
Owner

@dosubot[bot] commented on GitHub (Oct 30, 2024):

The suggested values for the variables are:

  • TTS_AUTO_PLAY_TIMEOUT: 5
  • TTS_AUTO_PLAY_YIELD_CPU_TIME: 0.02

There is no specific information provided on whether you should increase them. It might be beneficial to experiment with these values to see how they affect performance in your specific environment. Adjust them incrementally and test the results to find the optimal configuration for your setup [1].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Oct 30, 2024): <!-- Answer --> The suggested values for the variables are: - `TTS_AUTO_PLAY_TIMEOUT`: 5 - `TTS_AUTO_PLAY_YIELD_CPU_TIME`: 0.02 There is no specific information provided on whether you should increase them. It might be beneficial to experiment with these values to see how they affect performance in your specific environment. Adjust them incrementally and test the results to find the optimal configuration for your setup <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/constants/tts_auto_play_timeout.py)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@asrguru20 commented on GitHub (Oct 30, 2024):

is the TTS_AUTO_PLAY_TIMEOUT for delay time before auto play TTS ?

@asrguru20 commented on GitHub (Oct 30, 2024): is the TTS_AUTO_PLAY_TIMEOUT for delay time before auto play TTS ?
Author
Owner

@dosubot[bot] commented on GitHub (Dec 1, 2024):

Hi, @asrguru20. I'm Dosu, and I'm helping the Dify team manage their backlog. I'm marking this issue as stale.

Issue Summary

  • The issue involves a delay in the Text To Speech (TTS) feature with auto play enabled in Dify version 0.10.2.
  • I suggested adjusting TTS_AUTO_PLAY_TIMEOUT and TTS_AUTO_PLAY_YIELD_CPU_TIME settings to resolve the issue.
  • You inquired about the suggested values and were advised to experiment with the current values of 5 and 0.02.
  • Clarification was sought on the purpose of the TTS_AUTO_PLAY_TIMEOUT setting.

Next Steps

  • Please confirm if this issue is still relevant to the latest version of the Dify repository by commenting on this issue.
  • If there is no further activity, this issue will be automatically closed in 15 days.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Dec 1, 2024): Hi, @asrguru20. I'm [Dosu](https://dosu.dev), and I'm helping the Dify team manage their backlog. I'm marking this issue as stale. **Issue Summary** - The issue involves a delay in the Text To Speech (TTS) feature with auto play enabled in Dify version 0.10.2. - I suggested adjusting `TTS_AUTO_PLAY_TIMEOUT` and `TTS_AUTO_PLAY_YIELD_CPU_TIME` settings to resolve the issue. - You inquired about the suggested values and were advised to experiment with the current values of 5 and 0.02. - Clarification was sought on the purpose of the `TTS_AUTO_PLAY_TIMEOUT` setting. **Next Steps** - Please confirm if this issue is still relevant to the latest version of the Dify repository by commenting on this issue. - If there is no further activity, this issue will be automatically closed in 15 days. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#6451