47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class VWU_Baidu : VoiceWakeUp
|
|
{
|
|
[SerializeField]
|
|
string APP_ID = "你的 App ID";
|
|
[SerializeField]
|
|
string API_KEY = "你的 Api Key";
|
|
[SerializeField]
|
|
string SECRET_KEY = "你的 Secret Key";
|
|
|
|
Baidu.Aip.Speech.Asr client;
|
|
public override void Init()
|
|
{
|
|
base.Init();
|
|
client = new Baidu.Aip.Speech.Asr(APP_ID, API_KEY, SECRET_KEY);
|
|
client.Timeout = 60000; // 修改超时时间
|
|
}
|
|
|
|
public override void StartRecgnition(Action<bool> callback)
|
|
{
|
|
base.StartRecgnition(callback);
|
|
}
|
|
|
|
public override void StopRecognition()
|
|
{
|
|
throw new System.NotImplementedException();
|
|
}
|
|
|
|
//public void AsrData()
|
|
//{
|
|
// var data = File.ReadAllBytes("语音pcm文件地址");
|
|
|
|
// // 可选参数
|
|
// var options = new Dictionary<string, object>
|
|
// {
|
|
// {"dev_pid", 1537}
|
|
// };
|
|
// client.Timeout = 120000; // 若语音较长,建议设置更大的超时时间. ms
|
|
// var result = client.Recognize(data, "pcm", 16000, options);
|
|
// Console.Write(result);
|
|
//}
|
|
}
|