IndentationError: unindent does not match any outer indentation level python во время создания голосового ассистента

Когда я начал писать код для создания своего голосового ассистента у меня возникла проблема при использовании библиотеки Speech Recognition для Python.
Ошибка: IndentationError: unindent does not match any outer indentation level

Вот часть кода где возникает ошибка: r = sr.Recognizer() Вот полный код на данный момент.

import os
import sys
import time
import speech_recognition as sr
from fuzzywuzzy import fuzz
import pyttsx3
import datetime

opts = {
    "alias": ('jarvis', 'jervis', 'jirves', 'jurves', 'jervas'
              'jalvis', 'jelvis', 'jilves', 'julves', 'jelvas'),
    "tbr": ('say', 'tell', 'show', 'how much', 'will', 'would',
            'could', 'may', 'can', 'must', 'the'),
    "cmds": {
        "ctime": ('current time', 'time', 'what time is it'),
        "radio": ('turn on the music', 'turn on the radio',
                  'play radio'),
        "jokes": ('tell a joke', 'do you know any jokes',
                    'make me laugh')
    }
}

# functions

def speak(what):
    print(what)
    speak_engine.say(what)
    speak_engine.runAndWait()
    speak_engine.stop()



#start

 r = sr.Recognizer()
 m = sr.Microphone(device_index=1)

 with m as source:
     r.adjust_for_ambient_noise(source)


speak_engine = pyttsx3.init()

speak("Good day my master")
speak("Jarvis is listening")

# stop_listening = r.listen_in_background(m, callback)

# while True:
#     time.sleep(0.1) # infinite loop

все библиотеки нормально установлены с помощью pip, все библиотеки протестированы


Ответы (1 шт):

Автор решения: n1tr0xs

IndentationError - ошибка, возникающая при неправильных отступах в коде.
Вот исправленный код:

import os
import sys
import time
import speech_recognition as sr
from fuzzywuzzy import fuzz
import pyttsx3
import datetime

opts = {
    "alias": ('jarvis', 'jervis', 'jirves', 'jurves', 'jervas'
              'jalvis', 'jelvis', 'jilves', 'julves', 'jelvas'),
    "tbr": ('say', 'tell', 'show', 'how much', 'will', 'would',
            'could', 'may', 'can', 'must', 'the'),
    "cmds": {
        "ctime": ('current time', 'time', 'what time is it'),
        "radio": ('turn on the music', 'turn on the radio',
                  'play radio'),
        "jokes": ('tell a joke', 'do you know any jokes',
                    'make me laugh')
    }
}

# functions

def speak(what):
    print(what)
    speak_engine.say(what)
    speak_engine.runAndWait()
    speak_engine.stop()



#start
r = sr.Recognizer()
m = sr.Microphone(device_index=1)

with m as source:
     r.adjust_for_ambient_noise(source)


speak_engine = pyttsx3.init()

speak("Good day my master")
speak("Jarvis is listening")

#stop_listening = r.listen_in_background(m, callback)

#while True:
#   time.sleep(0.1) # infinite loop
→ Ссылка