Code Monkey home page Code Monkey logo

Comments (4)

Artrajz avatar Artrajz commented on July 21, 2024

我会研究如何在这个API中实现的,但我可能会保留mix这个模式,自动标记设置成一个新的模式

from vits-simple-api.

Haibersut avatar Haibersut commented on July 21, 2024

目前我们是这么做的,使用正则表达式对语言进行匹配,这个问题最大的难点就是划分这个句子中的各种语言部分
例如:
输入:你好,用日语说是:こんにちは
期望输出:[ZH]你好,用日语说是:[ZH][JA]こんにちは[JA]
这样的效果最好,目前mix模式下的正则在大部分情况下能够正常输出,但还是存在语音语调被筛选掉的情况,同时不能很好地区分日语中出现的汉语

个人觉得要完全解决这个问题应该需要一个模型进行自然语言处理

以下是目前客户端处理的相关代码:

def linguistic_process(self, text):
        if len(text) > 150:
            text = "这句话太长了,抱歉"

        lang = self.lang
        patterns = {
            "mix": r'[\!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\:\;\<\>\=\?\@\[\]\{\}\\\\\^\_\`\~\u3002\uff1b\uff0c\uff1a\u201c\u201d\uff08\uff09\u3001\uff1f\u300a\u300b\u4e00-\u9fff]+|[\u3040-\u309f\u30a0-\u30ff]+|\w+|[^\u4e00-\u9fff\u3040-\u309f\u30a0-\u30ff\w]+',
            "zh": r'[\!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\:\;\<\>\=\?\@\[\]\{\}\\\\\^\_\`\~\u3002\uff1b\uff0c\uff1a\u201c\u201d\uff08\uff09\u3001\uff1f\u300a\u300b\u4e00-\u9fff\p{P}]+',
            "ja": r'[\!\"\#\$\%\&\'\(\)\*\+\,\-\.\/\:\;\<\>\=\?\@\[\]\{\}\\\\\^\_\`\~\u3002\uff1b\uff0c\uff1a\u201c\u201d\uff08\uff09\u3001\uff1f\u300a\u300b\u3040-\u309f\u30a0-\u30ff\p{P}]+',
        }
        regex = patterns.get(lang, '')
        matches = re.findall(regex, text)
        if lang == "mix":
            matched_text = ''.join(
                '[ZH]' + match + '[ZH]' if re.search(patterns['zh'], match) else
                '[JA]' + match + '[JA]' if re.search(patterns['ja'], match) else
                match if re.search('[^\u4e00-\u9fff\u3040-\u309f\u30a0-\u30ff\w]+', match) else
                "[ZH]还有一些我不会说,抱歉[ZH]"
                for match in matches
            )
        else:
            matched_text = ''.join(matches)

        return matched_text

from vits-simple-api.

Artrajz avatar Artrajz commented on July 21, 2024

感谢!我会参考的。

from vits-simple-api.

Artrajz avatar Artrajz commented on July 21, 2024

已初步完成,自动识别模式为auto,lang默认参数为auto,保留mix模式以便自定义

from vits-simple-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.