Распознавание речи - микрофон не работает с exe-файлами, созданными с помощью pyinstaller

      import pyttsx3 
import speech_recognition as sr 
from tkinter import *
from PIL import Image,ImageTk
from customtkinter import *

def micro():
        global statement
        r=sr.Recognizer()
        with sr.Microphone() as source:  
            r.adjust_for_ambient_noise(source=source)
            audio=r.listen(source)
            r.energy_threshold=200
            r.pause_threshold=0.5
            try:
                statement=r.recognize_google(audio)
            except Exception as e:
                statement=" "
                engine.say("Pardon me ,please say that again")
                engine.runAndWait()  

def text_fill():
    micro()
    text_area.insert("end"," "+ statement)
    

def main():
    global root,label,frame1,engine,image1
    root=CTk()
    root.geometry("700x600")
    root.resizable(0,0)
    root.title("Notepad")
    frame1=CTkFrame(root,width=150,height=580)
    frame1.pack_propagate(False)
    frame1.place(x=10,y=10)
    set_appearance_mode("dark")
    set_default_color_theme("green")
    engine=pyttsx3.init()
    label=CTkLabel(root,text="File",width=520,height=40,font=("Algerian",30))
    label.place(x=170,y=10)
    global S
    global text_area
    text_area=CTkTextbox(root,height=580,width=520,) 
    text_area.place(x=170,y=60)  
    image1=CTkImage(Image.open("microphone.png"),size=(26,26))
    micro_button=CTkButton(root,image=image1,width=10,height=10,text="",command=text_fill)
    micro_button.place(x=650,y=15)

    root.update()
    root.mainloop()
  

if __name__=="__main__":
        main()

Я преобразовал эту программу в файл .exe с помощью pyinstaller. Всякий раз, когда я запускаю обычную программу, я вижу микрофон на панели задач, и программа работает без сбоев, но когда я запускаю ее исполняемый файл, микрофон не отображается на панели задач, и поэтому я не могу вводить данные с помощью голоса.

0 ответов

Другие вопросы по тегам