MCPcopy Create free account
hub / github.com/ARM-software/AVH / _configureStream

Method _configureStream

interface/vstream/python/vsi_audio_server.py:224–251  ·  view source on GitHub ↗

Configure the audio stream parameters. Args: channels: The number of audio channels (1=mono, 2=stereo). sample_rate: The sample rate in Hz (8000, 16000, 44100, 48000). sample_bits: The bit depth (8, 16, 24, 32). Returns: confi

(self, channels, sample_rate, sample_bits)

Source from the content-addressed store, hash-verified

222 return filename_valid
223
224 def _configureStream(self, channels, sample_rate, sample_bits):
225 """
226 Configure the audio stream parameters.
227
228 Args:
229 channels: The number of audio channels (1=mono, 2=stereo).
230 sample_rate: The sample rate in Hz (8000, 16000, 44100, 48000).
231 sample_bits: The bit depth (8, 16, 24, 32).
232 Returns:
233 configuration_valid: True if the configuration is valid and set, False otherwise.
234 """
235 logger.debug(f"_configureStream: channels={channels}, sample_rate={sample_rate}, sample_bits={sample_bits}")
236
237 if channels <= 0 or sample_rate <= 0 or sample_bits <= 0:
238 logger.error(f"_configureStream: invalid argument (channels={channels}, sample_rate={sample_rate}, sample_bits={sample_bits})")
239 return False
240
241 if sample_bits not in [8, 16, 24, 32]:
242 logger.error(f"_configureStream: unsupported sample_bits={sample_bits}")
243 return False
244
245 self.channels = channels
246 self.sample_rate = sample_rate
247 self.sample_bits = sample_bits
248
249 logger.info(f"_configureStream: stream configured to {self.channels} channels, {self.sample_rate}Hz, {self.sample_bits} bits")
250
251 return True
252
253 def _get_pyaudio_format(self):
254 """Get PyAudio format based on sample bits."""

Callers 1

runMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected