2noise / ChatTTS

A generative speech model for daily dialogue.
https://2noise.com
GNU Affero General Public License v3.0
31.19k stars 3.39k forks source link

[Fix] Replace mispronounced words in TTS using hack method #350

Closed 6drf21e closed 3 months ago

6drf21e commented 3 months ago

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:

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 叟”。
fumiama commented 3 months ago

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

aliencaocao commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

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

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":

Top 10 Replaced Characters:

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