From 2bf3d677bc5ddedcd4f444eedbab9ce4e2dded31 Mon Sep 17 00:00:00 2001 From: Deniz Sincar <46639905+denizsincar29@users.noreply.github.com> Date: Sat, 16 Nov 2024 23:49:48 +0300 Subject: [PATCH] python : accept bytes as input to encode (#127) Co-authored-by: deniz --- bindings/python/ggwave.pyx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bindings/python/ggwave.pyx b/bindings/python/ggwave.pyx index 39aa371..a9df2ff 100644 --- a/bindings/python/ggwave.pyx +++ b/bindings/python/ggwave.pyx @@ -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