From 9816b19a3d846984085d4ffbc73677022820920d Mon Sep 17 00:00:00 2001 From: JarbasAi Date: Tue, 17 Oct 2023 23:44:41 +0100 Subject: [PATCH] docstrs --- ovos_audio/service.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ovos_audio/service.py b/ovos_audio/service.py index b7589ff..86d2577 100644 --- a/ovos_audio/service.py +++ b/ovos_audio/service.py @@ -422,6 +422,11 @@ def _resolve_sound_uri(uri: str): @staticmethod def _path_from_hexdata(hex_audio, audio_ext=None): + """ hex_audio contains hex string encoded bytes + audio_ext if not provided assumed to be wav + + recommended encoding via binascii.hexlify(byte_data).decode('utf-8') + """ fname = md5(hex_audio.encode("utf-8")).hexdigest() bindata = binascii.unhexlify(hex_audio) if not audio_ext: @@ -448,7 +453,7 @@ def handle_queue_audio(self, message): audio_file = self._path_from_hexdata(hex_audio, audio_ext) if not audio_file: - raise ValueError(f"'uri' missing from message.data: {message.data}") + raise ValueError(f"message.data needs to provide 'uri' or 'binary_data': {message.data}") audio_file = self._resolve_sound_uri(audio_file) audio_ext = audio_ext or audio_file.split(".")[-1] listen = message.data.get("listen", False) @@ -467,7 +472,7 @@ def handle_instant_play(self, message): if hex_audio: audio_file = self._path_from_hexdata(hex_audio, audio_ext) if not audio_file: - raise ValueError(f"'uri' missing from message.data: {message.data}") + raise ValueError(f"message.data needs to provide 'uri' or 'binary_data': {message.data}") audio_file = self._resolve_sound_uri(audio_file) play_audio(audio_file)