From 93abd6ab4a8a164dce7dd1a85c7a35ed5c0de7f6 Mon Sep 17 00:00:00 2001 From: gcebollero Date: Mon, 6 Mar 2023 15:27:16 +0100 Subject: [PATCH 1/3] Multistage dockerfile --- Dockerfile | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4cda182 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM python:3.9-slim-buster AS builder +RUN apt update && apt install git gcc libssl-dev -y +WORKDIR /asksonic +RUN git clone https://github.com/srichter/asksonic.git +RUN pip install --user wheel setuptools honcho +RUN pip install --user -r asksonic/requirements.txt + +FROM python:3.9-slim-buster +COPY --from=builder /asksonic /opt +COPY --from=builder /root/.local /root/.local +ENV PATH=/root/.local/bin:$PATH +WORKDIR /opt/asksonic +ENTRYPOINT ["honcho", "start", "-f", "Procfile.dev"] From 9220ec0331cf27feea509d1575be8498bb5bcab0 Mon Sep 17 00:00:00 2001 From: gcebollero Date: Mon, 6 Mar 2023 16:01:32 +0100 Subject: [PATCH 2/3] Test multi-language support --- asksonic/__init__.py | 3 ++- asksonic/templates/es.yaml | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 asksonic/templates/es.yaml diff --git a/asksonic/__init__.py b/asksonic/__init__.py index ab17024..fbf651f 100644 --- a/asksonic/__init__.py +++ b/asksonic/__init__.py @@ -13,7 +13,8 @@ tracks_count = int(getenv('ASKS_TRACKS_COUNT', 50)) app = Flask(__name__) -ask = Ask(app, route_prefix, path='templates/en.yaml') +template_path = f"templates/{getenv('ASK_LANGUAGE', 'en')}.yaml" +ask = Ask(app, route_prefix, path=template_path) logger = app.logger diff --git a/asksonic/templates/es.yaml b/asksonic/templates/es.yaml new file mode 100644 index 0000000..ee0b67a --- /dev/null +++ b/asksonic/templates/es.yaml @@ -0,0 +1,25 @@ +launch_text: "Bienvenido a AskSonic. Ask me to play an artist, album, or song. You can also ask me to play a playlist or your entire library." +launch_title: "Welcome to AskSonic!" +launch_content: "Ask me to play an artist, album, or song. You can also ask me to play a playlist or your entire library." + +pausing: "Pausing" +resuming: "Resuming" +stopping: "Stopping" +okay: "Okay" + +playing_library: "Playing music from your library" +playing_artist: "Playing music by {{ artist }}" +playing_album: "Playing the album {{ album }} {{ 'by {}'.format(artist) if artist }}" + +current_track: "This song is " +track_information: "{{ title }} by {{ artist }}" +detailed_track_information: "{{ title }} by {{ artist }} from the album {{ album }}" + +artist_albums: "I found these albums by {{ artist }}: {{ album_titles }}" + +intent_not_supported: "Sorry, I can't do that yet" +nothing_playing: "There is no music playing" +no_previous_track: "There is no previous song" +end_of_queue: "There is no more music queued" +artist_not_found: "I couldn't find the artist {{ artist }}" +album_not_found: "I couldn't find the album {{ album }} {{ 'by {}'.format(artist) if artist }}" From ec8394ec1645340978bd556487be7675f73514aa Mon Sep 17 00:00:00 2001 From: gcebollero Date: Mon, 6 Mar 2023 17:51:36 +0100 Subject: [PATCH 3/3] dedup launch intent and help intent --- asksonic/intents/navigation.py | 10 +++++++- asksonic/templates/en.yaml | 10 +++++--- asksonic/templates/es.yaml | 42 +++++++++++++++++++--------------- 3 files changed, 39 insertions(+), 23 deletions(-) diff --git a/asksonic/intents/navigation.py b/asksonic/intents/navigation.py index f61049e..d4ba70c 100644 --- a/asksonic/intents/navigation.py +++ b/asksonic/intents/navigation.py @@ -8,7 +8,6 @@ from . import queue -@ask.intent('AMAZON.HelpIntent') @ask.launch def launch() -> question: log('Launch') @@ -18,6 +17,15 @@ def launch() -> question: content=render_template('launch_content') ) +@ask.intent('AMAZON.HelpIntent') +def help_intent() -> question: + log('Help') + return question(render_template('help_text')) \ + .simple_card( + title=render_template('help_title'), + content=render_template('help_content') + ) + @ask.intent('AskSonicShuffleLibraryIntent') def play_random_tracks() -> audio: diff --git a/asksonic/templates/en.yaml b/asksonic/templates/en.yaml index 2968120..02c3630 100644 --- a/asksonic/templates/en.yaml +++ b/asksonic/templates/en.yaml @@ -1,6 +1,6 @@ -launch_text: "Welcome to Ask Sonic. Ask me to play an artist, album, or song. You can also ask me to play a playlist or your entire library." -launch_title: "Welcome to AskSonic!" -launch_content: "Ask me to play an artist, album, or song. You can also ask me to play a playlist or your entire library." +launch_text: "Welcome to Ask Sonic!" +launch_title: "AskSonic" +launch_content: "Welcome to Ask Sonic!" pausing: "Pausing" resuming: "Resuming" @@ -23,3 +23,7 @@ no_previous_track: "There is no previous song" end_of_queue: "There is no more music queued" artist_not_found: "I couldn't find the artist {{ artist }}" album_not_found: "I couldn't find the album {{ album }} {{ 'by {}'.format(artist) if artist }}" + +help_text: "Ask me to play an artist, album, or song. You can also ask me to play a playlist or your entire library." +help_title: "Help menu" +help_content: "Ask me to play an artist, album, or song. You can also ask me to play a playlist or your entire library." diff --git a/asksonic/templates/es.yaml b/asksonic/templates/es.yaml index ee0b67a..2ac3a4c 100644 --- a/asksonic/templates/es.yaml +++ b/asksonic/templates/es.yaml @@ -1,25 +1,29 @@ -launch_text: "Bienvenido a AskSonic. Ask me to play an artist, album, or song. You can also ask me to play a playlist or your entire library." -launch_title: "Welcome to AskSonic!" -launch_content: "Ask me to play an artist, album, or song. You can also ask me to play a playlist or your entire library." +launch_text: "Bienvenido a AskSonic!" +launch_title: "AskSonic" +launch_content: "Bienvenido a AskSonic!" -pausing: "Pausing" -resuming: "Resuming" -stopping: "Stopping" +pausing: "Pausando" +resuming: "Reanudando" +stopping: "Parando" okay: "Okay" -playing_library: "Playing music from your library" -playing_artist: "Playing music by {{ artist }}" -playing_album: "Playing the album {{ album }} {{ 'by {}'.format(artist) if artist }}" +playing_library: "Reproduciendo música desde tu librería" +playing_artist: "Reproduciendo música de {{ artist }}" +playing_album: "Reproduciendo álbum {{ album }} {{ 'de {}'.format(artist) if artist }}" -current_track: "This song is " -track_information: "{{ title }} by {{ artist }}" -detailed_track_information: "{{ title }} by {{ artist }} from the album {{ album }}" +current_track: "Esta canción es " +track_information: "{{ title }} de {{ artist }}" +detailed_track_information: "{{ title }} de {{ artist }} del álbum {{ album }}" -artist_albums: "I found these albums by {{ artist }}: {{ album_titles }}" +artist_albums: "He encontrado estos albunes de {{ artist }}: {{ album_titles }}" -intent_not_supported: "Sorry, I can't do that yet" -nothing_playing: "There is no music playing" -no_previous_track: "There is no previous song" -end_of_queue: "There is no more music queued" -artist_not_found: "I couldn't find the artist {{ artist }}" -album_not_found: "I couldn't find the album {{ album }} {{ 'by {}'.format(artist) if artist }}" +intent_not_supported: "Lo siento, aún no puedo hacer eso." +nothing_playing: "No se está reproduciendo música" +no_previous_track: "No hay canción previa" +end_of_queue: "No hay más música en cola" +artist_not_found: "No he podido encontrar el artista {{ artist }}" +album_not_found: "No he podido encontrar el álbum {{ album }} {{ 'de {}'.format(artist) if artist }}" + +help_text: "Preguntame para reproducir un artista, álbum o canción. También puedes preguntarme para reproducir una lista de reproducción o tu biblioteca al completo." +help_title: "Menú de ayuda" +help_content: "Preguntame para reproducir un artista, álbum o canción. También puedes preguntarme para reproducir una lista de reproducción o tu biblioteca al completo."