Skip to content

Commit

Permalink
Fix voice errors for missing playlists
Browse files Browse the repository at this point in the history
  • Loading branch information
declension committed Mar 14, 2019
1 parent 0e5326f commit a727c38
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion squeezealexa/alexa/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def audio_response(speech=None, text=None, title=None):

def speech_response(title=None, speech=None, reprompt_text=None, end=True,
store=None, text=None, use_ssml=False):
speechlet_response = speech_fragment(speech=speech, title=title,
speechlet_response = speech_fragment(speech=speech or title, title=title,
reprompt_text=reprompt_text,
text=text, end=end,
use_ssml=use_ssml)
Expand Down
9 changes: 6 additions & 3 deletions squeezealexa/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,12 @@ def on_play_playlist(self, intent, session, pid=None):
speech=_("Playing \"{name}\" playlist").format(name=name),
text=_("Playing \"{name}\" playlist").format(name=name))
pl = random.choice(server.playlists)
template = _("Couldn't find a playlist matching \"{name}\"."
"How about the \"{suggestion}\" playlist?")
return speech_response(template.format(name=slot, suggestion=pl))
title = (_("Couldn't find a playlist matching \"{name}\".")
.format(name=slot))
extra = (_("How about the \"{suggestion}\" playlist?")
.format(suggestion=pl))
return speech_response(title=title, text=extra,
speech=title + extra)

@handler.handle(Play.RANDOM_MIX)
def on_play_random_mix(self, intent, session, pid=None):
Expand Down
7 changes: 7 additions & 0 deletions tests/integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ def test_on_playlist_play_without_playlists(self):
speech = speech_in(response)
assert "No Squeezebox playlists" in speech

def test_play_unknown_playlists(self):
self.stub._playlists = ['Black Friday', A_PLAYLIST, 'Happy Mondays']
intent = one_slot_intent('Playlist', 'Not here')
response = self.alexa.on_play_playlist(intent, FAKE_ID)
speech = speech_in(response)
assert "Couldn't find a playlist matching \"Not here\"" in speech

def test_on_playlist_play(self):
self.stub._playlists = ['Black Friday', A_PLAYLIST, 'Happy Mondays']
intent = one_slot_intent('Playlist', 'Mood Blues')
Expand Down

0 comments on commit a727c38

Please sign in to comment.