Skip to content

Conversation

@amjadnattouf
Copy link

The test_incompatible_audio_file_error test failed and raised the ValueError as mp3 format.
The test_sphinx_keywords fixed the tests before as they failed
Issue #778

Copy link
Collaborator

@ftnext ftnext left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for splitting the pull request.
First I have a question.

Copy link
Collaborator

@ftnext ftnext left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for moving the test code.

Please remove all comments.
Your change can "Explain Yourself in Code (ref: Clean Code)", so it seems that there is no need for comments

@amjadnattouf amjadnattouf requested a review from ftnext November 16, 2024 22:42
@amjadnattouf
Copy link
Author

@ftnext done ✅

Copy link
Collaborator

@ftnext ftnext left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fix so far.

I have added comments on more specifics as the code has become more concise.

self.assertSimilar(audio.get_raw_data()[:32], b"\x00\x00\x00\x00\x00\x00\xfe\xff\x00\x00\x02\x00\x00\x00\xfe\xff\x00\x00\x00\x00\x00\xff\x01\x00\x00\x02\xfc\xff\x00\xfe\x01\x00")

def test_incompatible_audio_file_error(self):
self.AUDIO_FILE_EN_MP3 = path.join(path.dirname(path.realpath(__file__)), "english.mp3")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.AUDIO_FILE_EN_MP3 -> AUDIO_FILE_EN_MP3
self seems to be unnecessary.

self.AUDIO_FILE_EN_MP3 = path.join(path.dirname(path.realpath(__file__)), "english.mp3")
r = sr.Recognizer()
with self.assertRaises(ValueError) as context:
with sr.AudioFile(self.AUDIO_FILE_EN_MP3) as source:r.record(source)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with sr.AudioFile(AUDIO_FILE_EN_MP3) as source:
    pass

Test target is AudioFile.__enter__(), so Recognizer is not required.

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.

2 participants