CoolFace
Apppublic

lenML/ChatTTS-Forge

sourceHugging Faceagpl-3.0updated 2y agoView on Hugging Face
301likes
localization_runtime.py375 linesDownload Raw Back to webui
1class LocalizationVars:2    def __init__(self):3        self.DEFAULT_TTS_TEXT = ""4        self.DEFAULT_SPEAKER_TEST_TEXT = ""5        self.DEFAULT_SPEAKER_MERAGE_TEXT = ""6        self.DEFAULT_SSML_TEXT = ""7 8        self.ssml_examples = []9        self.tts_examples = []10        self.podcast_default = []11 12 13class ZHLocalizationVars(LocalizationVars):14    def __init__(self):15        super().__init__()16        self.DEFAULT_TTS_TEXT = "chat T T S 是一款强大的对话式文本转语音模型。它有中英混读和多说话人的能力。"17        self.DEFAULT_SPEAKER_TEST_TEXT = (18            "说话人测试 123456789 [uv_break] ok, test done [lbreak]"19        )20        self.DEFAULT_SPEAKER_MERAGE_TEXT = (21            "说话人合并测试 123456789 [uv_break] ok, test done [lbreak]"22        )23        self.DEFAULT_SSML_TEXT = """24<speak version="0.1">25  <voice spk="Bob" seed="42" style="narration-relaxed">26    这里是一个简单的 SSML 示例 [lbreak] 27  </voice>28</speak>29        """.strip()30 31        self.ssml_examples = [32            """33<speak version="0.1">34    <voice spk="Bob" seed="42" style="narration-relaxed">35        下面是一个 ChatTTS 用于合成多角色多情感的有声书示例[lbreak]36    </voice>37    <voice spk="Bob" seed="42" style="narration-relaxed">38        黛玉冷笑道:[lbreak]39    </voice>40    <voice spk="female2" seed="42" style="angry">41        我说呢 [uv_break] ,亏了绊住,不然,早就飞起来了[lbreak]42    </voice>43    <voice spk="Bob" seed="42" style="narration-relaxed">44        宝玉道:[lbreak]45    </voice>46    <voice spk="Alice" seed="42" style="unfriendly">47        “只许和你玩 [uv_break] ,替你解闷。不过偶然到他那里,就说这些闲话。”[lbreak]48    </voice>49    <voice spk="female2" seed="42" style="angry">50        “好没意思的话![uv_break] 去不去,关我什么事儿? 又没叫你替我解闷儿 [uv_break],还许你不理我呢” [lbreak]51    </voice>52    <voice spk="Bob" seed="42" style="narration-relaxed">53        说着,便赌气回房去了 [lbreak]54    </voice>55</speak>56""",57            """58<speak version="0.1">59    <voice spk="Bob" seed="42" style="narration-relaxed">60        使用 prosody 控制生成文本的语速语调和音量,示例如下 [lbreak]61 62        <prosody>63            无任何限制将会继承父级voice配置进行生成 [lbreak]64        </prosody>65        <prosody rate="1.5">66            设置 rate 大于1表示加速,小于1为减速 [lbreak]67        </prosody>68        <prosody pitch="6">69            设置 pitch 调整音调,设置为6表示提高6个半音 [lbreak]70        </prosody>71        <prosody volume="2">72            设置 volume 调整音量,设置为2表示提高2个分贝 [lbreak]73        </prosody>74 75        在 voice 中无prosody包裹的文本即为默认生成状态下的语音 [lbreak]76    </voice>77</speak>78""",79            """80<speak version="0.1">81    <voice spk="Bob" seed="42" style="narration-relaxed">82        使用 break 标签将会简单的 [lbreak]83        84        <break time="500" />85 86        插入一段空白到生成结果中 [lbreak]87    </voice>88</speak>89""",90        ]91 92        self.tts_examples = [93            {94                "text": """95Fear is the path to the dark side. Fear leads to anger. Anger leads to hate. Hate leads to suffering.96恐惧是通向黑暗之路。恐惧导致愤怒。愤怒引发仇恨。仇恨造成痛苦。 [lbreak]97Do. Or do not. There is no try.98要么做,要么不做,没有试试看。[lbreak]99Peace is a lie, there is only passion.100安宁即是谎言,激情方为王道。[lbreak]101Through passion, I gain strength.102我以激情换取力量。[lbreak]103Through strength, I gain power.104以力量赚取权力。[lbreak]105Through power, I gain victory.106以权力赢取胜利。[lbreak]107Through victory, my chains are broken.108于胜利中超越自我。[lbreak]109The Force shall free me.110原力任我逍遥。[lbreak]111May the force be with you!112愿原力与你同在![lbreak]113              """.strip()114            },115            {116                "text": "大🍌,一条大🍌,嘿,你的感觉真的很奇妙  [lbreak]",117            },118            {119                "text": "Big 🍌, a big 🍌, hey, your feeling is really wonderful [lbreak]"120            },121            {122                "text": """123# 这是 markdown 标题124 125```126代码块将跳过127```128 129- **文本标准化**:130  - **Markdown**: 自动检测处理 markdown 格式文本。131  - **数字转写**: 自动将数字转为模型可识别的文本。132  - **Emoji 适配**: 自动翻译 emoji 为可读文本。133  - **基于分词器**: 基于 tokenizer 预处理文本,覆盖模型所有不支持字符范围。134  - **中英文识别**: 适配英文环境。135        """136            },137            {138                "text": "天气预报显示,今天会有小雨,请大家出门时记得带伞。降温的天气也提醒我们要适时添衣保暖 [lbreak]",139            },140            {141                "text": "公司的年度总结会议将在下周三举行,请各部门提前准备好相关材料,确保会议顺利进行 [lbreak]",142            },143            {144                "text": "今天的午餐菜单包括烤鸡、沙拉和蔬菜汤,大家可以根据自己的口味选择适合的菜品 [lbreak]",145            },146            {147                "text": "请注意,电梯将在下午两点进行例行维护,预计需要一个小时的时间,请大家在此期间使用楼梯 [lbreak]",148            },149            {150                "text": "图书馆新到了一批书籍,涵盖了文学、科学和历史等多个领域,欢迎大家前来借阅 [lbreak]",151            },152            {153                "text": "电影中梁朝伟扮演的陈永仁的编号27149 [lbreak]",154            },155            {156                "text": "这块黄金重达324.75克 [lbreak]",157            },158            {159                "text": "我们班的最高总分为583分 [lbreak]",160            },161            {162                "text": "12~23 [lbreak]",163            },164            {165                "text": "-1.5~2 [lbreak]",166            },167            {168                "text": "她出生于86年8月18日,她弟弟出生于1995年3月1日 [lbreak]",169            },170            {171                "text": "等会请在12:05请通知我 [lbreak]",172            },173            {174                "text": "今天的最低气温达到-10°C [lbreak]",175            },176            {177                "text": "现场有7/12的观众投出了赞成票 [lbreak]",178            },179            {180                "text": "明天有62%的概率降雨 [lbreak]",181            },182            {183                "text": "随便来几个价格12块5,34.5元,20.1万 [lbreak]",184            },185            {186                "text": "这是固话0421-33441122 [lbreak]",187            },188            {189                "text": "这是手机+86 18544139121 [lbreak]",190            },191        ]192 193        self.podcast_default = [194            [195                1,196                "female2",197                "你好,欢迎收听今天的播客内容。今天我们要聊的是中华料理。",198                "podcast",199            ],200            [201                2,202                "Alice",203                "嗨,我特别期待这个话题!中华料理真的是博大精深。",204                "podcast",205            ],206            [207                3,208                "Bob",209                "没错,中华料理有着几千年的历史,而且每个地区都有自己的特色菜。",210                "podcast",211            ],212            [213                4,214                "female2",215                "那我们先从最有名的川菜开始吧。川菜以其麻辣著称,是很多人的最爱。",216                "podcast",217            ],218            [219                5,220                "Alice",221                "对,我特别喜欢吃麻婆豆腐和辣子鸡。那种麻辣的感觉真是让人难以忘怀。",222                "podcast",223            ],224            [225                6,226                "Bob",227                "除了川菜,粤菜也是很受欢迎的。粤菜讲究鲜美,像是白切鸡和蒸鱼都是经典。",228                "podcast",229            ],230            [231                7,232                "female2",233                "对啊,粤菜的烹饪方式比较清淡,更注重食材本身的味道。",234                "podcast",235            ],236            [237                8,238                "Alice",239                "还有北京的京菜,像北京烤鸭,那可是来北京必吃的美食。",240                "podcast",241            ],242            [243                9,244                "Bob",245                "不仅如此,还有淮扬菜、湘菜、鲁菜等等,每个菜系都有其独特的风味。",246                "podcast",247            ],248            [249                10,250                "female2",251                "对对对,像淮扬菜的狮子头,湘菜的剁椒鱼头,都是让人垂涎三尺的美味。",252                "podcast",253            ],254        ]255 256 257class ENLocalizationVars(LocalizationVars):258    def __init__(self):259        super().__init__()260        self.DEFAULT_TTS_TEXT = "Chat T T S is a powerful conversational text-to-speech model. It has the ability to mix Chinese and English and multiple speakers."261        self.DEFAULT_SPEAKER_TEST_TEXT = (262            "Speaker test 123456789 [uv_break] ok, test done [lbreak]"263        )264        self.DEFAULT_SPEAKER_MERAGE_TEXT = (265            "Speaker merge test 123456789 [uv_break] ok, test done [lbreak]"266        )267        self.DEFAULT_SSML_TEXT = """268<speak version="0.1">269    <voice spk="Bob" seed="42" style="narration-relaxed">270        Here is a simple SSML example [lbreak]271    </voice>272</speak>273        """.strip()274 275        self.ssml_examples = [276            """277<speak version="0.1">278    <voice spk="Bob" seed="42" style="narration-relaxed">279        Below is an example of ChatTTS synthesizing an audiobook with multiple roles and emotions [lbreak]280    </voice>281    <voice spk="Bob" seed="42" style="narration-relaxed">282        Daiyu sneered: [lbreak]283    </voice>284    <voice spk="female2" seed="42" style="angry">285        I said [uv_break], it's a loss to trip, otherwise, I would have flown up long ago [lbreak]286    </voice>287    <voice spk="Bob" seed="42" style="narration-relaxed">288        Bao Yu said: [lbreak]289    </voice>290    <voice spk="Alice" seed="42" style="unfriendly">291        "Only play with you [uv_break], to relieve your boredom. But occasionally go to his place, just say these idle words." [lbreak]292    </voice>293    <voice spk="female2" seed="42" style="angry">294        "What a boring thing! [uv_break] Go or not, it's none of my business? I didn't ask you to relieve my boredom [uv_break], and you don't even care about me." [lbreak]295    </voice>296    <voice spk="Bob" seed="42" style="narration-relaxed">297        Saying that, he went back to the room in anger [lbreak]298    </voice>299</speak>""",300        ]301 302        self.tts_examples = [303            {304                "text": "I guess it comes down a simple choice. Get busy living or get busy dying.",305            },306            {307                "text": "You got a dream, you gotta protect it. People can't do something themselves, they wanna tell you you can't do it. If you want something, go get it.",308            },309            {310                "text": "Don't ever let somebody tell you you can't do something. Not even me. Alright? You got a dream, you gotta protect it. When people can't do something themselves, they're gonna tell you that you can't do it. You want something, go get it. Period.",311            },312        ]313        self.podcast_default = [314            [315                1,316                "female2",317                "Hello, welcome to today's podcast. Today, we're going to talk about global cuisine.",318                "podcast",319            ],320            [321                2,322                "Alice",323                "Hi, I'm really excited about this topic! Global cuisine is incredibly diverse and fascinating.",324                "podcast",325            ],326            [327                3,328                "Bob",329                "Absolutely, every country has its own unique culinary traditions and specialties.",330                "podcast",331            ],332            [333                4,334                "female2",335                "Let's start with Italian cuisine. Italian food is loved worldwide, especially for its pasta and pizza.",336                "podcast",337            ],338            [339                5,340                "Alice",341                "Yes, I especially love a good Margherita pizza and a hearty plate of spaghetti carbonara. The flavors are simply amazing.",342                "podcast",343            ],344            [345                6,346                "Bob",347                "Besides Italian cuisine, Japanese cuisine is also very popular. Dishes like sushi and ramen have become global favorites.",348                "podcast",349            ],350            [351                7,352                "female2",353                "Exactly, Japanese cuisine is known for its emphasis on fresh ingredients and delicate presentation.",354                "podcast",355            ],356            [357                8,358                "Alice",359                "And then there's Mexican cuisine, with its bold flavors and colorful dishes like tacos and guacamole.",360                "podcast",361            ],362            [363                9,364                "Bob",365                "Not to mention, there's also Indian cuisine, Thai cuisine, French cuisine, and so many more, each with its own distinctive flavors and techniques.",366                "podcast",367            ],368            [369                10,370                "female2",371                "Yes, like Indian curry, Thai tom yum soup, and French croissants, these are all mouth-watering dishes that are loved by people all over the world.",372                "podcast",373            ],374        ]375