Exemplo n.º 1
0
def init_speech():
    global sf
    global tf
    global TFAutoModel
    global AutoProcessor
    import soundfile as sf
    import tensorflow as tf
    from tensorflow_tts.inference import TFAutoModel
    from tensorflow_tts.inference import AutoProcessor

    global fastspeech2
    global mb_melgan
    global processor
    # initialize fastspeech2 model.
    fastspeech2 = TFAutoModel.from_pretrained(
        "tensorspeech/tts-fastspeech2-ljspeech-en")

    # initialize mb_melgan model
    mb_melgan = TFAutoModel.from_pretrained(
        "tensorspeech/tts-mb_melgan-ljspeech-en")

    # inference
    processor = AutoProcessor.from_pretrained(
        "tensorspeech/tts-fastspeech2-ljspeech-en")
    inference("Hello sir")
    debug("Speech", "init")
Exemplo n.º 2
0
def audio_to_text(filename):

    try:
        with sr.AudioFile(filename) as source:
            # listen for the data (load audio to memory)
            audio_data = r.record(source)
            # recognize (convert from speech to text)
            text = r.recognize_google(audio_data)
            save(text)
            do(text)
            debug(text, "said")
    except sr.UnknownValueError:
        pass
Exemplo n.º 3
0
def do(said):
    said = (said.lower())
    debug(time.perf_counter())

    if any(ext in said for ext in hotkey_hotword):
        shortcut(said)

    open_cmd(said)

    search(said)

    program_functions(said)

    talkings(said)
Exemplo n.º 4
0
def init_qa_pipeline():
    from transformers import pipeline
    global question_answering
    question_answering = pipeline("question-answering")
    debug("QA Pipeline", "init")
Exemplo n.º 5
0
def keep_inputing():
    while True:
        try:
            said = input("Write something: ")
            action = threading.Thread(target=do, args=[said]).start()
        except KeyboardInterrupt:

            break


def start():

    with open("opening", "w") as opening:
        opening.write("false")
    print("started listening")

    background_listen_2()


def init_items_thread():
    threading.Thread(target=init_speech).start()
    threading.Thread(target=init_qa_pipeline).start()
    print("Imported Everything")


if __name__ == "__main__":
    debug(time.perf_counter())
    init_items_thread()
    start()
    time.sleep(1000)