Giter VIP home page Giter VIP logo

internetarchive / internet-archive-voice-apps Goto Github PK

View Code? Open in Web Editor NEW
45.0 26.0 42.0 4.51 MB

Voice Apps (Actions on Google, Alexa Skill) of Internet Archive. Just say: "Ok Google, Ask Internet Archive to Play Jazz" or "Alexa, Ask Internet Internet Archive to play Instrumental Music"

JavaScript 99.47% Shell 0.53%
actions-on-google alexa-skill dialog-flow voice-assistant internet-archive

internet-archive-voice-apps's Introduction

Internet Archive Google Action Build Status Coverage Status

Setup Instructions

See the developer guide and release notes at https://developers.google.com/actions/ for more details.

Steps for testing with Google Assistant

Create and setup project in Actions Console

  1. Use the Actions on Google Console to add a new project with a name of your choosing and click Create Project.
  2. Click skip
  3. Go to actions under build, and click Add your first action
  4. select custom intent, then build

Create Action for the project

  1. Click CREATE (continued from above step)
  2. Go to settings and click export and import, then click restore from zip.
  3. zip the contents of models/dialogflow/ and use that zip to restore the project.

Run Local Server

Run server local with colorful logs

  1. npm install -g firebase-tools
  2. touch functions/.runtimeconfig.json and add fake keys (temporary workaround) refer this
  3. firebase init (remove .firebaserc first)
  4. firebase use --add (and choose your own firebase project)
  5. cd functions and npm install
  6. DEBUG=ia:* npm start

Expose local server

To expose server to google assistant use ngrok its free plan should be enough.

To publish 5000 port use:

ngrok http 5000

you should find url https://<id>.ngrok.io/.

Connect webhook to dialogflow

Go to the fullfillment section of your dialogflow draft copy of our app and after that you should use this url:

https://<id>.ngrok.io/<your project name>/us-central1/assistant

Steps for testing with Alexa

The Alexa app workflow for dev/production is the following:

  • We create a zip file with the app code.
  • We upload the zip to an AWS S3 bucket.
  • We edit the AWS Lambda app to load the new app zip file.
  • In case the AWS Lambda app changes a lot (e.g. we upgrade Node version), its Lambda ID will change. In that case, we need to edit the Alexa skill in https://developer.amazon.com/alexa/console/ask# to load the new Lambda app. This final step is not required most of the times.
  • We use https://developer.amazon.com/alexa/console/ask# to test the app.

More details follow.

Node 12 is required. There is a problem with newer Node versions, bespoken-tools which is a key dependency, is not supporting it. Use nvm install 12 and nvm use 12 to switch to Node 12 before running any other command.

The general idea is that there are 2 AWS S3 buckets, dev and production. You can access them via https://aws.amazon.com/ -> sign in -> S3. You need to create a zip with the app, you upload it to the relevant S3 bucket and then you go to AWS Lambda dev / production to select which app should be loaded via its S3 URL. (AWS -> Lambda -> edit app -> "upload from S3 .zip file").

S3 buckets have multiple app versions. This way, you can also easily rollback to a previous version if needed.

The script that produces the app.zip that we upload to S3 is bin/deploy-to-alexa-skill.sh. An important AWS Lambda limitation is that the unzip code filesize should be < 250MB. To achieve that, we do:

(cd ./deploy/alexa/; npm install --production; rm -rf node_modules/aws-sdk; node-prune node_modules)

aws-sdk is already preinstalled in AWS Lambda, so we don't need it.

npm install -g node-prune is a pre-requisite. This tool removes files that are useless in production and reduces the total filesize a lot.

After deploying to dev or production, use https://developer.amazon.com/alexa/console/ask# ACTIONS -> Test for testing.

Setup Env

Options

  • profile performance of requests Env Variable: PROFILE_REQUESTS=true (false by default) firebase functions:config:set performance.requests=true

How to make contributions?

๐Ÿ” get one good first issue assign yourself (if you have access) or write comment that you'd like to work on this issue. That's help to prevent work overlapping.

create git branch feature/<name-of-feature>, more

๐Ÿ’ป working on it

Use Mocha for continuous checking of your code quality and cover functionality by tests

npm run mocha -- --watch

โ˜• Complete checking of code by run unit tests and code style checking

npm test

๐ŸŒŸ We follow standard javascript code style.

Automatic style fixing, it doesn't solve all problems but could be very helpful

npm run lint -- --fix

๐ŸŽ‰ Finally make Pull Request and give complete description what have you done and link the addressed issue.

Also it could be good practice to create your Pull Request earlier, but add WIP: at the beginning of its name! This way other developers could see what are you working right now.

internet-archive-voice-apps's People

Contributors

adaveinthelife avatar anishsarangi avatar bimlendra avatar dependabot[bot] avatar hyzhak avatar juliascript avatar machawk1 avatar sayak119 avatar vbanos avatar yagyanshbhatia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

internet-archive-voice-apps's Issues

happy dialog #1

Google Assistant | Okay. Let's get the test version of Internet Archive.
IA | Welcome to music at the Internet Archive.Would you like to listen to music from our collections of 78s or Live Concerts?
User | 78s
IA | What genre of music would you like to listen to? Please select a topic like Jazz, Instrumental, or Dance
User | Jazz
IA | [Play songs randomly]
User | Stop
IA | Alright, see you next time!

combine all select search query slot actions together in the one handler

  • we have set of required slots: ['collection', 'creator', 'coverage', 'year']
  • if we filled all slots - use these slots to play music
  • if we lack one slot - promt user to give needed information
  • as well check which new slots we get and acknowledge user with new accomplishment
  • implement suggestions

"Internet Archive isn't supported on this device." for fresh deployed app

we are getting from google assistant or dialog flow:

body = {}
headers={"host":"us-central1-internet-archive.cloudfunctions.net","user-agent":"axios/0.16.2","accept":"application/json, text/plain, /","function-execution-id":"....","x-appengine-api-ticket":"....","x-appengine-city":"ashburn","x-appengine-citylatlong":"....","x-appengine-country":"US","x-appengine-https":"on","x-appengine-region":"va","x-appengine-user-ip":"...","x-cloud-trace-context":"...;o=1","x-forwarded-for":"...","accept-encoding":"gzip"}

and failing

some albums of etree doesn't have artist collection

Examples:

So maybe we can't rely on artist's collection:
collection:(etree) AND collection:(<artist>)

but search albums by instead:
collection:(etree) AND creator:(<artist>)

PS

Yes, it seems many creators don't have dedicated collections. It's easy to check by collection georgeblood.
For example artist Alvino Rey and his Orchestra has a lot of plates, but no any dedicated collection:
https://archive.org/advancedsearch.php?q=(collection:(georgeblood)%20AND%20creator:(Alvino%20Rey%20and%20his%20Orchestra))&output=json

Examples

  • The Cutest Puppy in the World
  • Big Leg Emma
  • Sage
  • 311

Script for uploading dialog flow

The Goal

We should be able automatically to populate the DialogFlow entity lists, which are related to our subject area.

For example:

  • categories like concerts, 78: collection names => collectionId
  • sub-categories like band names (creators): creator name => collectionId
  • albums and concerts album name => album name
  • genres: genre name => genre name
  • songs titles: title => title
    and etc

So we should match differently speaking titles to the "identifiers" (for example: live, Concerts, Live Concerts) -> etree, 78, -> georgeblood). Which we could use for https://web.archive.org/advancedsearch.php request.

Pipeline

  • it should be runnable through npm run upload:<name>
  • all data should automatically download from IA and upload to Dialog Flow
  • don't put tokens into the repository they should be got from process.env

PS

The last but not least. We should know what is the limit of Dialog Flow? And how many data could we store here?

Dependency

related #35

update welcome message

#36

we should have

Welcome to music at the Internet Archive.
Would you like to listen to music from our collections of 78s or Live Concerts?

option slot(?) for order

it could be:

  • the best
  • in the natural order
  • randomly

features:

  • and should be the option in slots scheme
  • user could alter the order

handle genres action

related to

#22

features

  • handle select-subject action
  • store selected subject
  • ask user about need information to fill query slots

react gracefully when we can't get data from IA

sometimes IA data unavailable for some reasons. so we should tell something pleasable to a user. For example, try later or try something else.

Depends on: #45

Answer:

we experience some technical problems on IA server, please try later or try something else.

Get status of metadata and launch script

We need to know whenever a new collection, categories, topics etc added to IA server. In the same request we can push that new collection into the listing of dialog-flow entity.
I believe this is something that can be added at the server side.

Below are the list of expected metadata::

  • collections
  • Topics
  • categories like concerts, 78
  • sub-categories like band names (creators)
  • genres

Single album of place and year

We should check each time whether we have enough information for single album or song and play it without extra questions.

For example when only one artist was played in this town at that year. Thus Town and year could be enough.

check user's data modification after ask and tell commands

AssistantApp and DialogflowApp send a response on ask and tell immediately so user's data should be set before response. Otherwise, it will be lost.

So it would be good to add some tests which will check user's data on ask and tell and at the end of action handling and notify about lost data!

related issues:
#93

refactor: use Map() for matching intends to handler

  const actionMap = new Map();
  actionMap.set(TRANSACTION_CHECK_NO_PAYMENT, transactionCheckNoPayment);
  actionMap.set(TRANSACTION_CHECK_ACTION_PAYMENT, transactionCheckActionPayment);
  actionMap.set(TRANSACTION_CHECK_GOOGLE_PAYMENT, transactionCheckGooglePayment);
  actionMap.set(TRANSACTION_CHECK_COMPLETE, transactionCheckComplete);
  actionMap.set(DELIVERY_ADDRESS, deliveryAddress);
  actionMap.set(DELIVERY_ADDRESS_COMPLETE, deliveryAddressComplete);
  actionMap.set(TRANSACTION_DECISION_ACTION_PAYMENT, transactionDecision);
  actionMap.set(TRANSACTION_DECISION_COMPLETE, transactionDecisionComplete);

  app.handleRequest(actionMap);

sample: https://github.com/actions-on-google/dialogflow-transactions-nodejs/blob/master/functions/index.js#L184

handlers

  • no.input
  • repeat
  • unknown.input
  • welcome

in additionally

  • each handler should have is own file
  • covered by unit tests

fix eslint

it seems eslint doesn't follow all files.
Easy to check:

npm run lint -- ./array.js
npm run lint -- ./index.js
npm run lint -- ./tests/*/*.js

and etc. We should check all js fields in the project

use Debug

https://github.com/visionmedia/debug

  • replace all
console.<something>

with debug() call

  • control verbosity through env variables (check that we have enough logging information in production)

I'm tired of getting extra log pollution on each unit test call so I'd like to get rid of it and use debug. it gives us much more control over the verbosity of logging. I haven't check what is the state of official node.js console.log. Maybe it is already good enough.

control playlist playing

  • next - support by google assistant - it sends event end of song
  • alt next - "skip track"
  • previous / rewind
  • stop
  • repeat
  • first
  • last
  • rewind N songs
  • skip N songs

requires #30 for support context-dependent words

support concat resolver for acknowledge template substitution

Add resolver which concatenate each field of received slots.

motivation

We need to simplify a description of acknowledges. So instead of:

{{coverage}} - great choice!
{{year}} - great choice!
{{__resolvers.collection.title}} - great choice!
{{__resolvers.creator.title}} - great choice!
{{__resolvers.creator.title}} {{year}} - great choice!
...

We could write instead:

{{__resolvers.concat.title}} - great choice!

Handle empty music query result

We get all the information but there is no any music.
Ask user for the wider/different request.
For the moment it is possible that we could give not answer in media-query handler, we should always prompt a user.

update select-collection message

search-collection should sound like "Ok, you selected the live music archive, what artist would you like to listen to? For example, the Grateful Dead, the Ditty Bops or the Cowboy Junkies."

playlist

sync

  • play one song and show description
  • when song is finished run next song in the list
  • notify when playlist is finished

async

sub-issue: #87

standard javascript code style

  • follow standardjs.com
  • setup travis ci ๐Ÿšœ
  • setup eslint
  • fix style, except unused - maybe we still need some of them
  • add readme

post-processing of slot value

We could receive some data which would be useful to process before usage.

For example:
We receive the name of a band, but actually, we need its id.
so we should convert data (for example by applying postprocessing).

Depends on: #86 - if we can't use creatorId as collection identifier of artist we don't have any use case for this feature yet

Update

  • we have replaced creatorId with creator so this feature is not actual anymore.

handle band action

Related to

#22

Features

  • handle select-creator action (band == creator)
  • ask about other query slots
  • store selected creator

we fails to play some songs

example.

this one is ok:
https://ia601601.us.archive.org/6/items/78_sugar-foot-stomp_connies-inn-orchestra-armstrong-oliver-rex-stewart-russell-smith_gbia0001054a/Sugar%20Foot%20Stomp%20-%20Connie's%20Inn%20Orchestra.mp3

but that one fails:
https://archive.org/download/78_sugar-foot-stomp_connies-inn-orchestra-armstrong-oliver-rex-stewart-russell-smith_gbia0001054a/Sugar Foot Stomp - Connie&#39;s Inn Orchestra.mp3
for some reasons we get it instead of this one
https://archive.org/download/78_sugar-foot-stomp_connies-inn-orchestra-armstrong-oliver-rex-stewart-russell-smith_gbia0001054a/Sugar Foot Stomp - Connie's Inn Orchestra.mp3

from: https://archive.org/metadata/78_sugar-foot-stomp_connies-inn-orchestra-armstrong-oliver-rex-stewart-russell-smith_gbia0001054a

Examples:

  • https://ia800607.us.archive.org/34/items/78_perdido_rolf-ericsons-swingin-swedes-rolf-ericson-arne-domnerus-g.-theselius-lars_gbia0009875b/Perdido%20-%20Rolf%20Ericson&#39;s Swingin&#39; Swedes.mp3
  • https://ia800803.us.archive.org/14/items/78_silver-moon-luna-dargento_p.-frosini-frosini_gbia0010047b/Silver%20Moon%20(Luna%20d&#39;argento) - P. Frosini.mp3
  • https://ia800603.us.archive.org/9/items/78_for-you_doc-lawson_gbia0009962a/For%20You%20-%20&quot;Doc&quot;%20Lawson.mp3

finite state machine

it could be something closer to the context of Dialog Flow.
The idea that when we give a user some question:

>What is the artist?

we define context so next answer very likely will match this context. As well very broad words like repeat could refer to the song or to the long message.

Alexa

As well it is needed to support cancel, close, stop, next and etc Alexa intents.

Modules

  • define states - sub-directory with actions is state
  • map intent name and current state to a handler
  • transition - update current state
  • log transition

implement "Happy path" 2

Implement "Happy path" 2

Message
User Hey Google, talk to Internet Archive
Google Assistant Okay. Let's get the test version of Internet Archive.
IA Welcome back. Choose an artist.to music at the Internet Archive.Would you like to listen to music from our collections of 78s or Live Concerts?
User "Concerts"
IA What artist would you like to listen to, e.g. the Grateful Dead, the Ditty Bops, or the cowboy junkies.
User Grateful Dead
IA Grateful Dead - great choice! Do you have a specific city and year in mind, like Washington 1973, or would you like me to play something randomly from Grateful Dead?
User Washington 1973
IA [Play songs]
User Stop
IA Alright, enjoy!

skipped slot

a user can ask for random something (creator, album or other) so this slot should be skipped and we shouldn't use it in a request to IA provider

  • could skip any slot
  • could use slot skipping in preset slotName: {skip:true},

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.