lexstream

module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2022 License: Apache-2.0

README

lexstream

Alexa Music skill for streaming your own music.

Go Report Card

created by tigwen

Prerequisites

  • Go
  • ASK CLI
    • Complete the setup through step 3, install and initialize.
      • You can use your existing AWS credentials instead of having the ask-cli linked to your aws account.
    • You need to hava an Alexa device registered to be able to create the skill that drives this code
      • Global installation is not required, you can create an alias or similar shell script. i.e.
      • alias ask="node /path/to/node_modules/ask-cli/bin/ask.js"
  • Node.js ASK CLI requires version 8.3 or higher.
  • An AWS account and IAM credentials stored in ~/.aws/credentials
    • These credentials need to have permissions to manipulate S3, IAM, Lambda resources
    • Set the AWS_PROFILE environment variable when not using the default profile

Skill Creation

  • Create a new skill with a Music model in the alexa console
  • Complete steps 1,3,4,5 in the Music Skill Builder Checklist under the Build tab.
    • Skip "Upload Catalogs" which will be completed under Catalog Creation below.
    • Under "Define Endpoints" copy the Your Skill ID or know how to get back to it.
      • Leave the Default endpoint empty for now, it will be filled in once the Deploy Lambda below has been completed.
    • Complete the Skill Names, Interfaces, Features sections using:
      • The first 4 Interfaces need be checked as they are required.
      • If you have explicit language filtering enabled for your Alexa devices the checkbox on Features needs to be checked. Otherwise, your devices will refuse to talk to the skill.
  • Click the Distribution tab and fill in some reasonable defaults for the preview / privacy / availability sections.
    • This is required to get the Certification to run and make sure the lambda works.
    • Most of this will not be used as we're not submitting the skill for publication.
  • On the Certification tab click the Run button.
    • It should just output one line: The catalog is missing entities for locale en-US. Make sure the complete catalog is uploaded and associated, then try again.
    • If there are any other errors, fix them in the Build tab.

Configuration steps

Catalog Creation
  • Update the catalog/track.json with the metadata (track/artist/album) of the files you are going to upload.
  • Create the catalog, replacing the title with your preferred title
    $ ask smapi create-catalog \
    --title "Matt's Music" \
    --type AMAZON.MusicRecording \
    --usage AlexaMusic.Catalog.MusicRecording
    
    • Make sure to note the catalog "id" field from the last command.
    • It should be in the form amzn1.ask-catalog.cat.<your-unique-id>
    • You can also get this using ask smapi list-catalogs-for-vendor
  • Associate the catalog with the skill
    # The -s parameter is your alexa skill id.
    # The -c parameter is the catalog id created in the previous step.
    $ ask smapi associate-catalog-with-skill \
    -s amzn1.ask.skill.<your-unique-id> \
    -c amzn1.ask-catalog.cat.<your-unique-id>
    
  • Upload your music catalog tracks metadata file
    $ ask smapi upload-catalog \
    -c amzn1.ask-catalog.cat.<your-unique-id> \
    -f catalog/track.json
    
    • Save the upload-id output from the previous command.
    • The output from the previous command will indicate Catalog uploaded successfully this does not mean it has passed all validation checks or has been run through the Spoken Language Understanding
  • Track progress of the catalog upload using
    # The --upload-id is from the previous step
    $ ask smapi get-content-upload-by-id \
    -c amzn1.ask-catalog.cat.<your-unique-id> \
    --upload-id amzn1.ask-catalog.upl.<your-unique-id> 
    
    • When an upload fails, the output of this command will contain some high level messages and a link to a log file with more details on why it failed.
  • The catalog should be ready to go once the installationSteps element
    {
      "ingestionSteps": [{
        "errors": [],
        "logUrl": "",
        "name": "ER_INGESTION",
        "status": "SUCCEEDED"
      }]
    }
    
Deploy Lambda
  • WARNING the bucket permissions will be re-set to no public access!!
  • Copy settings.json.example to settings.json and update with the appropriate bucket and skill id
  • Run the following command to create the required Bucket, IAM Role, and Lambda
    $ go run infra/sync.go
    
Update Endpoint and Re-Validate
  • Back in the Alexa skills console, update the skill endpoint with the output of the previous command
TODO
  • Build track catalog automatically from mp3 id tags
  • Upload music automatically
  • Periodically re-index mp3 files in bucket and create new track metadata and upload it
    • The ask cli does an browser based login to get the access tokens so this may be a pain doing it otherwise, more research needed

https://mlctrez-lexstream.s3.amazonaws.com/Undertale_OST__012_-_Home.mp3?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIAVHO22I3TRBBGFCXH%2F20221105%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20221105T032203Z&X-Amz-Expires=900&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEPz%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLWVhc3QtMSJIMEYCIQDBxPp11HtKPnXjdK06IdPCEVGPyeCRHBw2ixFNOQhqzAIhAIBd5B%2BeRDOXNjyJfqFfYMU76vIMDtqw6LMlJMnPUJzHKv0CCOT%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEQABoMMzU5NjI1NTQxMzUxIgzfFPAXTm4dyuF0qmEq0QIdprQR7VmxDzjRlzv3bfhl1eIVAlFkmJdP19GESkq7QlSG0ND%2F6uJVyX1MW5AvKbKpemHmFsm2b4HqbIe6FAym%2BZE02QyPY5bb%2F3o6emXNUrzlhjCMry9hAoQqZrPwUfSVKKIAZ0lCK26mKqucBQ0MlUj7C3Pp%2B3qADMdT86NQ6yXSZ9ilFJtO7s899tHTseFYPFSLIM6ifRYSyMFqUpgIE6tbINy7tAVHXGcMxvrTXmschCIWQBN39jodFrQhpZkxIv4smhrtSMQWRR%2FBieUvg5lIFtmf%2FCo%2BWHsv1mUvTXW0KuoEvKJgrXNY848hVA%2FOLNbptCErk%2FLS1tixoSXJM6ZIzlBAaOZ%2FztrHziL9IV2PuqrAYTN78GsjfloTQb1ORe79ASbbnjDXCKDR3lP5ZK7KU11GcxD2R%2BYHwsbI8PDA9g64BIMo8he0PE12tfyXML2tl5sGOp0Bsc%2FPszT0mkOK6JX%2BIuoHKv6pfmtgY9sAeZH1F2Qakzq4ytkB7uSxVMcfllSxqIWumV%2BhFiXd725IJOilneapvsH2WsJFONJ0pn%2B1cRqwZcRULeW7jSsrGJ%2ByOmC2sZqYsehMkxKcqGERzW0qJiZr8SQK5uXhkkg0pjNPSnuvIA6hmbT1iK6ZIrgkcUeSGFEbyxjFV%2FrMawnr5O4HTA%3D%3D&X-Amz-SignedHeaders=host&X-Amz-Signature=1425f7648e1aec41bf042bc535398cc9fa9fbdcdd13344fac691dc773708fc83

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL