using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using SpeechLib;
public class Speech : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.A)) {
StartCoroutine(SpeackVoice());
}
}
IEnumerator SpeackVoice() {
yield return new WaitForSeconds(5);
SpVoice v = new SpVoice();
v.Voice = v.GetVoices(string.Empty, string.Empty).Item(0);
v.Speak("這樣就好了嘛");
yield return new WaitForSeconds(5);
}
}
將Interop.SpeechLib.dll文件導(dǎo)入Unity,然后把上面的腳本掛載到游戲?qū)ο笊暇湍軠y試語音合成的效果了。
經(jīng)測試 調(diào)用v.Speak這個方法會讓程序卡頓,看哪位大佬有什么方法解決文章來源:http://www.zghlxwxcb.cn/news/detail-644442.html
Interop.SpeechLib.dll文件鏈接
https://download.csdn.net/download/yuan9a/21007842?spm=1001.2014.3001.5501
我自己上傳的 免費下載使用的DLL,這么簡單的DLL那些人收費10-50C幣也是夠坑的文章來源地址http://www.zghlxwxcb.cn/news/detail-644442.html
到了這里,關(guān)于Unity調(diào)用微軟SpeechLib.Dll的C#類實現(xiàn)語音合成功能的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!