Skip to content

Commit

Permalink
Troubleshoot performance on Pi4/Mark2
Browse files Browse the repository at this point in the history
Handle case-sensitive transcriptions
  • Loading branch information
NeonDaniel committed Oct 10, 2023
1 parent 973f05e commit 038a961
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions neon_minerva/integration/user_utterance.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from tempfile import mkstemp
from threading import Event, Lock
from time import time
Expand All @@ -32,7 +33,7 @@
from ovos_utils.log import LOG
from ovos_bus_client.client import MessageBusClient
from ovos_bus_client.message import Message
from ovos_plugin_manager.tts import OVOSTTSFactory, TTS
from ovos_plugin_manager.tts import TTS


class UtteranceTests:
Expand All @@ -49,7 +50,7 @@ def __init__(self, prompts: List[str], lang: str = "en-us",
self.core_bus.run_in_thread()
self.lang = lang
self.test_audio = audio
self._tts = tts or OVOSTTSFactory.create() if audio else None
self._tts = tts
# TODO: Handle prompt metadata for longer timeouts
self._prompts = prompts
self._stt_timeout = 60
Expand Down Expand Up @@ -151,15 +152,24 @@ def send_prompt(self, prompt: str):
"username": "minerva",
"user_profiles": [self._user_config]}
if self.test_audio:
_, file_path = mkstemp()
audio, _ = self._tts.get_tts(prompt, file_path, lang=self.lang)
if self._tts:
_, file_path = mkstemp()
audio, _ = self._tts.get_tts(prompt, file_path, lang=self.lang)
else:
resp = self.core_bus.wait_for_response(
Message("neon.get_tts", {'text': prompt,
'speaker': {'language': self.lang,
'gender': 'female'}}),
timeout=self._stt_timeout)
file_path = resp.data[self.lang]['female']
resp = self.core_bus.wait_for_response(
Message("neon.audio_input",
{"audio_data": encode_file_to_base64_string(file_path),
"lang": self.lang}, context),
timeout=self._stt_timeout)
LOG.info(resp.data)
if prompt not in resp.data['transcripts']:
if prompt.lower() not in (t.lower() for t
in resp.data['transcripts']):
LOG.warning(f"Invalid transcription for '{prompt}': "
f"{resp.data['transcripts']}")
else:
Expand Down

0 comments on commit 038a961

Please sign in to comment.