Skip to content

Commit

Permalink
python : accept bytes as input to encode (#127)
Browse files Browse the repository at this point in the history
Co-authored-by: deniz <[email protected]>
  • Loading branch information
denizsincar29 and deniz authored Nov 16, 2024
1 parent e2b650f commit 2bf3d67
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bindings/python/ggwave.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ def encode(payload, protocolId = 1, volume = 10, instance = None):
@return Generated audio waveform bytes representing 16-bit signed integer samples.
"""

cdef bytes data_bytes = payload.encode()
if isinstance(payload, str):
payload = payload.encode('utf-8')
cdef bytes data_bytes = payload

cdef char* cdata = data_bytes

own = False
Expand Down

0 comments on commit 2bf3d67

Please sign in to comment.