Skip to content

Commit

Permalink
fix:save utterances (#148)
Browse files Browse the repository at this point in the history
* fix:save utterances

backwards compat check wasnt quite right in #140

```
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]: 2024-10-19 08:04:47.463 - voice - ovos_dinkum_listener.service:_stt_audio:747 - ERROR - Error while saving STT audio
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]: Traceback (most recent call last):
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:   File "/home/goldyfruit/.venvs/ovos/lib64/python3.11/site-packages/ovos_dinkum_listener/service.py", line 742, in _stt_audio
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:     stt_context["filename"] = self._save_stt(audio_bytes, stt_context)
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:   File "/home/goldyfruit/.venvs/ovos/lib64/python3.11/site-packages/ovos_dinkum_listener/service.py", line 707, in _save_stt
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:     filename = formatter.format(utterance_filename)
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:   File "/home/goldyfruit/.venvs/ovos/lib64/python3.11/site-packages/ovos_dinkum_listener/_util.py", line 107, in format
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:     fmtkw = self._build_fmtkw(template, **kwargs)
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:   File "/home/goldyfruit/.venvs/ovos/lib64/python3.11/site-packages/ovos_dinkum_listener/_util.py", line 91, in _build_fmtkw
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:     fmtkw[key] = builder()
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:                  ^^^^^^^^^
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:   File "/home/goldyfruit/.venvs/ovos/lib64/python3.11/site-packages/ovos_dinkum_listener/service.py", line 705, in transcription_md5
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:     return hash_sentence(text)
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:            ^^^^^^^^^^^^^^^^^^^
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:   File "/home/goldyfruit/.venvs/ovos/lib64/python3.11/site-packages/ovos_plugin_manager/utils/tts_cache.py", line 20, in hash_sentence
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:     encoded_sentence = sentence.encode("utf-8", "ignore")
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]:                        ^^^^^^^^^^^^^^^
Oct 19 08:04:47 x270.home.lan ovos-dinkum-listener[152114]: AttributeError: 'NoneType' object has no attribute 'encode'

```

also needs OpenVoiceOS/ovos-config#171

* Update requirements.txt
  • Loading branch information
JarbasAl authored Oct 19, 2024
1 parent 9398f1d commit ab3c967
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions ovos_dinkum_listener/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,16 +692,14 @@ def _save_stt(self, audio_bytes, stt_meta, save_path=None):
@formatter.register('md5')
def transcription_md5():
# Build a hash of the transcription

try:
# handles legacy API
text = stt_meta.get('transcription')
except KeyError:
# handles new API
# transcriptions should be : List[Tuple[str, int]]
try:
text = stt_meta.get('transcriptions')[0][0]
except IndexError:
return 'null'
text = stt_meta.get('transcriptions')[0][0]
except IndexError:
# handles legacy API
return stt_meta.get('transcription') or 'null'

return hash_sentence(text)

filename = formatter.format(utterance_filename)
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ovos-plugin-manager>=0.3.1,<1.0.0
ovos-utils>=0.0.38,<1.0.0
ovos-config>=0.2.1,<1.0.0
ovos-config>=0.4.3,<1.0.0
ovos_bus_client>=0.0.10,<1.0.0
SpeechRecognition~=3.9

0 comments on commit ab3c967

Please sign in to comment.