Beispiel #1
0
        public static void RecordMode(string libraryName, string text, string outputFilename)
        {
            SoundRecorder recorder = new SoundRecorder(outputFilename);

            recorder.PostWait = 300;

            var engines = SpeechController.GetVoiceroid2SpeechEngine();
            var engine  = SpeechController.GetVoiceroid2Instance(libraryName);

            if (engine == null)
            {
                Console.WriteLine($"{libraryName} を起動できませんでした。");
                return;
            }

            engine.Activate();
            engine.Finished += (s, a) =>
            {
                Task t = recorder.Stop();
                t.Wait();
                finished = true;
                engine.Dispose();
            };
            recorder.Start();
            engine.Play(text);
        }
Beispiel #2
0
        private void startRecording()
        {
            int captureDeviceId = getActiveCaptureDeviceId();

            if (captureDeviceId >= 0)
            {
                try
                {
                    btnRecord.Image = Properties.Resources.Speak_Off;

                    soundRecorder = new SoundRecorder(captureDeviceId);
                    soundRecorder.RecordingStoppedEvent += SoundRecorder_RecordingStoppedEvent;

                    startTimerRecordingDuration();
                    soundRecorder.Start();
                }
                catch (Exception ex)
                {
                    stopTimerRecordingDuration();
                    soundRecorder = null;
                    throw ex;
                }
            }
            else
            {
                MessageBoxManager.ShowMessageBoxError(MESSAGE_NO_CAPTUREDEVICE_FOUND_STRING);
            }
        }
Beispiel #3
0
 void Start()
 {
     fileSlot       = null;
     networkAddress = "192.168.219.118";
     s = GameObject.Find("RecordManager").GetComponent <SoundRecorder>();
     // OpenServer();
     ConnectClientToServer();
 }
Beispiel #4
0
 private void Awake()
 {
     userSettings = GlobalVariables.SOUSERSETTINGS;
     Load_User_Settings();
     Create_Save_Directory();
     SoundRecorder.Play_Music(GlobalVariables.MAINMENUMUSIC);
     DOTween.Init(true, false, LogBehaviour.ErrorsOnly);
     GetComponent <Window>().Call_Window(gameObject.transform);
 }
Beispiel #5
0
 public void Changes_Made()
 {
     if (setUserSettings)
     {
         return;
     }
     confirmButton.gameObject.SetActive(true);
     SoundRecorder.Play_Effect(GlobalVariables.CLICKEFFECT);
 }
Beispiel #6
0
 public void Change_Volume_Settings()
 {
     if (setUserSettings)
     {
         return;
     }
     userSettings.soundSettings.effectsVolume = effectsVolumeSlider.value;
     userSettings.soundSettings.musicVolume   = musicVolumeSlider.value;
     SoundRecorder.Play_Effect(GlobalVariables.CLICKEFFECT);
 }
Beispiel #7
0
 public void Change_Language()
 {
     if (initialise)
     {
         return;
     }
     Unmap_Dropdown_Options();
     userSettings.languagePack = languagePacks[languageDropdown.value].packName;
     Save_User_Settings();
     SoundRecorder.Play_Effect(GlobalVariables.CLICKEFFECT);
 }
Beispiel #8
0
 private void CreateSoundRecorder()
 {
     try
     {
         _soundRecorder = new SoundRecorder();
         _soundRecorder.RecodingTimerStoped += RecodingTimerStoped;
     }
     catch (MicrophoneNotSupportedException ex)
     {
         tbErrorMessage.ErrorMessage = ex.Message;
     }
 }
 private void CreateSoundRecorder()
 {
     try
     {
         _soundRecorder = new SoundRecorder();
         _soundRecorder.RecodingTimerStoped += RecodingTimerStoped;
     }
     catch (MicrophoneNotSupportedException ex)
     {
         txtSpeechOutput.Text = ex.Message;
     }
 }
Beispiel #10
0
 private void CreateSoundRecorder()
 {
     try
     {
         _soundRecorder = new SoundRecorder();
         _soundRecorder.RecodingTimerStoped += RecodingTimerStoped;
     }
     catch (MicrophoneNotSupportedException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void CreateSoundRecorder()
 {
     try
     {
         _soundRecorder = new SoundRecorder();
         _soundRecorder.RecodingTimerStoped += RecodingTimerStoped;
     }
     catch (MicrophoneNotSupportedException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #12
0
 private void CreateSoundRecorder()
 {
     try
     {
         _soundRecorder = new SoundRecorder();
         _soundRecorder.RecodingTimerStoped += RecodingTimerStoped;
     }
     catch (MicrophoneNotSupportedException ex)
     {
         txtSpeechOutput.Text = ex.Message;
     }
 }
Beispiel #13
0
        private static void WhisperMode(string libraryName, string text)
        {
            string tempFile    = "normal.wav";
            string whisperFile = "whisper.wav";

            var engines = SpeechController.GetVoiceroid2SpeechEngine();
            var engine  = SpeechController.GetVoiceroid2Instance(libraryName);

            if (engine == null)
            {
                Console.WriteLine($"{libraryName} を起動できませんでした。");
                return;
            }
            engine.Activate();

            SoundRecorder recorder = new SoundRecorder(tempFile);

            {
                recorder.PostWait = 300;

                engine.Finished += (s, a) =>
                {
                    finished = true;
                };

                recorder.Start();
                engine.Play(text);
            }

            while (!finished)
            {
                Thread.Sleep(100);
            }
            engine.Dispose();
            Task t = recorder.Stop();

            t.Wait();
            // ささやき声に変換
            Whisper whisper = new Whisper();
            Wave    wave    = new Wave();

            wave.Read(tempFile);
            whisper.Convert(wave);
            wave.Write(whisperFile, wave.Data);

            //// 変換した音声を再生
            SoundPlayer sp = new SoundPlayer();

            sp.Play(whisperFile);
        }
Beispiel #14
0
        public void StartRecording()
        {
            this.label4.Text = "00:00.00";
            var channels   = (int)((ChannelsType)this.comboBox2.SelectedItem);
            var sampleRate = (int)(SamplingRates[this.comboBox1.SelectedItem as string]);
            var fileFormat = new WaveFormat(sampleRate, channels);

            this._recorder = new SoundRecorder(fileFormat, this.textBox1.Text);
            this._recorder.Start();
            this._recordingTimer = this.CreateTimer();
            this._stopwatch      = Stopwatch.StartNew();
            this.button1.Enabled = false;
            this.button2.Enabled = true;
        }
    //////////
    // collect references to managed objects
    // and release references to non-active objects
    //////////
    void onSceneLoaded(Scene scene, LoadSceneMode mode)
    {
        onKey = new ConcurrentQueue <Action <string, bool> >(); // clear keyhandler queue on scene change

        if ((bool)GetSetting("isLegacyExperiment") == true)
        {
            Debug.Log("Legacy Experiment");
            return;
        }

        // text displayer
        GameObject canvas = GameObject.Find("MemoryWordCanvas");

        if (canvas != null)
        {
            textDisplayer = canvas.GetComponent <TextDisplayer>();
            Debug.Log("Found TextDisplay");
        }

        // input reporters
        GameObject inputReporters = GameObject.Find("DataManager");

        if (inputReporters != null)
        {
            scriptedInput   = inputReporters.GetComponent <ScriptedEventReporter>();
            peripheralInput = inputReporters.GetComponent <PeripheralInputReporter>();
            uiInput         = inputReporters.GetComponent <UIDataReporter>();
            Debug.Log("Found InputReporters");
        }

        GameObject voice = GameObject.Find("VAD");

        if (voice != null)
        {
            voiceActity = voice.GetComponent <VoiceActivityDetection>();
            Debug.Log("Found VoiceActivityDetector");
        }

        GameObject video = GameObject.Find("VideoPlayer");

        if (video != null)
        {
            videoControl = video.GetComponent <VideoControl>();
            video.SetActive(false);
            Debug.Log("Found VideoPlayer");
        }

        GameObject sound = GameObject.Find("Sounds");

        if (sound != null)
        {
            lowBeep   = sound.transform.Find("LowBeep").gameObject.GetComponent <AudioSource>();
            lowerBeep = sound.transform.Find("LowerBeep").gameObject.GetComponent <AudioSource>();
            highBeep  = sound.transform.Find("HighBeep").gameObject.GetComponent <AudioSource>();
            playback  = sound.transform.Find("Playback").gameObject.GetComponent <AudioSource>();
            Debug.Log("Found Sounds");
        }

        GameObject soundRecorder = GameObject.Find("SoundRecorder");

        if (soundRecorder != null)
        {
            recorder = soundRecorder.GetComponent <SoundRecorder>();
            Debug.Log("Found Sound Recorder");
        }
    }
		private void CreateSoundRecorder()
		{
			try
			{
				_soundRecorder = new SoundRecorder();
				_soundRecorder.RecodingTimerStoped+=RecodingTimerStoped;
			}
			catch (MicrophoneNotSupportedException ex)
			{
				tbErrorMessage.ErrorMessage = ex.Message;
			}
		}
Beispiel #17
0
        static void Main(string[] args)
        {
            bool showUsage = true;

            if (args.Length >= 1) // requires port at least
            {
                try
                {
                    // todo: validate with a regex (ip or name)

                    int port = int.Parse(args[0]);
                    if (port > 0 && port < 65536)
                    {
                        showUsage = false;

                        String adrs = "127.0.0.1";
                        if (args.Length >= 2) adrs = args[1];

                        // todo: retreive list of devices and select from/display it in Show Usage

                        // todo: parse and set these parameters
                        SampleRate rate = SampleRate.Rate11KHz;
                        SampleSize size = SampleSize.Bits8;
                        short channels = 1;

                        SoundRecorder recorder = new SoundRecorder(SoundDeviceType.Default, rate, size, channels);
                        UdpClient udpClient = new UdpClient(adrs, port);
                        Console.WriteLine("Sending sound packets on UDP port " + port);
                        try
                        {
                            recorder.Start("");
                            while (recorder.Capturing())
                            {
                                //Sit here and wait for a message to arrive
                                recorder.NotificationEvent.WaitOne(System.Threading.Timeout.Infinite, true);

                                recorder.SendCapturedData(udpClient);
                            }

                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.ToString());
                            Console.WriteLine("Hit any key to continue");
                            Console.ReadKey();
                        }
                        finally
                        {
                            recorder.Stop();
                            udpClient.Close();
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }
            }
            if (showUsage)
            {
                Console.WriteLine("Send direct sound data as UDP packets.");
                Console.WriteLine("USAGE: UDPSoundSender targetIP port [8000 8 1]");
                Console.WriteLine("where:");
                Console.WriteLine("  targetIP is address where to send the packets (yes, multicast addresses should works!)");
                Console.WriteLine("  port is the one of the target ip listening");
                Console.WriteLine("  [optional parameters]");
                Console.WriteLine("  8000 is the default sample rate (choose 8000, 11025, 22050, 44100 or 48000 sample/sec)");
                Console.WriteLine("  8 is the default bit depth (choose 8 or 16 bits)");
                Console.WriteLine("  1 is the channels selected (choose 1 or 2 channels)");

                Console.WriteLine("Hit any key to exit");
                Console.Read();
            }
        }