'Speech recognition failed after build using buildplayer

I'm using PhraseRecognitionSystem under windows 10 system. Everything works fine both in Unity Editor and after build made manually in editor. But it failed with message "Speech recognition is not supported on this machine" when I build the application using BuildPlayer script.

I searched all kinds of resolution but none worked! I wonder is there any difference when built automatically by script and manually by Unity Editor?

My Phrase recoginition code like this:

private void CreateRecognizer() {
    if (m_phraseRecognizer != null) {
        m_phraseRecognizer.Dispose();
    }
    m_phraseRecognizer = new KeywordRecognizer(m_keywords, m_ConfidenceLevel);
    m_phraseRecognizer.OnPhraseRecognized += OnPhraseRecognized;
}

and my build code like:

public class BuildTool : MonoBehaviour {
    [MenuItem("Build/Build Win64")]
    public static void MyBuild() {
        BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
        buildPlayerOptions.scenes = new[] { "Assets/Scenes/SampleScene.unity" };
        buildPlayerOptions.locationPathName = Path.Combine(Application.persistentDataPath, "Win64Build", "Test.exe");
        buildPlayerOptions.target = BuildTarget.StandaloneWindows64;
        buildPlayerOptions.options = BuildOptions.None;

        BuildReport report = BuildPipeline.BuildPlayer(buildPlayerOptions);
        BuildSummary summary = report.summary;

        if (summary.result == BuildResult.Succeeded) {
            Debug.Log("Build succeeded: " + summary.totalSize + " bytes");
            OpenDirectory(Path.Combine(Application.persistentDataPath, "Win64Build"));
        }

        if (summary.result == BuildResult.Failed) {
            Debug.Log("Build failed");
        }   
    }
    private static void OpenDirectory(string path) {
        path = path.Replace("/", "\\");
        System.Diagnostics.Process.Start("explorer.exe", path);
    }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source