仅限于Windows系统PC端,如果是webgl需要接入讯飞语音SDK。
插件链接:https://download.youkuaiyun.com/download/ThreePointsHeat/12914777
调用:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using SpeechLib;
using UnityEngine.UI;
public class Test : MonoBehaviour
{
public InputField input;
public Button button;
SpVoice voice;
void Start()
{
voice = new SpVoice();
button.onClick.AddListener(Button_Event);
}
private void Button_Event() {
voice.Speak(input.text);
}
}
打包的时候注意将Api Compatibility Level改为 .NET 4.x
最后运行打包的exe即可。