Skip to content

Bugfix/cross platform console input#6

Open
Marconiadsf wants to merge 2 commits intocloudwalk:mainfrom
Marconiadsf:bugfix/cross-platform-console-input
Open

Bugfix/cross platform console input#6
Marconiadsf wants to merge 2 commits intocloudwalk:mainfrom
Marconiadsf:bugfix/cross-platform-console-input

Conversation

@Marconiadsf
Copy link

This pull request addresses a critical portability bug in the record_audio.py utility that prevented the application from running correctly on Windows.

Problem:
The original implementation used select.select([sys.stdin], [], [], 0.1)[0] to detect Enter key presses. This function is Unix-specific and resulted in an OSError: [WinError 10038] "Foi tentada uma operação em algum item que não é um soquete" on Windows systems, causing the application to crash during audio recording initialization.

Solution:
A new helper function, wait_for_enter(), has been introduced in record_audio.py. This function provides a cross-platform solution for console input detection:

  • On Windows (os.name == 'nt'), it utilizes the msvcrt module (msvcrt.kbhit() and msvcrt.getch()) to reliably detect the Enter key.
  • On Unix-like systems (Linux, macOS), it continues to use the existing select.select() mechanism, which is appropriate for those environments.

The record_audio() function now calls wait_for_enter() to handle the input, ensuring that the application can start and stop recording correctly across all supported operating systems.

Testing:

  • Verified local functionality on a Windows environment, where the OSError no longer occurs, and Enter key presses are correctly detected.
  • The core audio recording logic remains unchanged.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant