Skip to content

Commit

Permalink
feat/move to ovos-lang-detector-classics-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Feb 23, 2024
1 parent e94f420 commit be7228a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 3 additions & 1 deletion readme.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ optional arguments:

```

eg, to use the [Google Translate plugin](https://github.com/NeonGeckoCom/neon-lang-plugin-google_translate) `ovos-translate-server --tx-engine googletranslate_plug --detect-engine googletranslate_detection_plug`
eg, to use the [NLLB plugin](https://github.com/OpenVoiceOS/ovos-translate-plugin-nllb) for translation, and [Lang Classifier Classics](https://github.com/OpenVoiceOS/ovos-lang-detector-classics-plugin) for detection

`ovos-translate-server --tx-engine ovos-translate-plugin-nllb --detect-engine ovos-lang-detector-classics-plugin`

then you can do get requests

Expand Down
12 changes: 8 additions & 4 deletions ovos_translate_server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ def start_translate_server(tx_engine, detect_engine=None, port=9686, host="0.0.0
cfg = Configuration().get("language", {})

# load ovos lang translate plugin
if not tx_engine:
raise ValueError("tx_engine not set, please provide a plugin, eg.")
engine = load_tx_plugin(tx_engine)
if engine is None:
raise ImportError(f"{tx_engine} failed to load, is it installed?")
TX = engine(config=cfg.get(tx_engine, {}))
TX.plugin_name = tx_engine

Expand All @@ -68,10 +72,10 @@ def start_translate_server(tx_engine, detect_engine=None, port=9686, host="0.0.0
DETECT = engine(config=cfg.get(detect_engine, {}))
DETECT.plugin_name = detect_engine
else:
LOG.warning("lang detection plugin not set, falling back to lingua-podre")
from lingua_podre.opm import LinguaPodrePlugin
DETECT = LinguaPodrePlugin(config=cfg.get("ovos-lang-detector-plugin-lingua-podre", {}))
DETECT.plugin_name = "ovos-lang-detector-plugin-lingua-podre"
LOG.warning("lang detection plugin not set, falling back to ovos-lang-detector-classics-plugin")
from ovos_lang_detector_classics_plugin import VotingLangDetectPlugin
DETECT = VotingLangDetectPlugin(config=cfg.get("ovos-lang-detector-classics-plugin", {}))
DETECT.plugin_name = "ovos-lang-detector-classics-plugin"

app = create_app()
app.run(port=port, use_reloader=False, host=host)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
flask
ovos-plugin-manager
lingua-podre>=0.0.3
ovos-lang-detector-classics-plugin

0 comments on commit be7228a

Please sign in to comment.