Esempio n. 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 StopStreaming()
    {
        if (m_ws == null)
        {
            Debug.Log("Stream not connected.");
            return;
        }

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

        var stopStreaming = new StopStreamingPayload();
        var msg           = JsonUtility.ToJson(stopStreaming);

        m_ws.Send(msg);

        m_sttState = STT_State.Stopped;

        UIBinding.OnStreamingStopped();
    }