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: Text ignores special characters such as HTML tags #1912

Merged
merged 1 commit into from
Dec 25, 2024

Conversation

shaohuzhang1
Copy link
Contributor

fix: Text ignores special characters such as HTML tags --bug=1050847 --user=王孝刚 【应用】-文本转语音节点在接收到带有html标签或url的文本,生成的语音中没有忽略代码和url等信息 https://www.tapd.cn/57709429/s/1637065

--bug=1050847 --user=王孝刚 【应用】-文本转语音节点在接收到带有html标签或url的文本,生成的语音中没有忽略代码和url等信息 https://www.tapd.cn/57709429/s/1637065
Copy link

f2c-ci-robot bot commented Dec 25, 2024

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 Dec 25, 2024

[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

# 去除首尾空格
text = text.strip()
return 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 provided code includes several improvements and optimizations:

  1. Function Separation: A new function _remove_empty_lines has been added to handle splitting and transcribing files separately, which improves modularity.

  2. Markdown Conversion: The markdown_to_plain_text function uses Python's built-in re module to remove various Markdown elements such as images, links, headings, bold, italic, inline code, code blocks, unnecessary whitespace, HTML tags, and form renders. This greatly enhances the efficiency of text preprocessing for transcription tasks.

  3. Regex Optimization: The regex patterns have been updated for better performance, especially those targeting multiple replacement operations.

  4. Edge Case Handling: The code now handles edge cases such as tables rendered with <tbody>/<tr>/ by removing them using a regular expression (<tbody>[\s\S]*?</tbody>). Additionally, it ensures that the final text is stripped of leading and trailing spaces after processing.

Overall, these changes make the code more robust, efficient, and easier to maintain.

@wxg0103 wxg0103 merged commit bb58ac6 into main Dec 25, 2024
4 of 5 checks passed
@wxg0103 wxg0103 deleted the pr@main@fix_1050847 branch December 25, 2024 10:33
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