我正在开发一个用于Kindle Fire的增强型通信应用程序。我使用Fire HD 6作为我的测试设备。我在Xamarin,C#工作。
我知道设备上有语音识别器,因为麦克风图标出现在键盘上,我可以使用它来填充搜索窗口。但是,我的andoid语音识别器代码不起作用。我得到的#34;识别器不存在"错误。以下是我正在使用的代码:
public class VoiceRecognition : Activity
{
private static String TAG = "VoiceRecognition";
private const int VOICE_RECOGNITION_REQUEST_CODE = 1234;
private ListView mList;
public Handler mHandler;
private Spinner mSupportedLanguageView;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
mHandler = new Handler();
SetContentView(Resource.Layout.Main);
Button speakButton = FindViewById<Button>(Resource.Id.btnRecord);
// Check to see if a recognition activity is present
PackageManager pm = PackageManager;
IList<ResolveInfo> activities = pm.QueryIntentActivities(new Intent(RecognizerIntent.ActionRecognizeSpeech), 0);
if (activities.Count != 0)
speakButton.Click += speakButton_Click;
else
{
speakButton.Enabled = false;
speakButton.Text = "Recognizer not present";
}
}
这段代码显然不起作用,但我不知道从哪里开始。如何在此设备上访问语音识别器?
谢谢!
答案 0 :(得分:0)
您可以尝试通过SpeechRecognizer连接到语音识别器(大多数键盘应用都可以这样做)。
尝试另一件事是调用RecognizerIntent活动时的另一个操作,例如还有ACTION_WEB_SEARCH。
答案 1 :(得分:0)
然而,我的andoid语音识别器代码无效。我得到的#34;识别器不存在&#34;错误。
似乎您正在使用Android设备的标准语音API,如果您确定自己的代码并且启用了这些功能,语音识别器仍无法正常工作,我想你可能需要关注Kindle的官方Apis,而不是遵循标准的Android Apis。
看一下这个官方文档:Alexa Voice Service API Overview,它似乎使用HTTP来发送和接收SpeechRecognizer的JSON格式消息。你可以尝试一下。