using System; using System.Collections; using System.IO; using UnityEngine; using UnityEngine.UIElements; using System.Runtime.InteropServices; using Unity.VisualScripting; public class VoiceController : MonoBehaviour { // Start is called once before the first execution of Update after the MonoBehaviour is created private VisualElement waveForm; private Button voiceBtn; private Coroutine waveCoroutine; private AudioClip audioClip; // 保存的音频 private bool isRecording = false; private string filePathWav, filePathZip; public bool isCommandMode = false; // 是否在命令对话模式下,是的话只显示语音按钮 private DateTime startRecTime, stopRecTime; void OnEnable() { //Debug.Log("voice controller start"); var root = GetComponent().rootVisualElement; var voiceArea = root.Q("voiceArea"); waveForm = voiceArea.Q("waveForm"); voiceBtn = voiceArea.Q