Почему после импорта из .py в .exe у меня перестала работать функция while True

import os
from pygame import mixer
from gtts import gTTS
import speech_recognition as sr
import pyaudio
import webbrowser
from tkinter import *
import pyperclip
import wget

cmd_dict = {}

def click():

    voice = e_v.get()
    url = e_url.get()

    if voice == '' or url == '':
        l['text'] = 'Поля не заполнены'
        l['bg'] = 'yellow'

    else:
        cmd_dict[voice] = url 
        l['text'] = 'Успешно'
        l['bg'] = 'lime'


def main():
    while True:
        with sr.Microphone(device_index = device_index) as source:
            audio = r.listen(source = source, phrase_time_limit=3)
        try:
            speech = r.recognize_google(audio, language="ru_RU").lower()
            print(speech)
            for key in cmd_dict:
                if key in speech:
                    webbrowser.get(using='windows-default').open_new_tab('https://' + str(cmd_dict[key]))
                    answer('Открываю.')
        except:
            pass

window = Tk()
window.geometry('300x175')
window.title('SawaPlayGO | discord - mod')

window.resizable(width=False, height=False)

# Виджеты

l = Label()
l.place(x=50, y=115)

l_voice = Label(text='Команда ->')
l_voice.place(x=50, y=50)
l_url = Label(text='Ссылка -> ')
l_url.place(x=50, y=75)

but = Button(text='Добавить', command=click)
but.place(x=225, y=140)

but_s = Button(text='Старт', command=main)
but_s.place(x=50, y=140)

e_v = Entry()
e_v.place(x=150, y=45)

e_url = Entry()
e_url.place(x=150, y=75)


p = pyaudio.PyAudio()
device_index = None
for i in range(p.get_device_count()):
    device_info = p.get_device_info_by_index(i)
    if device_info.get("defaultSampleRate") == 44100.0:
        device_index = i
        break

def answer(my_string):
    mixer.init()
    tts = gTTS(text=my_string, lang="ru", slow=True)
    tts.save("abc.mp3")
    mixer.init()
    mixer.music.load("abc.mp3")
    mixer.music.set_volume(0.3) #от 0 до 1
    mixer.music.play()

    while mixer.music.get_busy():
        continue
    mixer.quit()
    os.remove('abc.mp3')

r = sr.Recognizer()

window.mainloop()

Использовал для перевода с .py в .exe - 'auto-py-to-exe'

Сама программа в .py работает, а вот уже в .exe нету отклика от неё.


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