Skip to content

Commit 8a8f7e3

Browse files
Warn, not raise error, if can't init pygame mixer
1 parent d040470 commit 8a8f7e3

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
license = "MIT"
55
name = "pyrobbot"
66
readme = "README.md"
7-
version = "0.7.2"
7+
version = "0.7.3"
88

99
[build-system]
1010
build-backend = "poetry.core.masonry.api"

pyrobbot/voice_chat.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,16 @@ def __init__(self, configs: VoiceChatConfigs = default_configs, **kwargs):
5858
self.block_size = int((self.sample_rate * self.frame_duration) / 1000)
5959

6060
self.mixer = pygame.mixer
61-
self.mixer.init(frequency=self.sample_rate, channels=1, buffer=self.block_size)
61+
try:
62+
self.mixer.init(
63+
frequency=self.sample_rate, channels=1, buffer=self.block_size
64+
)
65+
except pygame.error as error:
66+
logger.exception(error)
67+
logger.error(
68+
"Can't initialize the mixer. Please check your system's audio settings."
69+
)
70+
logger.warning("Voice chat may not be available or may not work as expected.")
6271

6372
self.vad = webrtcvad.Vad(2)
6473

0 commit comments

Comments
 (0)