Skip to content

Commit

Permalink
Print instead of rising error when can't use pydub
Browse files Browse the repository at this point in the history
  • Loading branch information
paulovcmedeiros committed Mar 3, 2024
1 parent 32b0553 commit d040470
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
license = "MIT"
name = "pyrobbot"
readme = "README.md"
version = "0.7.1"
version = "0.7.2"

[build-system]
build-backend = "poetry.core.masonry.api"
Expand Down
16 changes: 8 additions & 8 deletions pyrobbot/voice_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@
with contextlib.suppress(pydub.exceptions.CouldntDecodeError):
AudioSegment.from_mp3(io.BytesIO())
except (ImportError, OSError, FileNotFoundError) as error:
logger.error(
"{}. Can't use module `pydub`. Please check your system's ffmpeg install.", error
)
_pydub_imported = False
logger.exception(error)
logger.error("Can't use module `pydub`. Please check your system's ffmpeg install.")
_pydub_usable = False
else:
_pydub_imported = True
_pydub_usable = True


class VoiceChat(Chat):
Expand Down Expand Up @@ -520,9 +519,10 @@ def _check_needed_imports():
"Module `sounddevice`, needed for local audio recording, is not available."
)

if not _pydub_imported:
raise ImportError(
"Module `pydub`, needed for audio conversion, is not available."
if not _pydub_usable:
logger.error(
"Module `pydub`, needed for audio conversion, doesn't seem to be working. "
"Voice chat may not be available or may not work as expected."
)


Expand Down

0 comments on commit d040470

Please sign in to comment.