Skip to content

Commit b011fa8

Browse files
committed
conditional import for voice
1 parent ef5921f commit b011fa8

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

operate/main.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import matplotlib.font_manager as fm
2424
from openai import OpenAI
2525
import sys
26-
from whisper_mic import WhisperMic
2726

2827

2928
load_dotenv()
@@ -199,8 +198,22 @@ def main(model, accurate_mode, voice_mode=False):
199198
"""
200199
Main function for the Self-Operating Computer
201200
"""
201+
mic = None
202202
# Initialize WhisperMic if voice_mode is True if voice_mode is True
203-
mic = WhisperMic() if voice_mode else None if voice_mode else None
203+
"""
204+
Main function for the Self-Operating Computer
205+
"""
206+
if voice_mode:
207+
try:
208+
from whisper_mic import WhisperMic
209+
210+
# Initialize WhisperMic if import is successful
211+
mic = WhisperMic()
212+
except ImportError:
213+
print(
214+
"Voice mode requires the 'whisper_mic' module. Please install it using 'pip install -r requirements-audio.txt'"
215+
)
216+
sys.exit(1)
204217

205218
message_dialog(
206219
title="Self-Operating Computer",

0 commit comments

Comments
 (0)