Skip to content

Commit dee788a

Browse files
committed
prevent cutting off of first syllable
1 parent ae74156 commit dee788a

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

CHANGES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
0.1.1
2+
------
3+
- Keep 0.75s of data before speech starts to prevent cutting off of the first syllable
4+
15
0.1.0
26
------
37
- BREAKING INTERFACE CHANGES

auroraapi/audio.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from io import BytesIO
1010

1111
BUF_SIZE = (2 ** 10)
12-
SILENT_THRESH = (2 ** 10)
12+
SILENT_THRESH = (2 ** 11)
1313
NUM_CHANNELS = 1
1414
FORMAT = pyaudio.paInt16
1515
RATE = 16000
@@ -173,8 +173,15 @@ def _pyaudio_record(length, silence_len):
173173
)
174174

175175
data = array.array('h')
176-
while len(data) == 0 or _is_silent(data):
177-
data = array.array('h', stream.read(BUF_SIZE, exception_on_overflow=False))
176+
while True:
177+
d = array.array('h', stream.read(BUF_SIZE, exception_on_overflow=False))
178+
if not _is_silent(d):
179+
break
180+
data.extend(d)
181+
if len(data) > 12 * BUF_SIZE:
182+
data = data[BUF_SIZE:]
183+
184+
yield data
178185

179186
silent_for = 0
180187
bytes_read = 0

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# Versions should comply with PEP440. For a discussion on single-sourcing
1111
# the version across setup.py and the project code, see
1212
# https://packaging.python.org/en/latest/single_source_version.html
13-
version='0.1.0',
13+
version='0.1.1',
1414

1515
description='Python SDK for Aurora',
1616

0 commit comments

Comments
 (0)