From f58f1ceadc9d405039419430eb2d579ef1a7cb86 Mon Sep 17 00:00:00 2001 From: miro Date: Wed, 29 May 2024 22:57:07 +0100 Subject: [PATCH] visible duration --- __init__.py | 11 ++++++--- locale/en-us/visible_for.dialog | 2 ++ translations/en-us/dialogs.json | 40 ++++++++++++++++++--------------- 3 files changed, 32 insertions(+), 21 deletions(-) create mode 100644 locale/en-us/visible_for.dialog diff --git a/__init__.py b/__init__.py index 43267b4..c1d91b5 100644 --- a/__init__.py +++ b/__init__.py @@ -9,7 +9,7 @@ from lingua_franca.format import nice_duration from matplotlib.offsetbox import OffsetImage, AnnotationBbox from mpl_toolkits.basemap import Basemap -from ovos_utils.time import to_local +from ovos_utils.time import to_local, now_local from ovos_workshop.decorators import intent_handler from ovos_workshop.decorators import resting_screen_handler from ovos_workshop.intents import IntentBuilder @@ -168,8 +168,10 @@ def handle_when(self, message): pred = SatellitePredictions(lat, lon, altitude=0, days=1).predict() dt = pred["rise"]["time"] # in user timezone delta = pred["length"] + dur = dt - now_local() - duration = nice_duration(delta, lang=self.lang) + duration = nice_duration(dur, lang=self.lang) + visible_dur = nice_duration(delta, lang=self.lang) caption = self.location_pretty + " " + dt.strftime("%m/%d/%Y, %H:%M:%S") image = self.generate_map(lat, lon) @@ -179,7 +181,9 @@ def handle_when(self, message): "duration": duration, "toponym": self.location_pretty }, wait=True) - sleep(1) + self.speak_dialog("visible_for", { + "duration": visible_dur + }, wait=True) self.gui.release() @intent_handler( @@ -352,5 +356,6 @@ def spk(utt, *args, **kwargs): # The international space station is now over Central African Republic at 8.6270 latitude 21.5912 longitude s.handle_when(Message("")) # The I S S will be over XXX in seven minutes twenty five seconds + # It will be visible during seven minutes twenty five seconds s.handle_about_iss_intent(Message("")) # The International Space Station is a modular space station in low Earth orbit. The ISS programme is a multi-national collaborative project between five participating space agencies: NASA ( United States ) , Roscosmos ( Russia ) , JAXA ( Japan ) , ESA ( Europe ) , and CSA ( Canada ) .The ownership and use of the space station is established by intergovernmental treaties and agreements. diff --git a/locale/en-us/visible_for.dialog b/locale/en-us/visible_for.dialog new file mode 100644 index 0000000..b446a7f --- /dev/null +++ b/locale/en-us/visible_for.dialog @@ -0,0 +1,2 @@ +It will be visible for {duration} +You will be able to see it for {duration} \ No newline at end of file diff --git a/translations/en-us/dialogs.json b/translations/en-us/dialogs.json index 14505f6..7aa663a 100644 --- a/translations/en-us/dialogs.json +++ b/translations/en-us/dialogs.json @@ -3,37 +3,41 @@ "The International Space Station is a modular space station in low Earth orbit. The ISS programme is a multi-national collaborative project between five participating space agencies: NASA (United States), Roscosmos (Russia), JAXA (Japan), ESA (Europe), and CSA (Canada).The ownership and use of the space station is established by intergovernmental treaties and agreements." ], "location.unknown.dialog": [ - "The space station is at {latitude} latitude {longitude} longitude but I don't know where this is", - "The ISS is now over {latitude} latitude {longitude} longitude but there is no associated geographic feature" + "The ISS is now over {latitude} latitude {longitude} longitude but there is no associated geographic feature", + "The space station is at {latitude} latitude {longitude} longitude but I don't know where this is" ], "number.dialog": [ - "{number} persons are on board of the international space station", - "{number} persons are on board of the space station", - "{number} persons are on board of the I S S", - "{number} persons are in orbit on board of the space station", + "there are {number} persons in orbit on board of the space station", + "there are {number} persons on board of the I S S", "there are {number} persons on board of the international space station", "there are {number} persons on board of the space station", - "there are {number} persons on board of the I S S", - "there are {number} persons in orbit on board of the space station" + "{number} persons are in orbit on board of the space station", + "{number} persons are on board of the I S S", + "{number} persons are on board of the international space station", + "{number} persons are on board of the space station" + ], + "visible_for.dialog": [ + "It will be visible for {duration}", + "You will be able to see it for {duration}" ], "location.when.dialog": [ "The I S S will be over {toponym} in {duration}", - "The space station will be at {toponym} in {duration}", - "The international space station will be at {toponym} in {duration}" + "The international space station will be at {toponym} in {duration}", + "The space station will be at {toponym} in {duration}" ], "who.dialog": [ - "{people} are on board of the international space station", - "{people} are on board of the space station", - "{people} are on board of the I S S", - "{people} are in orbit on board of the space station", "the following people are on board of the international space station, {people}", - "the following persons are on board of the international space station, {people}" + "the following persons are on board of the international space station, {people}", + "{people} are in orbit on board of the space station", + "{people} are on board of the I S S", + "{people} are on board of the international space station", + "{people} are on board of the space station" ], "location.current.dialog": [ - "The I S S is over {latitude} latitude {longitude} longitude which corresponds to {toponym}", - "The space station is at {latitude} latitude {longitude} longitude over {toponym}", "It's at {latitude} latitude {longitude} longitude, over {toponym}", + "Over {toponym} at {latitude} latitude and {longitude} longitude", + "The I S S is over {latitude} latitude {longitude} longitude which corresponds to {toponym}", "The international space station is now over {toponym} at {latitude} latitude {longitude} longitude", - "Over {toponym} at {latitude} latitude and {longitude} longitude" + "The space station is at {latitude} latitude {longitude} longitude over {toponym}" ] } \ No newline at end of file