Bugfix/cross platform console input#6
Open
Marconiadsf wants to merge 2 commits intocloudwalk:mainfrom
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request addresses a critical portability bug in the
record_audio.pyutility 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 anOSError: [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 inrecord_audio.py. This function provides a cross-platform solution for console input detection:os.name == 'nt'), it utilizes themsvcrtmodule (msvcrt.kbhit()andmsvcrt.getch()) to reliably detect the Enter key.select.select()mechanism, which is appropriate for those environments.The
record_audio()function now callswait_for_enter()to handle the input, ensuring that the application can start and stop recording correctly across all supported operating systems.Testing:
OSErrorno longer occurs, and Enter key presses are correctly detected.