/* * private void Update() * { * if (Input.GetKeyDown(KeyCode.Space)) * { * * KeyValuePair<int, int> ka= GetMyGradeFromString("***Who *often *(took part in)=join=attend=(participate in) the lectures[lecture] on Chinese *tea *culture", TestT); * Debug.Log(ka.Value + "/" + ka.Key); * } * }*/ #region PartA /// <summary> /// 改卷_PartA /// </summary> /// <param name="audioClip">录音</param> /// <param name="sourceText">原文</param> /// <param name="examLevel">考试难度</param> public bool CheakPartA(AudioClip ac, string path, string sourceText, float examLevel, int maxGrade, System.Action <CheakExamRespondClass> onOK, System.Action <string> onError) { try { if (!File.Exists(path)) { return(false); } if (ac.length >= 120f) { return(false); } PAsourceText = sourceText; PALevel = examLevel; PAmaxGrade = maxGrade; okA = true; tempAStr = ""; if (ac.length > 60f) { bool ok = true; string error = ""; byte[] bytesA = null; byte[] bytesB = null; processACount = 2; ok = WavScissorHelper.GetWavFileScissor(path, path + ".tempA", 0, Mathf.FloorToInt(ac.length / 2f), ref error, ref bytesA); ok = WavScissorHelper.GetWavFileScissor(path, path + ".tempB", Mathf.FloorToInt(ac.length / 2f), Mathf.FloorToInt(ac.length), ref error, ref bytesB); if (!ok) { Debug.LogError(error); GlobalUIManager.guim.CreateNewDialogBox("PartA改卷时出现异常!\nError:" + error); } else { //err StartCoroutine(BaiDuAsrBaseTools.GetMessageFromAudio(bytesA, PartAMsgCallback, "PartA1")); //err StartCoroutine(BaiDuAsrBaseTools.GetMessageFromAudio(bytesB, PartAMsgCallback, "PartA2")); StartCoroutine(PAJianKong(onOK, onError)); } // return(ok); } else { processACount = 1; //err StartCoroutine(BaiDuAsrBaseTools.GetMessageFromAudio(File.ReadAllBytes(path), PartAMsgCallback, "PartA")); StartCoroutine(PAJianKong(onOK, onError)); return(true); } } catch (System.Exception e) { PAError = "抓取错误:" + e.Message + "\n" + e.StackTrace; return(false); } }
static void Cut() { string[] strs = Selection.assetGUIDs; string path = AssetDatabase.GUIDToAssetPath(strs[0]); string errInfo = ""; byte[] data = null; WavScissorHelper.GetWavFileScissor(path, path + ".wav", 0, 100, ref errInfo, ref data); Debug.LogError(errInfo); }
private bool CheakVoice(string path, int length, System.Action <bool, string> result) { try { if (!File.Exists(path)) { return(false); } List <int> myIds = new List <int>(); byte[] audioA = File.ReadAllBytes(path); if (length <= oneLenth) { StartCoroutine(BaiDuAsrBaseTools.GetMessageFromAudio(audioA, AsrCallBack, nowId)); myIds.Add(nowId); classes.Add(myIds); tempActions.Add(myIds, result); nowId += 1; return(true); } int dl = length / oneLenth; //int edl = length % oneLenth; for (int i = 0; i < dl + 1; i++) { byte[] bytei = null; string err = ""; bool ok = WavScissorHelper.GetWavFileScissor(path, path + ".ep", i * oneLenth, Mathf.Clamp((i + 1) * oneLenth, 0, length), ref err, ref bytei); if (ok) { StartCoroutine(BaiDuAsrBaseTools.GetMessageFromAudio(bytei, AsrCallBack, nowId)); myIds.Add(nowId); nowId += 1; } else { GlobalUIManager.guim.CreateNewDialogBox("处理音频时出错!请截图联系开发者!"); break; } } classes.Add(myIds); tempActions.Add(myIds, result); return(true); } catch (System.Exception err) { GlobalUIManager.guim.CreateNewDialogBox("处理音频时出错!请截图联系开发者!\n" + err.Message); return(false); } // WavScissorHelper.GetWavFileScissor(); // StartCoroutine(BaiDuAsrBaseTools.GetMessageFromAudio()) }