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

add simple_cli entrypoint #56

Merged
merged 4 commits into from
Oct 16, 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
43 changes: 43 additions & 0 deletions ovos_bus_client/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def ovos_speak():
raise SystemExit(2)
client = MessageBusClient()
client.run_in_thread()
if not client.connected_event.is_set():
client.connected_event.wait()
client.emit(Message("speak", {"utterance": utt, "lang": lang}))
client.close()

Expand All @@ -36,12 +38,53 @@ def ovos_say_to():
raise SystemExit(2)
client = MessageBusClient()
client.run_in_thread()
if not client.connected_event.is_set():
client.connected_event.wait()
client.emit(Message("recognizer_loop:utterance", {"utterances": [utt], "lang": lang}))
client.close()


def ovos_listen():
client = MessageBusClient()
client.run_in_thread()
if not client.connected_event.is_set():
client.connected_event.wait()
client.emit(Message("mycroft.mic.listen"))
client.close()


def simple_cli():
args_count = len(sys.argv)
if args_count == 1:
lang = Configuration().get("lang", "en-us")
elif args_count == 2:
lang = sys.argv[1]
else:
print("USAGE: ovos-simple-cli [lang]")
return

client = MessageBusClient()
client.run_in_thread()
if not client.connected_event.is_set():
client.connected_event.wait()
lang = lang or Configuration().get("lang", "en-us")

from ovos_bus_client.session import SessionManager, Session
sess = SessionManager.default_session

while True:
try:
utt = input("Say:")
if utt == ":exit":
break
client.emit(Message("recognizer_loop:utterance",
{"utterances": [utt], "lang": lang},
{"session": sess.serialize()}))
except KeyboardInterrupt:
break

client.close()


if __name__ == "__main__":
simple_cli()
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def get_version():
'ovos-listen=ovos_bus_client.scripts:ovos_listen',
'ovos-speak=ovos_bus_client.scripts:ovos_speak',
'ovos-say-to=ovos_bus_client.scripts:ovos_say_to',
'ovos-simple-cli=ovos_bus_client.scripts:simple_cli'
]
}
)
Loading