Example #1
0
 void FixedUpdate()
 {
     if (selectedTower != null && Input.GetKeyDown(KeyCode.Escape))
     {
         UpgradeButton.SetActive(false);
         upgradeCostText.SetActive(false);
         SynergizeButton.SetActive(false);
         selectedTower.transform.parent.gameObject.transform.GetChild(1).gameObject.SetActive(false);
         UpgradeText.SetActive(false);
         aTowerIsSelected = false;
         TowerStatsParent.SetActive(false);
         if (WaveGen.totalAmountOfEnemiesToSpawn <= WaveGen.enemiesSpawnedInThisWave && aTowerIsSelected == false && WaveGen.spawningTimerToggleStatic == true)
         {
             WaveGen.setSpawningTimerOff();
         }
         if (WaveGen.totalAmountOfEnemiesToSpawn > WaveGen.enemiesSpawnedInThisWave)
         {
             WaveGen.callWaveButtonStatic.SetActive(false);
         }
         towerInfoAndOptionsMenuButtonsState = true;
         selectedTower = null;
     }
     if (selectedTower != null)
     {
         OptionsMenuButton.SetActive(false);
         TowerInfoButton.SetActive(false);
         WaveGen.callWaveButtonStatic.SetActive(false);
     }
     if (selectedTower == null && WaveGen.totalAmountOfEnemiesToSpawn <= WaveGen.enemiesSpawnedInThisWave)
     {
         OptionsMenuButton.SetActive(true);
         TowerInfoButton.SetActive(true);
         WaveGen.callWaveButtonStatic.SetActive(true);
     }
 }
Example #2
0
    public void RequestSpeech(AudioClip audio, GameObject receiver, string callback)
    {
        float[] clipData = new float[audio.samples * audio.channels];
        audio.GetData(clipData, 0);
        WaveGen.WaveFormatChunk format = new WaveGen().MakeFormat(audio);

        try
        {
            string     filename = GetTempFileName() + ".wav";
            FileStream stream   = File.OpenWrite(filename);
            new WaveGen().Write(clipData, format, stream);
            stream.Close();

            Debug.Log("Request Start time: " + DateTime.Now.ToLongTimeString());

            if (requestFactory == null)
            {
                requestFactory = BuildRequestFactory(RequestFactory.ScopeTypes.Speech);
            }

            if (clientToken == null)
            {
                clientToken = GetAccessToken();
            }

            if (null != clientToken)
            {
                requestFactory.ClientCredential = clientToken;
            }

            ATT_MSSDK.Speechv3.SpeechResponse response = SpeechToTextService(filename, "Generic", "audio/wav");
            string speechOutput = response.Recognition.NBest[0].ResultText;
            if (clientToken == null)
            {
                clientToken = requestFactory.ClientCredential;
                SaveAccessToken();
            }

            Debug.Log("Response received time: " + DateTime.Now.ToLongTimeString());
            showProcess = false;
            Debug.Log("response: " + speechOutput);
            File.Delete(filename);
        }
        catch (System.Exception e)
        {
            Debug.LogError(e);
        }
    }
Example #3
0
        public async Task beepCmd()
        {
            string  filePath = @"C:\Users\KernelSanders\Desktop\test.wav";
            WaveGen wave     = new WaveGen(WaveType.Noise);

            wave.Save(filePath);
            await _service.JoinAudio(Context.Guild, (Context.User as IVoiceState).VoiceChannel);

            await _service.SendAudioAsync(Context.Guild, Context.Channel, filePath);

            await _service.LeaveAudio(Context.Guild);

            //SoundPlayer player = new SoundPlayer(filePath);
            //player.PlaySync();

            wave.Save(filePath, true);
        }
    IEnumerator DoRecording()
    {
        Debug.Log("Recording");
        audio.clip = Microphone.Start(null, false, 5, 8000);
        yield return(new WaitForSeconds(5));

        Debug.Log("Playing");
        audio.Play();
        Microphone.End(null);

        float[] clipData = new float[audio.clip.samples * audio.clip.channels];
        audio.clip.GetData(clipData, 0);

        //Format to 8KHz sampling rate
        WaveGen.WaveFormatChunk format = new WaveGen().MakeFormat(audio.clip);

        string     filename = "recordedSpeech.wav";
        FileStream stream   = File.OpenWrite(filename);

        new WaveGen().Write(clipData, format, stream);
        stream.Close();

        ATT_MSSDK.Speechv3.SpeechResponse response = SpeechToTextService(filename, "Generic", "audio/wav");
        string speechOutput = response.Recognition.NBest[0].ResultText;

        Debug.Log(speechOutput);

        string text = speechOutput.ToLower();

        if (text.Contains("red"))
        {
            gameObject.renderer.material.color = Color.red;
        }

        if (text.Contains("green"))
        {
            gameObject.renderer.material.color = Color.green;
        }

        if (text.Contains("blue"))
        {
            gameObject.renderer.material.color = Color.blue;
        }
    }
	IEnumerator DoRecording()
	{
		Debug.Log("Recording");
		audio.clip = Microphone.Start(null, false, 5, 8000);
		yield return new WaitForSeconds(5);
		Debug.Log("Playing");
		audio.Play();
		Microphone.End(null);

		float[] clipData = new float[audio.clip.samples * audio.clip.channels];
		audio.clip.GetData(clipData, 0);
		
		//Format to 8KHz sampling rate
		WaveGen.WaveFormatChunk format = new WaveGen().MakeFormat(audio.clip);
		
		string filename = "recordedSpeech.wav";
		FileStream stream = File.OpenWrite(filename);
		
		new WaveGen().Write(clipData, format, stream);
		stream.Close();

        ATT_MSSDK.Speechv3.SpeechResponse response = SpeechToTextService(filename, "Generic", "audio/wav");
        string speechOutput = response.Recognition.NBest[0].ResultText;
        Debug.Log(speechOutput);

		string text = speechOutput.ToLower();
		
		if (text.Contains("red"))
		{
			gameObject.renderer.material.color = Color.red;
		}
		
		if (text.Contains("green"))
		{
			gameObject.renderer.material.color = Color.green;
		}
		
		if (text.Contains("blue"))
		{
			gameObject.renderer.material.color = Color.blue;
		}
	}
    public void RequestSpeech(AudioClip audio, GameObject receiver, string callback)
    {
        float[] clipData = new float[audio.samples * audio.channels];
        audio.GetData(clipData, 0);
        WaveGen.WaveFormatChunk format = new WaveGen().MakeFormat(audio);
        
        try
        {
            string filename = GetTempFileName() + ".wav";
            FileStream stream = File.OpenWrite(filename);
            new WaveGen().Write(clipData, format, stream);
            stream.Close();

            Debug.Log("Request Start time: " + DateTime.Now.ToLongTimeString());

            if (requestFactory == null)
            {
                requestFactory = BuildRequestFactory(RequestFactory.ScopeTypes.Speech);
            }

            if (clientToken ==  null)
            {
                clientToken = GetAccessToken();
            }

            if (null != clientToken)
            {
                requestFactory.ClientCredential = clientToken;
            }

            ATT_MSSDK.Speechv3.SpeechResponse response = SpeechToTextService(filename, "Generic", "audio/wav");
            string speechOutput = response.Recognition.NBest[0].ResultText;
            if (clientToken == null)
            {
                clientToken = requestFactory.ClientCredential;
                SaveAccessToken();
            }

            Debug.Log("Response received time: " + DateTime.Now.ToLongTimeString());
            showProcess = false;
            Debug.Log("response: " + speechOutput);
            File.Delete(filename);
        }
        catch (System.Exception e)
        {
            Debug.LogError(e);
        }
    }