如何使用Amazon Voice Service或Alexa对我的应用程序进行语音查询

问题描述 投票:0回答:1

在开发与Android应用程序集成的物联网设备时,我遇到了这个问题。

我希望实现的是与我的应用程序交谈,例如,“Alexa,炊具内的温度是多少?”。要获取此信息,我有一个Android应用程序通过蓝牙和应用程序连接到智能电磁炉,而不是从电磁炉读取温度信息。

现在我如何在我的Android应用程序中获取查询,如何将我的响应返回为“当前炊具温度为100摄氏度”。而alexa可以为我表达它。

这是我到目前为止所做的。

  1. 我用amazon开发者控制台创建了一个帐户
  2. 在那里注册我的应用程序并将API密钥复制到我的android项目中
  3. 在我的android项目中添加了他们的lib
  4. 使用登录亚马逊服务获取accessToken requestContext = RequestContext.create(this) requestContext.registerListener(object : AuthorizeListener() { override fun onSuccess(authorizeResult: AuthorizeResult) { accessToken = authorizeResult.accessToken Timber.d("Access Token: %s", accessToken) } override fun onCancel(auth: AuthCancellation?) { Timber.e(auth?.description) } override fun onError(error: AuthError) { Timber.e(error, error.localizedMessage) } }) signInBtn.setOnClickListener { AuthorizationManager.authorize( AuthorizeRequest.Builder(requestContext) .addScopes(ProfileScope.profile(), ProfileScope.postalCode()) .build() ) }

这是清单的相关声明

<activity android:name="com.amazon.identity.auth.device.workflow.WorkflowActivity"
    android:theme="@android:style/Theme.NoDisplay"
    android:allowTaskReparenting="true"
    android:launchMode="singleTask">
    <intent-filter>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <!-- android:host must use the full package name found in Manifest General Attributes -->
        <data android:host="${applicationId}" android:scheme="amzn"/>
    </intent-filter>
</activity>

我一直在关注this文档。

我需要做什么才能在我的应用程序中获取查询以处理并返回结果?还是可以的?

android iot alexa alexa-voice-service amazon-lwa
1个回答
1
投票

您需要创建一个智能家居技能来实现它,您需要前进的方式

  1. 创建智能家居技能,参考文档here
  2. 一旦你创建了一个智能家居技能(你将在这个过程中创建一个后端服务器),并且用户在此之后启用了他的Alexa帐户中的技能,只要用户询问“Alexa,电磁炉内的温度是多少?”您将获得一个指令到您的服务器,然后您可以将其路由到Android应用程序并让Android应用程序直接或通过您的服务器发送响应AVS。
© www.soinside.com 2019 - 2024. All rights reserved.