Exemplo n.º 1
0
def showMenus(show_menu_channels=(),
              show_zh_menu_channels=(),
              meal_types=(),
              when=None):

  if isinstance(show_menu_channels, basestring):
    show_menu_channels = (show_menu_channels,)
  if isinstance(show_zh_menu_channels, basestring):
    show_zh_menu_channels = (show_zh_menu_channels,)
  if isinstance(meal_types, basestring):
    meal_types = (meal_types,)
  meal_types = meal_types and [meal_type.title() for meal_type in meal_types]

  meal_type = FacebookMenu.getMealType(when)
  if meal_type and (not meal_types or
                    meal_type in meal_types):
    menus = FacebookMenu.getMenus(when)
    if menus:
      if ' ' not in meal_type:
        meal_type += ' time'
      message = '%s\n%s' % (meal_type, '\n'.join(menus))
      sayOnChannels(show_menu_channels, message)
      zh_message = GoogleTranslate.translate(message)
      sayOnChannels(show_zh_menu_channels, zh_message)
Exemplo n.º 2
0
 def translate_en2cn(self, text):
     text_ = GoogleTranslate.translate('en', 'zh-CN', text)
     return text_
Exemplo n.º 3
0
import GoogleTranslate

with open('test.txt', 'w', encoding='utf-8') as f:
    f.writelines("\t测试\n")
exit(0)

text = 'Social media has been developing rapidly in public due to its nature of spreading new information, which leads to rumors being circulated. Meanwhile, detecting rumors from such massive information in social media is becoming an arduous challenge. Therefore, some deep learning methods are applied to discover rumors through the way they spread, such as Recursive Neural Network (RvNN) and so on. However, these deep learning methods only take into account the patterns of deep propagation but ignore the structures of wide dispersion in rumor detection. Actually, propagation and dispersion are two crucial characteristics of rumors. In this paper, we propose a novel bi-directional graph model, named Bi-Directional Graph Convolutional Networks (Bi-GCN), to explore both characteristics by operating on both top-down and bottom-up propagation of rumors. It leverages a GCN with a top-down directed graph of rumor spreading to learn the patterns of rumor propagation; and a GCN with an opposite directed graph of rumor diffusion to capture the structures of rumor dispersion. Moreover, the information from source post is involved in each layer of GCN to enhance the influences from the roots of rumors. Encouraging empirical results on several benchmarks confirm the superiority of the proposed method over the state-of-the-art approaches.'
print(GoogleTranslate.translate('en', 'zh-CN', text))
import speech_recognition as sr
import GoogleTranslate
import argparse


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument("-s", "--selfLanguage", required=True, type=str)
    parser.add_argument("-t", "--targetLanguage", required=True, type=str)

    args = parser.parse_args()
    r = sr.Recognizer()
    m = sr.Microphone()

    with m as source:
        print "say something"
        audio = r.listen(source)

    try:
        text = r.recognize_google(audio)
    except sr.UnknownValueError:
        print "Google Speech Recognition could not understand audio"
    except sr.RequestError as e:
        print "Could not request results from Google Speech Recognition service; {0}".format(e)

    if text is not None:
        try:
            translatedText = GoogleTranslate.translate(text, args.targetLanguage, args.selfLanguage)
        except:
            print "Something went wrong with the translation"
Exemplo n.º 5
0
import argparse

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument("-s", "--selfLanguage", required=True, type=str)
    parser.add_argument("-t", "--targetLanguage", required=True, type=str)

    args = parser.parse_args()
    r = sr.Recognizer()
    m = sr.Microphone()

    with m as source:
        print "say something"
        audio = r.listen(source)

    try:
        text = r.recognize_google(audio)
    except sr.UnknownValueError:
        print "Google Speech Recognition could not understand audio"
    except sr.RequestError as e:
        print "Could not request results from Google Speech Recognition service; {0}".format(
            e)

    if text is not None:
        try:
            translatedText = GoogleTranslate.translate(text,
                                                       args.targetLanguage,
                                                       args.selfLanguage)
        except:
            print "Something went wrong with the translation"