【问题标题】:How to implement Xamarin Speech Recognition如何实现 Xamarin 语音识别
【发布时间】:2020-06-13 05:50:27
【问题描述】:

我是 xamarin 的新手,我想知道是否可以实现这种语音识别:

首先用户输入“Hello”,但文本输出将是“Hi”?

我找到了这个链接:Android speech recognition pass data back to Xamarin Forms

但它只将语音“Hello”输出为文本“Hello”。

【问题讨论】:

  • 可以吗?

标签: android xamarin xamarin.forms


【解决方案1】:

语音识别通常涉及将您所说的内容翻译成文本。如果您需要更改其内容,也许您可​​以尝试在转换后直接进行一些判断,并根据您的要求进行更改,例如更改上面链接中的结果:

MainActivity OnActivityResult中:

    const int VOICE = 10;
    protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
    {
        base.OnActivityResult(requestCode, resultCode, data);
        if (requestCode == VOICE)
        {
            if (resultCode == Result.Ok)
            {
                var matches = data.GetStringArrayListExtra(RecognizerIntent.ExtraResults);
                if (matches.Count != 0)
                {
                    var textInput = matches[0];
                    if (textInput.Length > 500)
                        textInput = textInput.Substring(0, 500);

                    //make a judgment and change the value
                    if(textInput.Eques("hello")){
                        textInput = "Hi";
                    }
                    SpeechToText_Android.SpeechText = textInput;
                }
            }
            SpeechToText_Android.autoEvent.Set();
        }
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-27
    • 1970-01-01
    • 2020-05-03
    • 2017-12-16
    • 1970-01-01
    相关资源
    最近更新 更多