Desmond-Dong commited on
Commit
45977a5
·
1 Parent(s): a5465eb

fix: Sendspin PLAYER角色需要player_support参数

Browse files

- 添加ClientHelloPlayerSupport配置
- 支持多种PCM格式(48kHz/44.1kHz/16kHz, mono/stereo)
- 支持音量和静音控制命令

reachy_mini_ha_voice/audio_player.py CHANGED
@@ -23,7 +23,8 @@ _LOGGER = logging.getLogger(__name__)
23
  # Check if aiosendspin is available
24
  try:
25
  from aiosendspin.client import SendspinClient, PCMFormat
26
- from aiosendspin.models.types import Roles
 
27
  from aiosendspin.models.core import StreamStartMessage
28
  SENDSPIN_AVAILABLE = True
29
  except ImportError:
@@ -202,10 +203,34 @@ class AudioPlayer:
202
 
203
  try:
204
  # Use stable client_id so HA recognizes the same device after restart
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
205
  self._sendspin_client = SendspinClient(
206
  client_id=self._sendspin_client_id,
207
  client_name="Reachy Mini",
208
  roles=[Roles.PLAYER], # PLAYER role to receive audio
 
209
  )
210
 
211
  await self._sendspin_client.connect(server_url)
 
23
  # Check if aiosendspin is available
24
  try:
25
  from aiosendspin.client import SendspinClient, PCMFormat
26
+ from aiosendspin.models.types import Roles, AudioCodec, PlayerCommand
27
+ from aiosendspin.models.player import ClientHelloPlayerSupport, SupportedAudioFormat
28
  from aiosendspin.models.core import StreamStartMessage
29
  SENDSPIN_AVAILABLE = True
30
  except ImportError:
 
203
 
204
  try:
205
  # Use stable client_id so HA recognizes the same device after restart
206
+ # Configure player support with common audio formats
207
+ player_support = ClientHelloPlayerSupport(
208
+ supported_formats=[
209
+ SupportedAudioFormat(
210
+ codec=AudioCodec.PCM, channels=2, sample_rate=48000, bit_depth=16
211
+ ),
212
+ SupportedAudioFormat(
213
+ codec=AudioCodec.PCM, channels=2, sample_rate=44100, bit_depth=16
214
+ ),
215
+ SupportedAudioFormat(
216
+ codec=AudioCodec.PCM, channels=1, sample_rate=48000, bit_depth=16
217
+ ),
218
+ SupportedAudioFormat(
219
+ codec=AudioCodec.PCM, channels=1, sample_rate=44100, bit_depth=16
220
+ ),
221
+ SupportedAudioFormat(
222
+ codec=AudioCodec.PCM, channels=1, sample_rate=16000, bit_depth=16
223
+ ),
224
+ ],
225
+ buffer_capacity=32_000_000,
226
+ supported_commands=[PlayerCommand.VOLUME, PlayerCommand.MUTE],
227
+ )
228
+
229
  self._sendspin_client = SendspinClient(
230
  client_id=self._sendspin_client_id,
231
  client_name="Reachy Mini",
232
  roles=[Roles.PLAYER], # PLAYER role to receive audio
233
+ player_support=player_support,
234
  )
235
 
236
  await self._sendspin_client.connect(server_url)