define_subject.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:MUSTani-Robot 作者: swayam01 项目源码 文件源码
def define_subject(speech_text):
    words_of_message = speech_text.split()
    words_of_message.remove('define')
    cleaned_message = ' '.join(words_of_message)

    try:
        wiki_data = wikipedia.summary(cleaned_message, sentences=5)
        regEx = re.compile(r'([^\(]*)\([^\)]*\) *(.*)')
        m = regEx.match(wiki_data)
        while m:
            wiki_data = m.group(1) + m.group(2)
            m = regEx.match(wiki_data)

        wiki_data = wiki_data.replace("'", "")
        tts(wiki_data)

    except wikipedia.exceptions.DisambiguationError as e:
        tts('Can you please be more specific? You may choose something from the following.')
        print("Can you please be more specific? You may choose something from following.; {0}".format(e))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号