Skip to content
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
12 changes: 6 additions & 6 deletions alexa/skills.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def get_day(handler_input):
else:
dt = timezone.localtime()

day = liturgics.Day(dt.year, dt.month, dt.day)
day = liturgics.Day(dt.year, dt.month, dt.day, translation=speech.TRANSLATION)
day.initialize()

return day
Expand All @@ -58,7 +58,7 @@ def handle(self, handler_input):
session.clear()

today = timezone.localtime()
day = liturgics.Day(today.year, today.month, today.day)
day = liturgics.Day(today.year, today.month, today.day, translation=speech.TRANSLATION)
day.initialize()

speech_text, card_text = speech.day_speech(day)
Expand Down Expand Up @@ -222,7 +222,7 @@ def handle(self, handler_input):

# Build speech

passage = readings[0].pericope.get_passage()
passage = readings[0].pericope.get_passage(translation=speech.TRANSLATION)
group_size = speech.estimate_group_size(passage)
date_text = day.gregorian_date.strftime('%A, %B %-d')
reading_speech = speech.reading_speech(readings[0], group_size)
Expand Down Expand Up @@ -302,7 +302,7 @@ def handle(self, handler_input):

def commemorations_handler(self, session, builder):
dt = datetime.strptime(session['date'], '%Y-%m-%d')
day = liturgics.Day(dt.year, dt.month, dt.day)
day = liturgics.Day(dt.year, dt.month, dt.day, translation=speech.TRANSLATION)
day.initialize()

next_commemoration = session.get('next_commemoration')
Expand Down Expand Up @@ -342,14 +342,14 @@ def commemorations_handler(self, session, builder):

def scriptures_handler(self, session, builder):
dt = datetime.strptime(session['date'], '%Y-%m-%d')
day = liturgics.Day(dt.year, dt.month, dt.day)
day = liturgics.Day(dt.year, dt.month, dt.day, translation=speech.TRANSLATION)
day.initialize()
readings = day.get_abbreviated_readings()

next_reading = session.get('next_reading')

reading = readings[next_reading]
passage = reading.pericope.get_passage()
passage = reading.pericope.get_passage(translation=speech.TRANSLATION)

# Is this a long passage?
if group_size := session.get('group_size'):
Expand Down
13 changes: 11 additions & 2 deletions alexa/speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,19 @@

from django.utils import timezone

from calendarium.datetools import FastLevels
from calendarium.datetools import FastLevels, Translation

MAX_SPEECH_LENGTH = 8000

# The skill speaks a modern translation, matching the readings page.
#
# It is set here rather than left to `bible.DEFAULT_TRANSLATIONS['en']`, which
# is KJV and stays that way: the API and the RSS feeds resolve through that
# default and are deliberately unchanged. `Pericope.get_passage` takes the
# translation per call and does not inherit it from the Day, so every call site
# that reads scripture has to pass it.
TRANSLATION = Translation.LXX2012WEB

ref_re = re.compile(r'(\d*)\s*([\w\s]+)\s+(\d+)')
ssml_re = re.compile(r'<(?!p\b)(.*?)>(.*?)</\1>')

Expand Down Expand Up @@ -209,7 +218,7 @@ def reading_speech(reading, end=None):
)

def reading_range_speech(reading, start=None, end=None):
passage = reading.pericope.get_passage()
passage = reading.pericope.get_passage(translation=TRANSLATION)
return '\n'.join(f'<p>{verse.content}</p>' for verse in passage[start:end])

def estimate_group_size(passage):
Expand Down
4 changes: 3 additions & 1 deletion alexa/tests/test_intents.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ def test_next_intent(self):
request_envelope = skill.serializer.deserialize(payload=envelope, obj_type=RequestEnvelope)
response = skill.invoke(request_envelope=request_envelope, context=None)

self.assertIn('deceiveth his own heart', response.response.output_speech.ssml)
# LXX2012-WEB, the translation the skill speaks -- KJV has
# "deceiveth his own heart" here. See alexa.speech.TRANSLATION.
self.assertIn('deceives his heart', response.response.output_speech.ssml)
self.assertIn('Would you like to hear the next reading?', response.response.output_speech.ssml)
self.assertEqual(1, response.session_attributes['next_reading'])
self.assertEqual(['commemorations'], response.session_attributes['task_queue'])
Expand Down
9 changes: 7 additions & 2 deletions alexa/tests/test_speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,14 @@ def test_reference_speech(self):
self.assertEqual(expected, actual)

def test_reading_speech(self):
day = liturgics.Day(2023, 1, 18)
"""The skill speaks LXX2012-WEB, not the KJV that
`bible.DEFAULT_TRANSLATIONS['en']` still gives the API and the feeds.
KJV renders this verse "The spirit that dwelleth in us lusteth to
envy"; see alexa.speech.TRANSLATION."""

day = liturgics.Day(2023, 1, 18, translation=speech.TRANSLATION)
day.initialize()
readings = day.get_readings()

speech_text = speech.reading_speech(readings[0])
self.assertIn('The spirit that dwelleth in us lusteth to envy', speech_text)
self.assertIn('The Spirit who lives in us yearns jealously', speech_text)
4 changes: 2 additions & 2 deletions calendarium/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ def get_openapi_operation_id(self, operation):
description=(
'Orthocal.info provides an API for looking up information about '
'days and months in the Orthodox Calendar, including the ability '
'to look up the scripture readings and lives of the saints for a given day.'
'The API follow OCA rubrics.'
'to look up the scripture readings and lives of the saints for a given day. '
'The API follows OCA practices.'
),
servers=[
{'url': settings.ORTHOCAL_PUBLIC_URL, 'description': 'Public API'},
Expand Down
5 changes: 3 additions & 2 deletions calendarium/templates/help.ssml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
<p>Orthodox Daily makes it easy to access the daily scripture readings. Simply
ask me to open Orthodox Daily and I will provide you with a few details
about today, including the fasting rules, and then read the prescribed
scriptures. The scriptures are read from the King James Version and at
present follow <say-as interpret-as="spell-out">OCA</say-as> rubrics.</p>
scriptures. The scriptures are read from the World English Bible, with an Old
Testament translated from the Septuagint, and at present follow
<say-as interpret-as="spell-out">OCA</say-as> practices.</p>

<p>You can also ask me directly about a particular day. For instance
you can say, "Alexa, ask Orthodox Daily about tomorrow." Or you could say,
Expand Down
5 changes: 4 additions & 1 deletion orthocal/templates/alexa.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ <h2>Alexa Skill</h2>
scripture readings and commemorations. Simply ask Alexa to open Orthodox Daily, and she will
provide you with a few details about today, including the fasting rules,
and then read the prescribed scriptures and lives of the saints out loud.
The scriptures are read from the King James Version and follow OCA rubrics
The scriptures are read from
<a href="https://en.wikipedia.org/wiki/The_Septuagint_version_of_the_Old_Testament_(Brenton)">LXX2012</a> +
<a href="https://en.wikipedia.org/wiki/World_English_Bible">WEB</a>, the same
modern-English pairing the readings page uses by default, and follow OCA practices
and fasting guidelines. For the Alexa skill, the number of readings is
abbreviated. A fuller list is available on this website. The stories from
the lives of the saints are borrowed from abbamoses.com by
Expand Down