Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix_add_special_feature_tests #778 #783

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added tests/english.mp3
Binary file not shown.
10 changes: 10 additions & 0 deletions tests/test_audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ def test_flac_stereo_24_bit(self):
else:
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.

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.


self.assertEqual(
str(context.exception),
"Audio file could not be read as PCM WAV, AIFF/AIFF-C, or Native FLAC; check if file is corrupted or in another format"
)

if __name__ == "__main__":
unittest.main()