首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >统一中的Android语音识别

统一中的Android语音识别
EN

Stack Overflow用户
提问于 2022-12-04 17:56:40
回答 1查看 21关注 0票数 -1

我正在寻找一种方法,使统一识别用户的语音在Android构建。我为Windows找到了一个解决方案:youtube.com/watch?v=29vyEOgsW8s&t=612 s,但我需要Android。我不需要它把演讲变成文字,我只想在正确发音的单词后面出现一个小图像。会感谢您的任何建议,谢谢!我已经尝试过一些东西,但是它没有起作用,而且我在c#方面也不是很好。尽管如此,我还是很乐意得到任何帮助。

EN

回答 1

Stack Overflow用户

发布于 2022-12-04 18:35:58

您所引用的视频使用的是Windows.Speech API,对于Android.Speech您可能希望使用Android.Speech包。我不知道是否仍然是这样,但是您可能需要在清单文件中添加以下内容才能使用它:

代码语言:javascript
运行
复制
<intent>
    <action android:name="android.speech.RecognitionService" />
</intent>

至于统一集成,统一确实有一个内置的麦克风类,或者如果您可以访问Android包:

代码语言:javascript
运行
复制
private const int Voice = 10;
private string _recognizedText;

private void Start()
{
    // Check if the device supports speech recognition
    if (!Android.Speech.Recognition.IsRecognitionAvailable(this))
    {
        Debug.LogError("Speech recognition is not available on this device!");
        return;
    }

    // Create a new intent for speech recognition
    var intent = new Intent(RecognizerIntent.ActionRecognizeSpeech);
    // Set the language for the intent
    intent.PutExtra(RecognizerIntent.ExtraLanguage, Java.Util.Locale.Default);
    // Start the activity for speech recognition
    StartActivityForResult(intent, Voice);
}

protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
    base.OnActivityResult(requestCode, resultCode, data);

    if (requestCode == Voice && resultCode == Result.Ok)
    {
        // Get the recognized text from the intent
        _recognizedText = data.GetStringExtra(RecognizerIntent.ExtraResultsRecognition);
        Debug.Log("Recognized text: " + _recognizedText);
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74679383

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档