Skip to content

Commit

Permalink
fix(voice): remove the gap between sentences
Browse files Browse the repository at this point in the history
  • Loading branch information
sassanh committed Aug 1, 2024
1 parent f5ee50e commit 17ae6ea
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 111 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Version 0.15.6

- fix(audio): add a recovery mechanism for audio service to rebind the sound card if it is not available - closes #83
- fix(voice): remove the gap between sentences

## Version 0.15.5

Expand Down
206 changes: 109 additions & 97 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ optional = true

[tool.poetry.group.dev.dependencies]
poethepoet = "^0.24.4"
pyright = "^1.1.372"
pyright = "^1.1.374"
pytest = "^8.0.0"
pytest-asyncio = "^0.23.5.post1"
pytest-cov = "^4.1.0"
pytest-timeout = "^2.3.1"
pytest-xdist = "^3.5.0"
ruff = "^0.5.3"
ruff = "^0.5.5"
tenacity = "^8.2.3"
toml = "^0.10.2"
pytest-mock = "^3.14.0"
Expand Down
8 changes: 4 additions & 4 deletions ubo_app/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ def render_on_display(

logger.verbose('Rendering frame', extra={'data_hash': data_hash})

data = data.astype(np.uint16)
data_ = data.astype(np.uint16)
color = (
((data[:, :, 0] & 0xF8) << 8)
| ((data[:, :, 1] & 0xFC) << 3)
| (data[:, :, 2] >> 3)
((data_[:, :, 0] & 0xF8) << 8)
| ((data_[:, :, 1] & 0xFC) << 3)
| (data_[:, :, 2] >> 3)
)
data_bytes = bytes(
np.dstack(((color >> 8) & 0xFF, color & 0xFF)).flatten().tolist(),
Expand Down
16 changes: 9 additions & 7 deletions ubo_app/services/010-voice/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,26 @@ def synthesize_and_play(event: VoiceSynthesizeTextEvent) -> None:
text = event.piper_text
if not _context.piper_voice:
return
id = hex(hash(text))
queue = Queue(maxsize=1)

if text in piper_cache:
source = piper_cache[text]
is_first_time = False
else:
source = _context.piper_voice.synthesize_stream_raw(text)

queue = Queue(maxsize=1)
queue.put(None)
piper_cache[text] = []
is_first_time = True

unsubscribe = subscribe_event(
AudioPlaybackDoneEvent,
lambda event: event.id == id and queue.get(),
)

piper_cache[text] = []
id = hex(hash(text))
for sample in source:
piper_cache[text].append(sample)
if is_first_time:
piper_cache[text].append(sample)
queue.put(None)
dispatch(
AudioPlayAudioAction(
id=id,
Expand All @@ -134,7 +137,6 @@ def synthesize_and_play(event: VoiceSynthesizeTextEvent) -> None:
width=2,
),
)
queue.put(None)
unsubscribe()
elif engine == 'orca':
with _context.orca_lock:
Expand Down
2 changes: 1 addition & 1 deletion ubo_app/store/update_manager/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async def check_version() -> None:
aiohttp.ClientSession() as session,
session.get(
'https://pypi.org/pypi/ubo-app/json',
timeout=5,
timeout=aiohttp.ClientTimeout(total=5),
) as response,
):
if response.status != requests.codes.ok:
Expand Down

0 comments on commit 17ae6ea

Please sign in to comment.