Skip to content

Commit

Permalink
docstrs
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Oct 17, 2023
1 parent 706eb90 commit 9816b19
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ovos_audio/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand All @@ -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)

Expand Down

0 comments on commit 9816b19

Please sign in to comment.