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

feat/console_scripts #105

Merged
merged 2 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions ovos_utils/scripts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env python3
# each method here is a console_script defined in setup.py
# each corresponds to a cli util
from mycroft_bus_client import MessageBusClient, Message
from ovos_config import Configuration
import sys


def ovos_speak():
if (args_count := len(sys.argv)) == 2:
utt = sys.argv[1]
lang = Configuration().get("lang", "en-us")
elif args_count == 3:
utt = sys.argv[1]
lang = sys.argv[2]
else:
print("USAGE: ovos-speak {utterance} [lang]")
raise SystemExit(2)
client = MessageBusClient()
client.run_in_thread()
client.emit(Message("speak", {"utterance": utt, "lang": lang}))
client.close()


def ovos_say_to():
if (args_count := len(sys.argv)) == 2:
utt = sys.argv[1]
lang = Configuration().get("lang", "en-us")
elif args_count == 3:
utt = sys.argv[1]
lang = sys.argv[2]
else:
print("USAGE: ovos-say-to {utterance} [lang]")
raise SystemExit(2)
client = MessageBusClient()
client.run_in_thread()
client.emit(Message("recognizer_loop:utterance", {"utterances": [utt], "lang": lang}))
client.close()


def ovos_listen():
client = MessageBusClient()
client.run_in_thread()
client.emit(Message("mycroft.mic.listen"))
client.close()
9 changes: 8 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,12 @@ def required(requirements_file):
license='Apache',
author='jarbasAI',
author_email='[email protected]',
description='collection of simple utilities for use across the mycroft ecosystem'
description='collection of simple utilities for use across the mycroft ecosystem',
entry_points={
'console_scripts': [
'ovos-listen=ovos_utils.scripts:ovos_listen',
'ovos-speak=ovos_utils.scripts:ovos_speak',
'ovos-say-to=ovos_utils.scripts:ovos_say_to',
]
}
)