Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix STT and TTS configuration handling #187

Merged
merged 7 commits into from
Oct 25, 2023
Merged

Conversation

NeonDaniel
Copy link
Member

@NeonDaniel NeonDaniel commented Oct 12, 2023

Fix STT and TTS config handling to pass parsed plugin config to plugin init
Closes #132

The get_plugin_config method is intended to load a complete configuration dict for a plugin where plugin-specific config takes the highest priority, then plugin class config (i.e. 'stt', 'tts'), and then global config (i.e. Configuration()['lang'])

@NeonDaniel NeonDaniel requested review from mikejgray and a team October 12, 2023 22:13
@codecov
Copy link

codecov bot commented Oct 12, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (dev@0063ba6). Click here to learn what that means.

Additional details and impacted files
@@          Coverage Diff          @@
##             dev    #187   +/-   ##
=====================================
  Coverage       ?   0.00%           
=====================================
  Files          ?      57           
  Lines          ?    3946           
  Branches       ?       0           
=====================================
  Hits           ?       0           
  Misses         ?    3946           
  Partials       ?       0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mikejgray
Copy link
Contributor

With this config:

{
  "play_wav_cmdline": "paplay %1",
  "play_mp3_cmdline": "paplay %1",
  "time_format": "half",
  "system_unit": "imperial",
  "lang": "de-de",
  "tts": {
    "module": "ovos_tts_plugin_espeakng",
    "ovos_tts_plugin_espeakng": {
      "lang": "de-de",
      "voice": "german-mbrola-5",
      "speed": "135",
      "amplitude": "80",
      "pitch": "20"
    }
  }
}

I receive these errors, and TTS fails to load:

2023-10-13 14:53:56.447 - ovos-launcher - ovos_plugin_manager.tts:create:197 - INFO - Found plugin ovos_tts_plugin_espeakng
2023-10-13 14:53:56.465 - ovos-launcher - ovos_plugin_manager.tts:create:206 - ERROR - The TTS plugin "ovos_tts_plugin_espeakng" could not be loaded.
Available modules: ovos-tts-plugin-mimic3-server,ovos-tts-plugin-mimic,ovos-tts-plugin-server,ovos-tts-plugin-dummy,ovos_tts_plugin_espeakng
Traceback (most recent call last):
  File "/home/mike/ovos-launcher/.venv/lib/python3.10/site-packages/ovos_plugin_manager/tts.py", line 198, in create
    tts = clazz(tts_lang, tts_config)
  File "/home/mike/ovos-launcher/.venv/lib/python3.10/site-packages/ovos_tts_plugin_espeakng/__init__.py", line 12, in __init__
    super().__init__(*args, **kwargs,
TypeError: TTS.__init__() got multiple values for argument 'lang'
2023-10-13 14:53:56.466 - ovos-launcher - ovos_audio.service:__init__:82 - ERROR - TTS.__init__() got multiple values for argument 'lang'
Traceback (most recent call last):
  File "/home/mike/ovos-launcher/.venv/lib/python3.10/site-packages/ovos_audio/service.py", line 79, in __init__
    self._maybe_reload_tts()
  File "/home/mike/ovos-launcher/.venv/lib/python3.10/site-packages/ovos_audio/service.py", line 295, in _maybe_reload_tts
    self.tts = TTSFactory.create(config)
  File "/home/mike/ovos-launcher/.venv/lib/python3.10/site-packages/ovos_audio/tts.py", line 9, in create
    return OVOSTTSFactory.create(config)
  File "/home/mike/ovos-launcher/.venv/lib/python3.10/site-packages/ovos_plugin_manager/tts.py", line 198, in create
    tts = clazz(tts_lang, tts_config)
  File "/home/mike/ovos-launcher/.venv/lib/python3.10/site-packages/ovos_tts_plugin_espeakng/__init__.py", line 12, in __init__
    super().__init__(*args, **kwargs,
TypeError: TTS.__init__() got multiple values for argument 'lang'
2023-10-13 14:53:56.467 - ovos-launcher - ovos_audio.service:on_error:38 - ERROR - Audio service failed to launch (TTS.__init__() got multiple values for argument 'lang').
2023-10-13 14:53:56.482 - ovos-launcher - ovos_plugin_manager.templates.tts:add_metric:520 - ERROR - 'EspeakNGTTS' object has no attribute 'log_timestamps'
Traceback (most recent call last):
  File "/home/mike/ovos-launcher/.venv/lib/python3.10/site-packages/ovos_plugin_manager/templates/tts.py", line 517, in add_metric
    if self.log_timestamps:
AttributeError: 'EspeakNGTTS' object has no attribute 'log_timestamps'

@mikejgray
Copy link
Contributor

The latest change appears to have broken it entirely. Here's what it looks like with various combinations of lang set to de-de:

TypeError: TTS.__init__() got multiple values for argument 'lang'
2023-10-13 22:58:21.420 - ovos-launcher - ovos_audio.service:__init__:82 - ERROR - TTS.__init__() got multiple values for argument 'lang'
Traceback (most recent call last):
  File "/home/mike/ovos-launcher/.venv/lib/python3.10/site-packages/ovos_audio/service.py", line 79, in __init__
    self._maybe_reload_tts()
  File "/home/mike/ovos-launcher/.venv/lib/python3.10/site-packages/ovos_audio/service.py", line 295, in _maybe_reload_tts
    self.tts = TTSFactory.create(config)
  File "/home/mike/ovos-launcher/.venv/lib/python3.10/site-packages/ovos_audio/tts.py", line 9, in create
    return OVOSTTSFactory.create(config)
  File "/home/mike/ovos-launcher/.venv/lib/python3.10/site-packages/ovos_plugin_manager/tts.py", line 197, in create
    tts = clazz(None,  # don't pass lang and force read from config
  File "/home/mike/ovos-launcher/.venv/lib/python3.10/site-packages/ovos_tts_plugin_espeakng/__init__.py", line 12, in __init__
    super().__init__(*args, **kwargs,
TypeError: TTS.__init__() got multiple values for argument 'lang'
2023-10-13 22:58:21.422 - ovos-launcher - ovos_audio.service:on_error:38 - ERROR - Audio service failed to launch (TTS.__init__() got multiple values for argument 'lang').
2023-10-13 22:58:21.431 - ovos-launcher - ovos_plugin_manager.templates.tts:add_metric:275 - ERROR - 'EspeakNGTTS' object has no attribute 'log_timestamps'
Traceback (most recent call last):
  File "/home/mike/ovos-launcher/.venv/lib/python3.10/site-packages/ovos_plugin_manager/templates/tts.py", line 272, in add_metric
    if self.log_timestamps:
AttributeError: 'EspeakNGTTS' object has no attribute 'log_timestamps'

And here's with the ovos-launcher default TTS and lang set to en-us:

2023-10-13 23:06:02.758 - ovos-launcher - ovos_plugin_manager.templates.tts:init:317 - WARNING - PlaybackThread should be inited by ovos-audio, initing via plugin has been deprecated, please pass playback=PlaybackThread() to TTS.init
2023-10-13 23:06:02.759 - ovos-launcher - ovos_plugin_manager.templates.tts:__new__:62 - WARNING - PlaybackThread moved to ovos_audio.playback
2023-10-13 23:06:02.760 - ovos-launcher - ovos_audio.service:__init__:82 - ERROR - please install ovos-audio for playback handling
Traceback (most recent call last):
  File "/home/mike/ovos-launcher/.venv/lib/python3.10/site-packages/ovos_plugin_manager/templates/tts.py", line 64, in __new__
    from ovos_audio.playback import PlaybackThread
ModuleNotFoundError: No module named 'ovos_audio.playback'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mike/ovos-launcher/.venv/lib/python3.10/site-packages/ovos_audio/service.py", line 79, in __init__
    self._maybe_reload_tts()
  File "/home/mike/ovos-launcher/.venv/lib/python3.10/site-packages/ovos_audio/service.py", line 296, in _maybe_reload_tts
    self.tts.init(self.bus)
  File "/home/mike/ovos-launcher/.venv/lib/python3.10/site-packages/ovos_plugin_manager/templates/tts.py", line 321, in init
    playback = PlaybackThread(TTS.queue, self.bus)  # compat
  File "/home/mike/ovos-launcher/.venv/lib/python3.10/site-packages/ovos_plugin_manager/templates/tts.py", line 67, in __new__
    raise ImportError("please install ovos-audio for playback handling")
ImportError: please install ovos-audio for playback handling
2023-10-13 23:06:02.762 - ovos-launcher - ovos_audio.service:on_error:38 - ERROR - Audio service failed to launch (please install ovos-audio for playback handling).

@mikejgray
Copy link
Contributor

Jarbas pointed out I had some version mismatches with ovos-audio, but even after resolving some:

2023-10-13 23:27:41.562 - ovos-launcher - ovos_plugin_manager.tts:create:206 - ERROR - The TTS plugin "ovos-tts-plugin-mimic3-server" could not be loaded.
Available modules: ovos-tts-plugin-mimic3-server,ovos-tts-plugin-mimic,ovos-tts-plugin-dummy,ovos-tts-plugin-server,ovos_tts_plugin_espeakng
Traceback (most recent call last):
  File "/home/mike/ovos-launcher/.venv/lib/python3.10/site-packages/ovos_plugin_manager/tts.py", line 197, in create
    tts = clazz(None,  # don't pass lang and force read from config
  File "/home/mike/ovos-launcher/.venv/lib/python3.10/site-packages/ovos_tts_plugin_mimic3_server/__init__.py", line 52, in __init__
    lang = lang.split("-")[0]
AttributeError: 'NoneType' object has no attribute 'split'
2023-10-13 23:27:41.563 - ovos-launcher - ovos_audio.service:__init__:88 - ERROR - 'NoneType' object has no attribute 'split'
Traceback (most recent call last):
  File "/home/mike/ovos-launcher/.venv/lib/python3.10/site-packages/ovos_audio/service.py", line 85, in __init__
    self._maybe_reload_tts()
  File "/home/mike/ovos-launcher/.venv/lib/python3.10/site-packages/ovos_audio/service.py", line 332, in _maybe_reload_tts
    self._get_tts_fallback()
  File "/home/mike/ovos-launcher/.venv/lib/python3.10/site-packages/ovos_audio/service.py", line 360, in _get_tts_fallback
    self.fallback_tts = TTSFactory.create(cfg)
  File "/home/mike/ovos-launcher/.venv/lib/python3.10/site-packages/ovos_audio/tts.py", line 9, in create
    return OVOSTTSFactory.create(config)
  File "/home/mike/ovos-launcher/.venv/lib/python3.10/site-packages/ovos_plugin_manager/tts.py", line 197, in create
    tts = clazz(None,  # don't pass lang and force read from config
  File "/home/mike/ovos-launcher/.venv/lib/python3.10/site-packages/ovos_tts_plugin_mimic3_server/__init__.py", line 52, in __init__
    lang = lang.split("-")[0]
AttributeError: 'NoneType' object has no attribute 'split'
2023-10-13 23:27:41.564 - ovos-launcher - ovos_audio.service:on_error:39 - ERROR - Audio service failed to launch ('NoneType' object has no attribute 'split').
2023-10-13 23:27:41.572 - ovos-launcher - ovos_plugin_manager.templates.tts:add_metric:275 - ERROR - 'Mimic3ServerTTSPlugin' object has no attribute 'log_timestamps'
Traceback (most recent call last):
  File "/home/mike/ovos-launcher/.venv/lib/python3.10/site-packages/ovos_plugin_manager/templates/tts.py", line 272, in add_metric
    if self.log_timestamps:
AttributeError: 'Mimic3ServerTTSPlugin' object has no attribute 'log_timestamps'

This is with default config, latest alphas of everything I could (some packages were forcing older versions and I had to push them forward manually)

@NeonDaniel
Copy link
Member Author

Interesting.. it appears there's something wrong with lang handling still that's causing this; I'll see if I can reproduce this behavior in a unit test and fix it

@JarbasAl JarbasAl added the bug Something isn't working label Oct 18, 2023
@NeonDaniel NeonDaniel requested a review from JarbasAl October 21, 2023 01:31
@mikejgray
Copy link
Contributor

I did a spot check and I think this fixed the issue, but I'll do some additional testing and come back with logs to confirm

Copy link
Contributor

@mikejgray mikejgray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2023-10-24 22:22:31.234 - audio - ovos_plugin_manager.tts:create:209 - INFO - Loaded plugin ovos_tts_plugin_espeakng

@NeonDaniel NeonDaniel force-pushed the FIX_SttTtsPluginConfig branch from a78d58f to 1b99cf2 Compare October 25, 2023 18:27
@JarbasAl JarbasAl merged commit 74a6045 into dev Oct 25, 2023
@JarbasAl JarbasAl deleted the FIX_SttTtsPluginConfig branch October 25, 2023 18:29
@github-actions github-actions bot mentioned this pull request Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

STT class init with wrong config
3 participants