在你的Unity項目中建立Plugins文件夾ide
將如下兩個dll文件考入Plugins文件夾中code
CustomMarshalers.dll
Interop.SpeechLib.dllit
而後就能夠在項目的C#腳本中進行使用了io
例:class
using System.Collections; using System.Collections.Generic; using UnityEngine; using SpeechLib; public class Voice : MonoBehaviour { private void Start() { SpVoice voice=new SpVoice(); voice.Speak("你好"); } }
把腳本隨便掛到場景中的任意物體上引用
運行場景,你就會聽到稍顯機械的女聲讀出「你好」腳本
注:不要在VS中添加引用speechlib,那樣作沒用,還報錯項目