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

Method _writeAudio

interface/vstream/python/vsi_audio_server.py:536–563  ·  view source on GitHub ↗

Write audio data to the output destination (file or speakers). Args: data: The input audio data as a bytearray to be written. Returns: None

(self, data)

Source from the content-addressed store, hash-verified

534 return audio_data
535
536 def _writeAudio(self, data):
537 """
538 Write audio data to the output destination (file or speakers).
539
540 Args:
541 data: The input audio data as a bytearray to be written.
542 Returns:
543 None
544 """
545 logger.debug(f"_writeAudio: audio data size={len(data)} bytes")
546
547 if not self.active:
548 logger.error("_writeAudio: stream not active")
549 return
550
551 try:
552 if self.filename == None:
553 # Write to speakers buffer
554 self.audio_buffer.extend(data)
555 logger.debug("_writeAudio: added data to speaker buffer")
556
557 else:
558 # Write to wave file
559 self.wave_file.writeframes(data)
560 logger.debug("_writeAudio: wrote data to file")
561
562 except Exception as e:
563 logger.error(f"_writeAudio: error writing audio data: {e}")
564
565 def run(self):
566 """

Callers 1

runMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected