Hello I am new at coding the microcontrolers and I dont know what I am doing wrong. Could someone help me. I get the access denied. I checked everything the port, baudrate, drivers and still get this error. I dont have more ideas CODE IN PYTHON
import speech_recognition as sr
import pyttsx3
import pyaudio
import webbrowser
import os
import subprocess
import serial
silnik = pyttsx3.init()
silnik.setProperty("glosnosc", 0.70)
silnik.setProperty("szybkosc", 120)
voices = silnik.getProperty('voices')
silnik.setProperty('voice', voices[0].id)
przegladarka_path = "C:/Users/x/AppData/Local/Programs/Opera GX/launcher.exe %s"
num = 5
ser = serial.Serial("COM3", 115200)
ser.open()
def recognise(msg="Powiedz coś!"):
r = sr.Recognizer()
with sr.Microphone() as source:
print(msg)
audio = r.listen(source)
try:
recognised_text = r.recognize_google(audio, language="pl-PL")
print("Powiedziałeś: " + recognised_text)
return recognised_text.lower()
except sr.UnknownValueError:
print("Nie rozumiem co mowisz")
except sr.RequestError as e:
print("ERROR", e)
text = recognise()
word_list = text.split(" ")
if ("otwórz" in text and word_list[0] == "otwórz") or ("uruchom" in text and word_list[0] == "uruchom"):
if "przeglądarkę" in text:
silnik.say("Otwieram przeglądarke!")
silnik.runAndWait()
webbrowser.get(przegladarka_path).open_new_tab("http://www.google.com")
if "youtube" in text:
silnik.say("Otwieram YouTube!")
silnik.runAndWait()
webbrowser.get(przegladarka_path).open_new_tab("https://www.youtube.com")
if "diskord" or "discord" in text:
silnik.say("Otwieram discorda!")
silnik.runAndWait()
os.startfile("C:/Users/x/AppData/Local/Discord/app-1.0.9013/Discord.exe")
if "wyłącz" in text and word_list[0] == "wyłącz":
if "komputer" in text:
silnik.say(f"Wyłączam komputer za {num} sekund")
os.system(f"shutdown /s /t {num}")
if "led" in text:
ser.write(encode("OFF"))
if "włącz" in text and word_list[0] == "włącz":
if "led" in text:
ser.write(encode("ON"))
CODE IN MICROPYTHON
import machine
import time
led_pin = machine.Pin(16, machine.Pin.OUT)
uart = machine.UART(0, 115200)
while True:
if uart.any():
command = uart.read().decode().strip()
print("Otrzymane polecenie: " + command)
if command == "ON":
led_pin.on()
elif command == "OFF":
led_pin.off()
time.sleep(0.1)
and I get the access denied. I checked everything the port, baudrate, drivers and still get this error.