Skip to content

Refactor audio helper, improve CLI/GUI error handling, and add OpenAI SDK requirement#1

Open
SPark1264 wants to merge 1 commit intomainfrom
codex/set-up-ai-chatbot-integration
Open

Refactor audio helper, improve CLI/GUI error handling, and add OpenAI SDK requirement#1
SPark1264 wants to merge 1 commit intomainfrom
codex/set-up-ai-chatbot-integration

Conversation

@SPark1264
Copy link
Owner

Motivation

  • Resolve PyCharm typing/structure issues by simplifying where audio capture lives and keeping the typed OpenAI chat call.
  • Ensure microphone capture uses ALSA-compatible tooling on Raspberry Pi by relying on arecord with a clear failure message if not installed.
  • Surface runtime errors to users and avoid silent failures in both CLI and GUI flows.

Description

  • Moved record_audio_wav(...) to a module-level function and updated BMOAssistant.transcribe_microphone(...) to call it directly.
  • Use arecord (ALSA) for recording a mono 16kHz WAV and raise a helpful error if the binary is missing.
  • Add invalid-menu-choice handling in run_cli(...) so non-1/2 inputs print a guidance message.
  • Add exception handling in GUI worker threads to append Error: <exc> lines to the UI output when background ask_chatbot/transcribe_microphone calls fail.
  • Preserve the typed chat call using self.client.chat.completions.create(...) with ChatCompletionSystemMessageParam/ChatCompletionUserMessageParam.
  • Add requirements.txt requiring openai>=1.40.0 to match the SDK usage.

Testing

  • Ran python -m compileall main.py and the file compiled successfully.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant