Seite 1 von 1

Python Spracherkennung

Verfasst: Donnerstag 30. September 2021, 19:45
von dsm4
Hallo,

ich habe einen Sprachassistenten im Internet gefunden. Jedoch bekomme ich diesen Error:

Code: Alles auswählen

C:\Users\timo\PycharmProjects\pythonProject\venv\Scripts\python.exe C:/Users/timo/PycharmProjects/pythonProject/main.py
Traceback (most recent call last):
  File "C:/Users/timo/PycharmProjects/pythonProject/main.py", line 1, in <module>
    from neuralintents import GenericAssistant
  File "C:\Users\timo\PycharmProjects\pythonProject\venv\lib\site-packages\neuralintents\__init__.py", line 1, in <module>
    from neuralintents.main import GenericAssistant
  File "C:\Users\timo\PycharmProjects\pythonProject\venv\lib\site-packages\neuralintents\main.py", line 14, in <module>
    from tensorflow.keras.models import Sequential
  File "C:\Users\timo\PycharmProjects\pythonProject\venv\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "C:\Users\timo\PycharmProjects\pythonProject\venv\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>
    from tensorflow.python.eager import context
  File "C:\Users\timo\PycharmProjects\pythonProject\venv\lib\site-packages\tensorflow\python\eager\context.py", line 35, in <module>
    from tensorflow.python import pywrap_tfe
  File "C:\Users\timo\PycharmProjects\pythonProject\venv\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\timo\PycharmProjects\pythonProject\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 28, in <module>
    self_check.preload_check()
  File "C:\Users\timo\PycharmProjects\pythonProject\venv\lib\site-packages\tensorflow\python\platform\self_check.py", line 61, in preload_check
    % " or ".join(missing))
ImportError: Could not find the DLL(s) 'msvcp140.dll or msvcp140_1.dll'. TensorFlow requires that these DLLs be installed in a directory that is named in your %PATH% environment variable. You may install these DLLs by downloading "Microsoft C++ Redistributable for Visual Studio 2015, 2017 and 2019" for your platform from this URL: https://support.microsoft.com/help/2977003/the-latest-supported-visual-c-downloads

Process finished with exit code 1
Der Python Code:

Code: Alles auswählen

from neuralintents import GenericAssistant
import speech_recognition
import pyttsx3 as tts
import sys

recognizer = speech_recognition.Recognizer()

speaker = tts.init()
speaker.setProperty('rate', 150)

todo_list = ['Go Shopping', 'Clean Room', 'finsih python projekt']

def create_note():
    global recognizer

    speaker.say("What do you want to write on to your note")
    speaker.runAndWait()

    done = False


    while not done:
        try:

            with speech_recognition.Microphone() as mic:

                recognizer.adjust_for_ambient_noise(mic, duration=0.2)
                audio = recognizer.listen(mic)

                note = recognizer.recognize_google(audio)
                note = note.lower()

                speaker.say("Choose a filename!")
                speaker.runAndWait()

                recognizer.adjust_for_ambient_noise(mic, duration=0.2)
                audio = recognizer.listen(mic)

                filename = recognizer.recognize_google(audio)
                filename = filename.lower()

            with open(filename, 'w') as f:
                f.write(note)
                done = True
                speaker.say(f"I succesfully created the note {filename}")
                speaker.runAndWait()

        except speech_recognition.UnknowValueError:
            recognizer = speech_recognition.Recognizer()
            speaker.say("I did not understand you! Please try it again")
            speaker.runAndWait()

def add_todo():

    global recognizer

    speaker.say("What todo do you want to add?")
    speaker.runAndWait()

    done = False

    while not done:
        try:

            with speech_recognition.Microphone() as mic:

                recognizer.adjust_for_ambient_noise(mic, duration=0.2)
                audio = recognizer.listen(mic)

                item = recognizer.recognize_google(audio)
                item = item.lower()

                todo_list.append(item)
                done = True

                speaker.say(f"I added {item} to the to do list!")
                speaker.runAndWait

        except speech_recognition.UnknowValueError:
            recognizer = speech_recognition.Recognizer()
            speaker.say("I did not understand you! Please try it again")
            speaker.runAndWait()


def show_todos():

    speaker.say("The items on your to do list are the following")
    for item in todo_list:
        speaker.say(item)
    speaker.runAndWait()


def hello():
    speaker.say("Hello. What can I do for you?")
    speaker.runAndWait()

def quit():
    speaker.say("Bye")
    speaker.runAndWait()
    sys.exit(0)



mappings = {
    "greeting": hello,
    "create_note": create_note,
    "add_todo": add_todo,
    "show_todos": show_todos,
    "exit": quit()
}


assistant = GenericAssistant('intents.json', intent_methods=mappings)
assistant.train_model()

while True:

    try:
        with speech_recognition.Microphone() as mic:

            recognizer.adjust_for_ambient_noise(mic, duration=0.2)
            audio = recognizer.listen(mic)

            message = recognizer.recognize_google(audio)
            message = message.lower()

        assistant.request(message)
    except speech_recognition.UnknowValueError:
        recognizer = speech_recognition.Recognizer()
Und die Intents.json:

Code: Alles auswählen

{"intents":
[
  {"tag": "greeting",
    "patterns": ["Hi", "Hey", "What's up", "Hello", "greetings"],
    "responses": ["Hello!", "Hello User!", "Hello, what can I do for you?"]},
  {"tag": "create_note",
    "patterns": ["Please create a new note", "Create a new note", "New note", "I want to create a new note"],
    "responses": [""]},
  {"tag": "add_todo",
    "patterns": ["Please create a new todo", "Create a new todo", "New todo", "I want to create a new todo"],
    "responses": [""]},
  {"tag": "show_todos",
    "patterns": ["Show my todos", "What are my todos", "What is on my todo list", "Show todo list"],
    "responses": [""]},
  {"tag": "exit",
    "patterns": ["Bye", "Stop", "Quit", "Quiet", "I want to quit", "I want to quiet", "Goodbye", "I have to go"],
    "responses": [""]}
]},
Vielleicht kann mir jemand helfen? Mit Pip habe ich eigentlich alle pakete installiert.

Grüße

Re: Python Spracherkennung

Verfasst: Freitag 1. Oktober 2021, 06:08
von ThomasL
Du kennst Google? Hast du bestimmt schon mal benutzt.

Die Suche nach "Could not find the DLL(s) 'msvcp140.dll or msvcp140_1.dll'. TensorFlow requires that these DLLs" liefert (bei mir) diesen Link als zweites Ergebnis

https://stackoverflow.com/questions/605 ... ound-error

In der Antwort zu der Frage dort steht alles drin was zu tun ist.