C# 4.0 如何检查用户是否对麦克风讲话?
我想检查用户是否对麦克风讲话。我试过了,但没用。我怎样才能做到这一点 我的代码是:C# 4.0 如何检查用户是否对麦克风讲话?,c#-4.0,audio,unity3d,microphone,C# 4.0,Audio,Unity3d,Microphone,我想检查用户是否对麦克风讲话。我试过了,但没用。我怎样才能做到这一点 我的代码是: using UnityEngine; using System.Collections; public class Example : MonoBehaviour { AudioClip sound; string dname; // Use this for initialization void Start () { } // Update i
using UnityEngine;
using System.Collections;
public class Example : MonoBehaviour
{
AudioClip sound;
string dname;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
foreach(string device in Microphone.devices)
{
dname=device;
}
sound=Microphone.Start(dname,true,10, 44100);
//here check user speak to microphone or not.
}
}
列出您尝试过的库、这些库的效果以及它不起作用的原因会很有帮助。你可以期待你已经尝试过的答案,浪费了回答者和你的时间……至于你的问题,这里有一些解释:它简短地说有一些技巧可以实现你想要的,但这是一个解决方法,而且很混乱。建议您等待Unity3d实现某种API,或者使用其他IDE。我不确定您使用的库是什么,但根据我的经验,系统默认麦克风始终列在系统设备列表的第一位。您似乎正在使用列表中的最后一个设备(在foreach之后)。可能尝试使用设备[0]?