{ "info": { "author": "Richard Tier", "author_email": "rikatee@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# Alexa Voice Service Client\n\n[![code-climate-image]][code-climate]\n[![circle-ci-image]][circle-ci]\n[![codecov-image]][codecov]\n\n**Python Client for Alexa Voice Service (AVS)**\n\nThis package has been renamed to [alexa-client](https://pypi.org/project/alexa-client/). Only [alexa-client](https://pypi.org/project/alexa-client/) will receive updates.\n\n---\n\n## Installation\n```sh\npip install avs_client\n```\n\nor if you want to run the demos:\n\n```sh\npip install avs_client[demo]\n```\n\n## Usage\n\n### File audio ###\n```py\nfrom avs_client import AlexaVoiceServiceClient\n\nalexa_client = AlexaVoiceServiceClient(\n client_id='my-client-id',\n secret='my-secret',\n refresh_token='my-refresh-token',\n)\nalexa_client.connect() # authenticate and other handshaking steps\nwith open('./tests/resources/alexa_what_time_is_it.wav', 'rb') as f:\n for i, directive in enumerate(alexa_client.send_audio_file(f)):\n if directive.name in ['Speak', 'Play']:\n with open(f'./output_{i}.mp3', 'wb') as f:\n f.write(directive.audio_attachment)\n```\n\nNow listen to `output_0.wav` and Alexa should tell you the time.\n\n### Microphone audio\n\n```py\nimport io\n\nfrom avs_client import AlexaVoiceServiceClient\nimport pyaudio\n\n\ndef callback(in_data, frame_count, time_info, status):\n buffer.write(in_data)\n return (in_data, pyaudio.paContinue)\n\np = pyaudio.PyAudio()\nstream = p.open(\n format=pyaudio.paInt16,\n channels=1,\n rate=16000,\n input=True,\n stream_callback=callback,\n)\n\nalexa_client = AlexaVoiceServiceClient(\n client_id='my-client-id',\n secret='my-secret',\n refresh_token='my-refresh-token',\n)\n\nbuffer = io.BytesIO()\ntry:\n stream.start_stream()\n print('listening. Press CTRL + C to exit.')\n alexa_client.connect()\n for i, directive in enumerate(alexa_client.send_audio_file(buffer)):\n if directive.name in ['Speak', 'Play']:\n with open(f'./output_{i}.mp3', 'wb') as f:\n f.write(directive.audio_attachment)\nfinally:\n stream.stop_stream()\n stream.close()\n p.terminate()\n```\n\n### Voice Request Lifecycle\n\nAn Alexa command may relate to a previous command e.g,\n\n[you] \"Alexa, play twenty questions\"\n[Alexa] \"Is it a animal, mineral, or vegetable?\"\n[you] \"Mineral\"\n[Alexa] \"Is it valuable\"\n[you] \"No\"\n[Alexa] \"is it...\"\n\nThis can be achieved by passing the same dialog request ID to multiple `send_audio_file` calls:\n\n```py\nfrom avs_client.avs_client import helpers\n\ndialog_request_id = helpers.generate_unique_id()\ndirectives_one = alexa_client.send_audio_file(audio_one, dialog_request_id=dialog_request_id)\ndirectives_two = alexa_client.send_audio_file(audio_two, dialog_request_id=dialog_request_id)\ndirectives_three = alexa_client.send_audio_file(audio_three, dialog_request_id=dialog_request_id)\n\n```\n\nRun the streaming microphone audio demo to use this feature:\n\n```sh\npip install avs_client[demo]\npython -m avs_client.demo.streaming_microphone \\\n --client-id=\"{enter-client-id-here}\" \\\n --client-secret=\"{enter-client-secret-here\"} \\\n --refresh-token=\"{enter-refresh-token-here}\"\n```\n\n## Authentication\n\nTo use AVS you must first have a [developer account](http://developer.amazon.com). Then register your product [here](https://developer.amazon.com/avs/home.html#/avs/products/new). Choose \"Application\" under \"Is your product an app or a device\"?\n\nThe client requires your `client_id`, `secret` and `refresh_token`:\n\n| client kwarg | Notes |\n| --------------- | ------------------------------------- |\n| `client_id` | Retrieve by clicking on the your product listed [here](https://developer.amazon.com/avs/home.html#/avs/home) |\n| `secret` | Retrieve by clicking on the your product listed [here](https://developer.amazon.com/avs/home.html#/avs/home) |\n| `refresh_token` | You must generate this. [See below](#refresh-token) |\n\n### Refresh token ###\n\nYou will need to login to Amazon via a web browser to get your refresh token.\n\nTo enable this first go [here](https://developer.amazon.com/avs/home.html#/avs/home) and click on your product to set some security settings under `Security Profile`:\n\n| setting | value |\n| ------------------- | --------------------------------|\n| Allowed Origins | http://localhost:9000 |\n| Allowed Return URLs | http://localhost:9000/callback/ |\n\nNote what you entered for Product ID under Product Information, as this will be used as the device-type-id (case sensitive!)\n\nThen run:\n\n```sh\npython -m avs_client.refreshtoken.serve \\\n --device-type-id=\"{enter-device-type-id-here}\" \\\n --client-id=\"{enter-client-id-here}\" \\\n --client-secret=\"{enter-client-secret-here}\"\n```\n\nFollow the on-screen instructions shown at `http://localhost:9000` in your web browser. \nOn completion Amazon will return your `refresh_token` - which you will require to [send audio](#file-audio) or [recorded voice](#microphone-audio).\n\n## Steaming audio to AVS\n`alexa_client.send_audio_file` streaming uploads a file-like object to AVS for great latency. The file-like object can be an actual file on your filesystem, an in-memory BytesIo buffer containing audio from your microphone, or even audio streaming from [your browser over a websocket in real-time](https://github.com/richtier/alexa-browser-client).\n\nAVS requires the audio data to be 16bit Linear PCM (LPCM16), 16kHz sample rate, single-channel, and little endian.\n\n## Persistent AVS connection\n\nCalling `alexa_client.connect()` creates a persistent connection to AVS. A thread runs that pings AVS after 4 minutes of no request being made to AVS. This prevents the connection getting forcefully closed due to inactivity.\n\n## Unit test ##\n\nTo run the unit tests, call the following commands:\n\n```sh\ngit clone git@github.com:richtier/alexa-voice-service-client.git\npip install -e .[test]\nmake test_requirements\nmake test\n```\n\n## Other projects ##\n\nThis library is used by [alexa-browser-client](https://github.com/richtier/alexa-browser-client), which allows you to talk to Alexa from your browser.\n\n[code-climate-image]: https://codeclimate.com/github/richtier/alexa-voice-service-client/badges/gpa.svg\n[code-climate]: https://codeclimate.com/github/richtier/alexa-voice-service-client\n\n[circle-ci-image]: https://circleci.com/gh/richtier/alexa-voice-service-client/tree/master.svg?style=svg\n[circle-ci]: https://circleci.com/gh/richtier/alexa-voice-service-client/tree/master\n\n[codecov-image]: https://codecov.io/gh/richtier/alexa-voice-service-client/branch/master/graph/badge.svg\n[codecov]: https://codecov.io/gh/richtier/alexa-voice-service-client\n\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/richtier/alexa-voice-service-client", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "avs-client", "package_url": "https://pypi.org/project/avs-client/", "platform": "", "project_url": "https://pypi.org/project/avs-client/", "project_urls": { "Homepage": "https://github.com/richtier/alexa-voice-service-client" }, "release_url": "https://pypi.org/project/avs-client/1.3.1/", "requires_dist": [ "hyper (>=0.7.0<1.0.0)", "requests-toolbelt (>=0.8.0<1.0.0)", "requests (>=2.19.1<3.0.0)", "resettabletimer (<1.0.0,>=0.6.3)", "pydub (<1.0.0,>=0.23.0) ; extra == 'demo'", "pyaudio (<1.0.0,>=0.2.11) ; extra == 'demo'", "flake8 (==3.4.0) ; extra == 'test'", "freezegun (==0.3.9) ; extra == 'test'", "pytest-cov (==2.5.1) ; extra == 'test'", "pytest-sugar (==0.9.0) ; extra == 'test'", "pytest (==3.2.0) ; extra == 'test'", "requests-mock (==1.3.0) ; extra == 'test'", "codecov (==2.0.9) ; extra == 'test'", "twine (<2.0.0,>=1.11.0) ; extra == 'test'", "wheel (<1.0.0,>=0.31.0) ; extra == 'test'", "setuptools (<39.0.0,>=38.6.0) ; extra == 'test'" ], "requires_python": "", "summary": "Python Client for Alexa Voice Service (AVS)", "version": "1.3.1" }, "last_serial": 4709462, "releases": { "0.4.0": [ { "comment_text": "", "digests": { "md5": "1d3125311c9e10603284ec572e27ad19", "sha256": "16ba682e4c1f735ce798a0d8c3fd439e72e23fae6ec206d44d6348a27f905c18" }, "downloads": -1, "filename": "avs_client-0.4.0-py3-none-any.whl", "has_sig": false, "md5_digest": "1d3125311c9e10603284ec572e27ad19", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6243, "upload_time": "2017-08-26T22:04:27", "url": "https://files.pythonhosted.org/packages/77/99/35831e3d120bbc0ee7874a39ddacdb3e499396db3ef80d3ac99590996126/avs_client-0.4.0-py3-none-any.whl" } ], "0.4.2": [ { "comment_text": "", "digests": { "md5": "9cb139dc65923f55ed05fcc757b32618", "sha256": "f60bc11640207b4bb2a8fbc57b9bbb231e97868a7aeecb2dc3a76089b0fe97a3" }, "downloads": -1, "filename": "avs_client-0.4.2-py3-none-any.whl", "has_sig": false, "md5_digest": "9cb139dc65923f55ed05fcc757b32618", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13875, "upload_time": "2017-08-26T22:28:25", "url": "https://files.pythonhosted.org/packages/d9/cd/31619bcc5beaf87f68e51b5991b25ba9ea30faaadd5e471e26bc316a8651/avs_client-0.4.2-py3-none-any.whl" } ], "0.5.0": [ { "comment_text": "", "digests": { "md5": "baea7bf4ffab2c2f244aa303e4a8c934", "sha256": "a7c6ef66d4cb1e31464427266b3f562da7c73d813e4eb6dc4b38fb5d3c1ae3fc" }, "downloads": -1, "filename": "avs_client-0.5.0-py3-none-any.whl", "has_sig": false, "md5_digest": "baea7bf4ffab2c2f244aa303e4a8c934", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13881, "upload_time": "2017-08-28T22:15:48", "url": "https://files.pythonhosted.org/packages/5b/94/f46d997e136f7d42fdf72bf811b43c4a3ac9cac64e88b0d562ad0c83feca/avs_client-0.5.0-py3-none-any.whl" } ], "0.5.1": [ { "comment_text": "", "digests": { "md5": "04e9780f203886e9b9327f460575d992", "sha256": "a0890737d7dad00b8feeeafacf8dbe455538d38270ca2d2f1a316daaed458fa7" }, "downloads": -1, "filename": "avs_client-0.5.1-py3-none-any.whl", "has_sig": false, "md5_digest": "04e9780f203886e9b9327f460575d992", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13822, "upload_time": "2017-08-29T22:32:08", "url": "https://files.pythonhosted.org/packages/b7/0e/7b1bd7290f53fadaaaf503013b1c638dea4752567676a113f1faa11b7f90/avs_client-0.5.1-py3-none-any.whl" } ], "0.5.2": [ { "comment_text": "", "digests": { "md5": "4b4b304de67b4b4aa756d6a16a273ad3", "sha256": "37c6a7c7ae720483170134e26a588ddd1ba209c8c8b8f085f7f70b202b835973" }, "downloads": -1, "filename": "avs_client-0.5.2-py3-none-any.whl", "has_sig": false, "md5_digest": "4b4b304de67b4b4aa756d6a16a273ad3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14228, "upload_time": "2017-09-25T20:10:14", "url": "https://files.pythonhosted.org/packages/ca/ef/2c5568f416dc210813102f8ff7f3dd9c8711ecfc3fee80b576ee2d22ff13/avs_client-0.5.2-py3-none-any.whl" } ], "0.6.0": [ { "comment_text": "", "digests": { "md5": "a9a966f1a34106ac663eb16fccdf5951", "sha256": "2c9de95229dcee573b714f2844cf3514ab3168c2ad593393d7e95fb716feea29" }, "downloads": -1, "filename": "avs_client-0.6.0-py3-none-any.whl", "has_sig": false, "md5_digest": "a9a966f1a34106ac663eb16fccdf5951", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14718, "upload_time": "2017-10-03T22:35:00", "url": "https://files.pythonhosted.org/packages/92/4f/380d8c05bc7446f4952bbf82465f974d54287f6f635823942ab2eae206ab/avs_client-0.6.0-py3-none-any.whl" } ], "0.7.0": [ { "comment_text": "", "digests": { "md5": "c9000302ede6b446e601f710b102c958", "sha256": "5c37cbcbc363220ea49238d0d9b1e95f3d7eeb75df4d99cfaa9d6038219b356a" }, "downloads": -1, "filename": "avs_client-0.7.0-py3-none-any.whl", "has_sig": false, "md5_digest": "c9000302ede6b446e601f710b102c958", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14789, "upload_time": "2018-07-17T21:37:12", "url": "https://files.pythonhosted.org/packages/af/ce/acdcbeef214d5d866c5716c4956e78344156b86ead1d13d845ae8ac28d82/avs_client-0.7.0-py3-none-any.whl" } ], "0.7.1": [ { "comment_text": "", "digests": { "md5": "922083988e7957d3be4af09c0a95574e", "sha256": "9e6cbbefd061f3905bf9146fc11759a2a14ca8c3fc695711d1945fa691f6e857" }, "downloads": -1, "filename": "avs_client-0.7.1-py3-none-any.whl", "has_sig": false, "md5_digest": "922083988e7957d3be4af09c0a95574e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14809, "upload_time": "2018-08-16T21:40:30", "url": "https://files.pythonhosted.org/packages/9d/d7/92ed07605adfec15e0238ee4abbffdd1d25938001aa0cf1b5edd5433a8fc/avs_client-0.7.1-py3-none-any.whl" } ], "1.0.0": [ { "comment_text": "", "digests": { "md5": "6e3618349670e6243979afe4afd6a765", "sha256": "d6200dfdaff2e205043e65b13361ce0f50cbf5db624616d5b0db515ccb858259" }, "downloads": -1, "filename": "avs_client-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "6e3618349670e6243979afe4afd6a765", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13138, "upload_time": "2018-12-20T23:01:04", "url": "https://files.pythonhosted.org/packages/ea/d2/ce07183e9b382ee47696ab40e4de881f03136517095ef1f43ecbb5722574/avs_client-1.0.0-py3-none-any.whl" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "c6e5fe4ccbfe792d6eb1c1ebe86c36ff", "sha256": "4ba91ac7a4876362ed70161bf7a4031571d6d10e0187e3ecd1633edb50d1392b" }, "downloads": -1, "filename": "avs_client-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "c6e5fe4ccbfe792d6eb1c1ebe86c36ff", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13132, "upload_time": "2018-12-20T23:21:15", "url": "https://files.pythonhosted.org/packages/bd/9a/b86c0ce725fcc5e5861c339a1486b2b61383175fa796d994d9ad001dd448/avs_client-1.0.1-py3-none-any.whl" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "5208c24682354d00f443503e14df2a7d", "sha256": "f4730db4df27de767e0daf84a0a4b84a9506d17b6fec858f8eead9c645a1fd3d" }, "downloads": -1, "filename": "avs_client-1.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "5208c24682354d00f443503e14df2a7d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13325, "upload_time": "2018-12-31T20:27:36", "url": "https://files.pythonhosted.org/packages/08/e5/7419bec470529656a2ad9e82cc015fdbda44ba290843f65f533fbe3b2527/avs_client-1.1.0-py3-none-any.whl" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "e61c87743f012bf666491fc73f8adbb3", "sha256": "ec363c832041d801c338b9b406e3f2d807bfce4839f11103c44ae7bcf4a1be5c" }, "downloads": -1, "filename": "avs_client-1.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "e61c87743f012bf666491fc73f8adbb3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14956, "upload_time": "2019-01-04T23:42:28", "url": "https://files.pythonhosted.org/packages/8f/a3/ce41542dc20351ceb208e5ac69244f94a1694dbd5148ac9cb7b4bed007ca/avs_client-1.2.0-py3-none-any.whl" } ], "1.3.0": [ { "comment_text": "", "digests": { "md5": "6096d853f05d475fa122674fe32a0051", "sha256": "f173bfca2d5197e65dc907800e5189d1ac9bac10559499d6d96cc012056da08e" }, "downloads": -1, "filename": "avs_client-1.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "6096d853f05d475fa122674fe32a0051", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14780, "upload_time": "2019-01-16T23:12:02", "url": "https://files.pythonhosted.org/packages/0a/0a/9459ae2e35cf929960564d119217a340e0991ca405e4f6ee206204bb992d/avs_client-1.3.0-py3-none-any.whl" } ], "1.3.1": [ { "comment_text": "", "digests": { "md5": "74ad5066aba9e736006840d25c96753d", "sha256": "62320aa9feea4ac49649f17b8b74116a45bca39ca76215b9466dee9157f5839e" }, "downloads": -1, "filename": "avs_client-1.3.1-py3-none-any.whl", "has_sig": false, "md5_digest": "74ad5066aba9e736006840d25c96753d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14845, "upload_time": "2019-01-17T19:51:31", "url": "https://files.pythonhosted.org/packages/1d/18/00133539ef8983eff1d979e87b4180dc53e79d378d3403585972e3e2be20/avs_client-1.3.1-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "74ad5066aba9e736006840d25c96753d", "sha256": "62320aa9feea4ac49649f17b8b74116a45bca39ca76215b9466dee9157f5839e" }, "downloads": -1, "filename": "avs_client-1.3.1-py3-none-any.whl", "has_sig": false, "md5_digest": "74ad5066aba9e736006840d25c96753d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 14845, "upload_time": "2019-01-17T19:51:31", "url": "https://files.pythonhosted.org/packages/1d/18/00133539ef8983eff1d979e87b4180dc53e79d378d3403585972e3e2be20/avs_client-1.3.1-py3-none-any.whl" } ] }