我正在寻找一种方法,使统一识别用户的语音在Android构建。我为Windows找到了一个解决方案:youtube.com/watch?v=29vyEOgsW8s&t=612 s,但我需要Android。我不需要它把演讲变成文字,我只想在正确发音的单词后面出现一个小图像。会感谢您的任何建议,谢谢!我已经尝试过一些东西,但是它没有起作用,而且我在c#方面也不是很好。尽管如此,我还是很乐意得到任何帮助。
发布于 2022-12-04 18:35:58
您所引用的视频使用的是Windows.Speech
API,对于Android.Speech您可能希望使用Android.Speech包。我不知道是否仍然是这样,但是您可能需要在清单文件中添加以下内容才能使用它:
<intent>
<action android:name="android.speech.RecognitionService" />
</intent>
至于统一集成,统一确实有一个内置的麦克风类,或者如果您可以访问Android包:
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);
}
}
https://stackoverflow.com/questions/74679383
复制相似问题