Example #1
0
def audio_msg(update, context):
    print("Hey, please wait I am transcripting your audio!")
    audio_file = context.bot.getFile(update.message.voice.file_id)
    audio_file.download('voice.ogg')
    transcription = audio_processor()
    print("calling translator with " + transcription)
    context.bot.send_message(chat_id=update.effective_chat.id,
                             text="You just said " + transcription +
                             " in the voice note!")
    tranlate_text = translatorFn(transcription, bot_cmd_list[-1])
    context.bot.send_message(chat_id=update.effective_chat.id,
                             text="Translated Text: " + tranlate_text)
    textToSpeech(tranlate_text)
Example #2
0
 def __init__(self):
     self._speech = googleSpeech()
     self._turing = turing123()
     self._text2Speech = textToSpeech()
     thread = threading.Thread(target=self.run, args=())
     thread.daemon = True  # Daemonize thread
     thread.start()  # Start the execution
Example #3
0
def googleSpeechToTextWithWatsonSpeechToTest():
    r = sr.Recognizer()
    with sr.WavFile(
            "test.wav") as source:  # use "test.wav" as the audio source
        r.energy_threshold = 4000
        audio = r.record(source)  # extract audio data from the file
        try:
            sentence = r.recognize_google(audio)
            print("You said " +
                  sentence)  # recognize speech using Google Speech Recognition
            dataInt.gatherData()
            bestAnswer = dataInt.returnBestAnswer(sentence)
            print(bestAnswer)
            textToSpeech.textToSpeech(bestAnswer)
        except IndexError:  # the API key didn't work
            print("No internet connection")
        except KeyError:  # the API key didn't work
            print("Invalid API key or quota maxed out")
        except LookupError:  # speech is unintelligible
            print("Could not understand audio")
Example #4
0
  def __init__(self):
    """
    Initialization of the kernel.

    Returns:
      None
    """

    # load default config
    self.loadConfig('defaultConfig.yml')

    # init wrappers
    self.attwordListener = attwordListener.attwordListener(self.attwordConfig)
    self.speechToText = speechToText.speechToText(self.speechToTextConfig)
    self.queryProcessor = queryProcessor.queryProcessor(self.queryProcessorConfig)
    self.textToSpeech = textToSpeech.textToSpeech(self.textToSpeechConfig)
  def __init__(self):
    """
    Initialization of the kernel.

    Returns:
      None
    """

    # load default config
    self.loadConfig('defaultConfig.yml')

    # init wrappers
    self.attwordListener = attwordListener.attwordListener(self.attwordConfig, 'attention word module')
    self.speechToText = speechToText.speechToText(self.speechToTextConfig, 'speech-to-text module')
    self.getIntent = getIntent.getIntent(self.getIntentConfig, 'get intent module')
    self.queryProcessor = queryProcessor.queryProcessor(self.queryProcessorConfig, 'query processing module')
    self.textToSpeech = textToSpeech.textToSpeech(self.textToSpeechConfig, 'text-to-speech module')
Example #6
0
    def find_def(self, text, lemma, pos):

        # get the definition and synonyms of the word
        if not lemma:
            definition = DefinitionService.findDef(text, pos)
            synonyms = DefinitionService.findSyn(text, pos)
        else:
            definition = DefinitionService.findDef(lemma, pos)
            synonyms = DefinitionService.findSyn(lemma, pos)

        # get the encoded audio information
        sound = textToSpeech.textToSpeech(text)

        return {
            'text': text,
            'definition': definition,
            'synonyms': synonyms,
            'sound': sound
        }
                               titles[0].firstChild.nodeValue + ".mp3")

        #os.path.join(SITE_ROOT, "static", "options.json")
        pod_dict = {}
        pod_dict['count'] = count
        stitle = titles[0].firstChild.nodeValue.encode(
            'ascii', 'ignore').decode('unicode_escape')
        #pod_dict['podcasts'] = [{'title': podcastName, 'file-name': titles[0].firstChild.nodeValue + ".mp3"}]
        pod_dict['podcasts'] = [{
            'title': podcastName,
            'file-name': stitle + ".mp3"
        }]
        count += 1

        result.append(pod_dict)
        geturl(mp3list[0], saveLoc)

    with open(static_folderpath + '/options.json', 'w') as outfile:
        json.dump(result, outfile, indent=4, sort_keys=True)

    trim()


if __name__ == '__main__':
    try:
        main()
        textToSpeech.textToSpeech()
    except KeyboardInterrupt:
        print('\n')
        sys.exit(0)
Example #8
0
# 判斷是否需要開始治療
def isNeedToStart(threat, now, offset):
    if threat['halfDay'] == now['halfDay']:
        # offset分鐘前就預先開始啟動
        if int(threat['hour']) * 60 + int(threat['min']) < int(
                now['hour']) * 60 + int(now['min']) - offset:
            return True
        else:
            return False
    else:
        return False


googleSpeech = googleSpeech()
turing = turing123()
speechConverter = textToSpeech()
motor, ldr = initRaspberry()
connection = initDB()
score = getLatestScore(connection)
threatTimeStruct = countTreatTime(score)

turingThread = threading.Thread(target=turing.result, args=())
turingThread.daemon = True  # Daemonize thread
turingThread.start()  # Start the execution

# 判斷是否完成判斷光度
isFinish = False
# 判斷是否準備好接受治療
isReady = False

threatTimeStruct['hour'] = str(2)
Example #9
0
# import des librairies

from traduction import traduction
from textToSpeech import textToSpeech
from speechToText import speechToText

print("Bonjour Bienvenu dans ATA, Assistant de Traduction Automatique")
print("Veillez prononcez la phrase à traduire en eng ")

texte = speechToText()
<<<<<<< HEAD
texte = traduction(texte)
textToSpeech(texte)
=======

print("J'ai entendu : " + texte)
texte, langue = traduction(texte)
textToSpeech(texte, langue)
>>>>>>> 2d2bd022454c6b8cc5d6924eaf5ce12d92917f35

print("J'ai fini !")