Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix autoplay when tts disabled #2089

Merged
merged 1 commit into from
Jan 23, 2025
Merged

Conversation

shaohuzhang1
Copy link
Contributor

fix: Fix autoplay when tts disabled --bug=1051950 --user=刘瑞斌 【应用】不关闭自动朗读,直接关闭语言合成模型,还是会自动朗读 https://www.tapd.cn/57709429/s/1650240

--bug=1051950 --user=刘瑞斌 【应用】不关闭自动朗读,直接关闭语言合成模型,还是会自动朗读 https://www.tapd.cn/57709429/s/1650240
Copy link

f2c-ci-robot bot commented Jan 23, 2025

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link

f2c-ci-robot bot commented Jan 23, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@@ -278,7 +278,7 @@ const pausePlayAnswerText = () => {

onMounted(() => {
// 第一次回答后自动播放, 打开历史记录不自动播放
if (props.tts_autoplay && buttonData.value.write_ed && !buttonData.value.update_time) {
if (props.tts && props.tts_autoplay && buttonData.value.write_ed && !buttonData.value.update_time) {
playAnswerText(buttonData.value.answer_text)
}
})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code snippet you provided checks if two conditions are met before playing an answer text using the playAnswerText function:

  1. The tts prop is truthy (true) and tts_autoplay is also true.
  2. write_ed value from buttonData should be a non-empty string, representing "write ed" functionality.

If both conditions are satisfied, it calls the playAnswerText method with the current answer text.

Here's a brief suggestion to improve readability and maintainability:

onMounted(() => {
  // Check if tts is enabled and auto-play is set to true,
  // also ensure write_ed has some content and no update_time exists.
  if (props.tts && props.tts_autoplay && buttonData.value.write_ed.trim() !== '') {
    playAnswerText(buttonData.value.answer_text);
  }
});

Changes made:

  • Wrapped buttonData.value.write_ed trimming in parentheses: (buttonData.value.write_ed.trim() !== ''). Parentheses can make the intent clearer, especially when dealing with conditional logic expressions.

This change enhances readability while keeping the same logic.

@liuruibin liuruibin merged commit 2732323 into main Jan 23, 2025
4 checks passed
@liuruibin liuruibin deleted the pr@main@fix_tts_autoplay branch January 23, 2025 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants