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] Replace mispronounced words in TTS using hack method #350

Merged
merged 4 commits into from
Jun 19, 2024

Conversation

6drf21e
Copy link
Contributor

@6drf21e 6drf21e commented Jun 19, 2024

This PR addresses the issue of mispronounced words in the TTS system by implementing a hack method. The main idea is as follows:

  1. Identify correctly pronounced characters by ChatTTS.
  2. Replace the mispronounced characters with correctly pronounced ones.

For example:

  • Original: 关关雎鸠,在河之洲。窈窕淑女,君子好逑。
  • Corrected: 关关鸠,在河之洲。咬挑淑女,君子好

The replacement rule file ChatTTS/homophones_map.json contains 16,000 entries.

Rule creation process:

  1. Use a word corpus to let ChatTTS infer the text.
  2. Record any discrepancies between the inferred text and the input.
  3. Find homophones with the correct pronunciation for the mismatched characters.

Corpus used: Tencent AI Lab Embedding Corpora for Chinese and English Words and Phrases

Limitations:

  1. Some characters and words might not be covered.
  2. Some characters do not have correctly pronounced homophones, e.g., “sǒu 叟”.

中文:

本次PR通过使用hack办法解决TTS系统中读错、漏读的问题。主要的构思如下:

  1. 找到ChatTTS读音正确的字。
  2. 将读错的字符替换成读音正确的字。

例如:

  • 原文: 关关雎鸠,在河之洲。窈窕淑女,君子好逑。
  • 替换后: 关关鸠,在河之洲。咬挑淑女,君子好

替换规则文件 ChatTTS/homophones_map.json 包含1.6万条规则。

规则制作流程:

  1. 使用词库,让ChatTTS推理文本。
  2. 记录推理文本和输入文本之间的不一致。
  3. 将不一致的字找到对应的正确读音的同音字。

当前版本所使用的词库:腾讯AI实验室中英文词语嵌入语料库

缺陷:

  1. 可能有未覆盖的字词。
  2. 有些字找不到能读正确的字,比如“sǒu 叟”。

ChatTTS/utils/infer_utils.py Outdated Show resolved Hide resolved
@fumiama fumiama added enhancement New feature or request good first issue Good for newcomers labels Jun 19, 2024
@fumiama
Copy link
Member

fumiama commented Jun 19, 2024

p.s. 建议在代码中标明加载的json的出处。

Copy link
Member

@fumiama fumiama left a comment

Choose a reason for hiding this comment

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

Thanks!

@fumiama fumiama merged commit ce1c962 into 2noise:main Jun 19, 2024
@aliencaocao
Copy link
Contributor

Im curious on whether this hack has been verified to not affect the output quality by any means. By swapping words, you are scrambling up phrases into meaningless indiv characters. By right this should affect the linguistic ability of the model.

@fumiama
Copy link
Member

fumiama commented Jun 19, 2024

By right this should affect the linguistic ability of the model.

It is better than no sound if the model cannot recognize that character. We will remove (or shrink) this replace if the model is updated and it can recognize new characters.

@6drf21e
Copy link
Contributor Author

6drf21e commented Jun 19, 2024

The replacements only target incorrectly output characters. In modern novels, the replacement rate is low. For example, in "Twenty Thousand Leagues Under the Sea":

  • Total Chinese characters: 214,526
  • Replaced characters: 316
  • Replacement rate: 0.15%

Top 10 Replaced Characters:

Original Replacement Count
43
32
27
22
16
12
12
8
7
6

In ancient novels, the rate is higher. For example, in "Romance of the Three Kingdoms":

  • Total Chinese characters: 493,054
  • Replaced characters: 6,946
  • Replacement rate: 1.41%

Top 10 Replaced Characters:

Original Replacement Count
249
189
161
154
136
134
133
119
109
103

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants