Skip to content

Commit

Permalink
Warn, not raise error, if can't init pygame mixer
Browse files Browse the repository at this point in the history
  • Loading branch information
paulovcmedeiros committed Mar 3, 2024
1 parent d040470 commit 8a8f7e3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 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.2"
version = "0.7.3"

[build-system]
build-backend = "poetry.core.masonry.api"
Expand Down
11 changes: 10 additions & 1 deletion pyrobbot/voice_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,16 @@ def __init__(self, configs: VoiceChatConfigs = default_configs, **kwargs):
self.block_size = int((self.sample_rate * self.frame_duration) / 1000)

self.mixer = pygame.mixer
self.mixer.init(frequency=self.sample_rate, channels=1, buffer=self.block_size)
try:
self.mixer.init(
frequency=self.sample_rate, channels=1, buffer=self.block_size
)
except pygame.error as error:
logger.exception(error)
logger.error(
"Can't initialize the mixer. Please check your system's audio settings."
)
logger.warning("Voice chat may not be available or may not work as expected.")

self.vad = webrtcvad.Vad(2)

Expand Down

0 comments on commit 8a8f7e3

Please sign in to comment.