Skip to content

Commit

Permalink
Merge pull request #110 from OpenVoiceOS/release-0.3.0a1
Browse files Browse the repository at this point in the history
Release 0.3.0a1
  • Loading branch information
JarbasAl authored Oct 23, 2024
2 parents 248b0aa + 4f602b0 commit 01b7603
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 35 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Changelog

## [0.2.5a1](https://github.com/OpenVoiceOS/ovos-audio/tree/0.2.5a1) (2024-10-23)
## [0.3.0a1](https://github.com/OpenVoiceOS/ovos-audio/tree/0.3.0a1) (2024-10-23)

[Full Changelog](https://github.com/OpenVoiceOS/ovos-audio/compare/0.2.4...0.2.5a1)
[Full Changelog](https://github.com/OpenVoiceOS/ovos-audio/compare/0.2.5...0.3.0a1)

**Merged pull requests:**

- fix:b64 improvements [\#107](https://github.com/OpenVoiceOS/ovos-audio/pull/107) ([JarbasAl](https://github.com/JarbasAl))
- feat:g2p [\#109](https://github.com/OpenVoiceOS/ovos-audio/pull/109) ([JarbasAl](https://github.com/JarbasAl))



Expand Down
51 changes: 25 additions & 26 deletions ovos_audio/playback.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import random
from queue import Empty
from threading import Thread, Event
from typing import Optional

from ovos_audio.transformers import TTSTransformersService
from ovos_bus_client.message import Message
from ovos_bus_client.util import get_message_lang
from ovos_config import Configuration
from ovos_plugin_manager.g2p import OVOSG2PFactory
from ovos_plugin_manager.templates.g2p import OutOfVocabulary, Grapheme2PhonemePlugin
from ovos_plugin_manager.templates.tts import TTS
from ovos_utils.log import LOG, log_deprecation
from ovos_utils.sound import play_audio
from queue import Empty
from threading import Thread, Event
from time import time


Expand All @@ -27,6 +32,13 @@ def __init__(self, queue=TTS.queue, bus=None):
self._now_playing = None
self._started = Event()
self.tts_transform = TTSTransformersService(self.bus)
self.g2p = None
if Configuration().get("g2p", {}).get("module"):
LOG.debug("Loading Grapheme2Phoneme plugin for mouth movements")
try:
self.g2p: Optional[Grapheme2PhonemePlugin] = OVOSG2PFactory.create()
except: # not mission critical
pass

@property
def is_running(self):
Expand Down Expand Up @@ -117,6 +129,16 @@ def _play(self):
data, message.context = self.tts_transform.transform(data, message.context)

self.p = play_audio(data)

if not visemes and self.g2p is not None:
try:
visemes = self.g2p.utterance2visemes(message.data["utterance"],
get_message_lang(message))
except OutOfVocabulary:
pass
except:
# this one is unplanned, let devs know all the info so they can fix it
LOG.exception(f"Unexpected failure in G2P plugin: {self.g2p}")
if visemes:
self.show_visemes(visemes)
if self.p:
Expand Down Expand Up @@ -155,30 +177,7 @@ def run(self, cb=None):
while not self._terminated:
self._do_playback.wait()
try:
# HACK: we do these check to account for direct usages of TTS.queue singletons
speech_data = self.queue.get(timeout=2)
if len(speech_data) == 5 and isinstance(speech_data[-1], Message):
data, visemes, listen, tts_id, message = speech_data
else:
log_deprecation(
"Direct modification of TTS.queue is not recommended!\n"
"expected=(data, visemes, listen, tts_id, message)",
"0.1.0")
if len(speech_data) == 6:
# old ovos backwards compat
_, data, visemes, ident, listen, tts_id = speech_data
elif len(speech_data) == 5:
# mycroft style
tts_id = None
_, data, visemes, ident, listen = speech_data
else:
# old mycroft style TODO can this be deprecated? its very very old
listen = False
tts_id = None
_, data, visemes, ident = speech_data

message = Message("speak", context={"session": {"session_id": ident}})

data, visemes, listen, tts_id, message = self.queue.get(timeout=2)
self._now_playing = (data, visemes, listen, tts_id, message)
self._play()
except Empty:
Expand Down
6 changes: 3 additions & 3 deletions ovos_audio/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,9 +577,9 @@ def shutdown(self):
Stop any playing audio and make sure threads are joined correctly.
"""
self.status.set_stopping()
if self.tts.playback:
self.tts.playback.shutdown()
self.tts.playback.join()
if self.playback_thread:
self.playback_thread.shutdown()
self.playback_thread.join()
if self.audio:
self.audio.shutdown()

Expand Down
6 changes: 3 additions & 3 deletions ovos_audio/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# START_VERSION_BLOCK
VERSION_MAJOR = 0
VERSION_MINOR = 2
VERSION_BUILD = 5
VERSION_ALPHA = 0
VERSION_MINOR = 3
VERSION_BUILD = 0
VERSION_ALPHA = 1
# END_VERSION_BLOCK

0 comments on commit 01b7603

Please sign in to comment.