Skip to content
This repository was archived by the owner on Oct 19, 2023. It is now read-only.

Updated buf to use tobytes() as tostring() is deprecated #421

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import time
import threading
import wave
import sys

import click
import sounddevice as sd
Expand Down Expand Up @@ -54,7 +55,8 @@ def normalize_audio_buffer(buf, volume_percentage, sample_width=2):
arr = array.array('h', buf)
for idx in range(0, len(arr)):
arr[idx] = int(arr[idx]*scale)
buf = arr.tostring()
# for python >= 3.2 use 'tobytes', otherwise 'tostring'
buf = arr.tobytes() if sys.version_info[0] >= 3 and sys.version_info[1] >= 2 else arr.tostring()
return buf


Expand Down