Пример #1
0
    public void ToggleMicrophone()
    {
        if (!Microphone.IsRecording(null))
        {
            m_recording = Microphone.Start(null, true, 15, 44100);

            Conversation.StartStreaming();

            if (m_recording != null)
            {
                Debug.LogFormat("Mic on: {0}", Microphone.devices[0]);
            }

            UIBinding.OnStreamingStarted();
        }
        else
        {
            Microphone.End(null);
            Conversation.StopStreaming();

            TestSource.clip = m_recording;
            TestSource.Play();

            UIBinding.OnStreamingStopped();
        }
    }
    public void StartStreaming()
    {
        if (m_ws == null)
        {
            Debug.Log("Stream not connected.");
            return;
        }

        if (m_sttState == STT_State.Started)
        {
            return;
        }

        var startMsg = new StartStreamingPayload(44100);
        var msg      = JsonUtility.ToJson(startMsg);

        m_ws.Send(msg);

        m_sttState = STT_State.Started;

        UIBinding.OnStreamingStarted();
    }