wordpress - 基于 Alexa Skill 的 WordPress 语音识别
问题描述
我想开发一个 WordPress 插件,允许用户与 WordPress 网站进行语音交互。我希望它基于 Alexa Skill。
这项任务的架构是什么?
解决方案
If you think your use case is relatively standard, you can take a look at VoiceWP, which was built to allow for management of an Alexa skill mostly from within WordPress.
If you need something more custom, you can use the WordPress REST API to provide Alexa with the data you need. With this architecture, your plugin on the WordPress side would just be setting up and managing all the REST API endpoints.
From the top down the architecture looks like this:
This leaves you with 3 pieces to build:
Set up the Alexa Skill
First, you have to set up the skill with the Alexa Skills Kit. This involves setting up things like the name of your skill, the icon, and most importantly, where the skill should look to get it's functionality. In our example, we'll point the skill to an AWS Lambda function.
Set up the Lambda Skill to fulfill the Alexa input
Once the Skill knows to look to the Lambda function for it's functionality, we actually need to code the Lambda function. This can be done in Node.js (JavaScript), Python, Java (Java 8 compatible), C# (.NET Core) or Go. What the Lambda function needs to do is parse the JSON that comes from Alexa and determine which endpoint to call or which parameters to pass to this endpoint. For an example of this in Python, you can check out my example on GitHub.
Set up WordPress endpoints to provide data
Once you have the Lambda function parsing the user's intent and pushing the request to the specific endpoints, you need to write the code from within WordPress to make sure all the endpoints you need are available. This is the part that I'm able to give the least input on because the specific endpoints that you will need are based on your use case, which I don't really know at this point. But for an example of how we created a settings field and returned that value through a custom REST API endpoint, you can see this example on GitHub.
Wrapping up and Extending it Further
So once the data is returned from WordPress, formatted by the Lambda function and returned to Alexa, the user will hear the results of their query.
This can be customized and further functionality added by adding more endpoints to WordPress and more routing to the Lambda function based on new Alexa voice inputs.
Further Reading Watching
If you're interested in learning more, I've given a couple talks about this:
WP REST API as the Foundation of the Open Web Voice stuff starts at 11:06
Voice Is The New Keyboard: Voice Interfaces In 2018 And Beyond - This uses Google Home for the custom skill, but the ideas presented here are the same.
推荐阅读
- python - Python不断与pygame函数崩溃
- excel - Excel 中的数字格式帮助
- python - Pytest参数化测试用例共享一个类变量
- java - 我在我的 Eclipse 项目中添加了一个 jar,但它仍然没有导入
- visual-c++ - 如何要求泛型类型参数的函数实现
- thread-safety - D 成员函数 std.process.environment.toAA 有问题吗?
- reactjs - 如何处理 reactstrap 下拉列表中的选择
- python - Python 3.7 - CSV - Remove quotes from value, quoting=csv.QUOTE_NONE gives error
- processing - 不同类型的论点?
- eclipse - How to disable Eclipse IDE Language Server