public AudioItemPage(bool isNew = false)
        {
            InitializeComponent();
            isNewItem   = isNew;
            paidAlready = false;

            nameEntry.Placeholder          = StartPage.lp.Placeholder;
            IsActive.Text                  = StartPage.lp.IsActive;
            StopRecordingAfterSilence.Text = StartPage.lp.StopRecordingAfterSilence;
            RecordButton.Text              = StartPage.lp.Record;
            SaveButton.Text                = StartPage.lp.Save;
            PlayButton.Text                = StartPage.lp.Play;
            ViewButton.Text                = StartPage.lp.View;
            DeleteButton.Text              = StartPage.lp.Delete;

            audioRecorded = false;

            recorder = new AudioRecorderService
            {
                StopRecordingAfterTimeout = true,
                TotalAudioTimeout         = TimeSpan.FromSeconds(15),
                AudioSilenceTimeout       = TimeSpan.FromSeconds(2)
            };

            player = new AudioPlayer();
            player.FinishedPlaying += Player_FinishedPlaying;
        }
Exemple #2
0
        public RecorderViewModel(IPytorchService tensorFlowService,
                                 bool IsCartPage, string headerText, string contentText,
                                 string callerPage, int secsBeforeRecording = 5,
                                 bool isNewApi = false, string screen = null)
        {
            _tensorFlowService = tensorFlowService;
            isCartPage         = IsCartPage;
            Header             = headerText;
            Content            = contentText;
            _isNewAPI          = isNewApi;
            _screen            = screen;
            Error = "An error occured while recording.Please click back and try again.";

            //page that calls the recorder
            CallerPage = callerPage;


            StartTimer(secsBeforeRecording);

            recorder = new AudioRecorderService
            {
                //StopRecordingAfterTimeout = true,
                // TotalAudioTimeout = TimeSpan.FromSeconds(6),
                StopRecordingOnSilence = true,
                AudioSilenceTimeout    = TimeSpan.FromSeconds(2)
            };
        }
Exemple #3
0
        private void RecordButton_Clicked(object sender, EventArgs e)
        {
            if (recorder == null)
            {
                recorder = new AudioRecorderService()
                {
                    FilePath = recordFilePath,
                    StopRecordingOnSilence = false
                };

                recorder.AudioInputReceived += Recorder_AudioInputReceived;
            }

            if (recorder.IsRecording)
            {
                recorder.StopRecording();
            }
            else
            {
                recorder.StartRecording();

                RecordButton.Text                = $"{AppResources.Recording}";
                RecordButton.IsEnabled           = false;
                RecordStatusLabel.IsVisible      = true;
                RecordCountProgressBar.Progress  = 0;
                RecordCountProgressBar.IsVisible = true;

                timeTimer.Start();
            }
        }
        public MainPage()
        {
            InitializeComponent();

            recorder = new AudioRecorderService
            {
                StopRecordingOnSilence    = true,
                StopRecordingAfterTimeout = true,
                TotalAudioTimeout         = TimeSpan.FromSeconds(15)          // Speech REST API has 15 sec max
            };

            if (Keys.Speech.SubscriptionKey == Keys.Speech.BadSubscriptionKey)
            {
                throw new Exception("Get a Speech API key here: https://azure.microsoft.com/en-us/pricing/details/cognitive-services/speech-api/");
            }

            speechClient = new SpeechApiClient(Keys.Speech.SubscriptionKey, SpeechRegion);

            //	if you need custom endpoint(s) you can create them and pass into the SpeechApiClient constructor:
            //var speechEndpoint = new Endpoint ("westus.stt.speech.microsoft.com", "/speech/recognition");
            //var authEndpoint = new Endpoint ("westus.api.cognitive.microsoft.com", "/sts/v1.0/issueToken");
            //speechClient = new SpeechApiClient (Keys.Speech.SubscriptionKey, SpeechRegion, authEndpoint, speechEndpoint);

            BindingContext = this;
        }
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();
            LoadApplication(new App());

            // The following are all optional settings to change the behavior on iOS

            // this controls whether the library will attempt to set the shared AVAudioSession category, and then reset it after recording completes
            AudioRecorderService.RequestAVAudioSessionCategory(AVAudioSessionCategory.PlayAndRecord);
            // same thing as above, forces the shared AVAudioSession into recording mode, and then reset it after recording completes
            AudioPlayer.RequestAVAudioSessionCategory(AVAudioSessionCategory.PlayAndRecord);

            // allows you to add additional code to configure/change the shared AVAudioSession before each playback instance
            //	this can be used to alter the cateogry, audio port, check if the system will allow your app to access the session, etc.
            //	See https://github.com/NateRickard/Plugin.AudioRecorder/issues/27 for additional info
            AudioPlayer.OnPrepareAudioSession = audioSession =>
            {
                // maybe force audio to route to the speaker?
                var success = audioSession.OverrideOutputAudioPort(AVAudioSessionPortOverride.Speaker, out NSError error);

                // do something else like test if the audio session can go active?

                //if (success)
                //{
                //	audioSession.SetActive (true, out error);
                //}
            };

            // can also do something AFTER audio is played with this callback
            //AudioPlayer.OnResetAudioSession = audioSession => ...

            return(base.FinishedLaunching(app, options));
        }
Exemple #6
0
        public async Task StartRecordAsync()
        {
            IsInRecordingMode = true;

            var filePath = storageFolder.Path + @"\" +
                           DateTime.Now.Year + "-" +
                           DateTime.Now.Month + "-" +
                           DateTime.Now.Day + "_" +
                           DateTime.Now.Hour + "." +
                           DateTime.Now.Minute + "." +
                           DateTime.Now.Second + "." +
                           DateTime.Now.Millisecond + ".wav";

            recorder = new AudioRecorderService
            {
                StopRecordingOnSilence    = true,                    //will stop recording after 2 seconds (default)
                StopRecordingAfterTimeout = true,                    //stop recording after a max timeout (defined below)
                AudioSilenceTimeout       = TimeSpan.FromMilliseconds(Params.SilenceTimeout * 1000),
                SilenceThreshold          = Params.SilenceThreshold, // float between 0 and 1
                TotalAudioTimeout         = TimeSpan.FromSeconds(Params.TimeoutLimit),
                FilePath            = filePath,
                PreferredSampleRate = 16000
            };

            recorder.AudioInputReceived += Recorder_AudioInputReceived;
            //await RecordAudio();
            await recorder.StartRecording();
        }
        public AudioPage() // an example Audio quiz
        {
            InitializeComponent();

            Challenge = new Challenge
            {
                ChallengeID     = 3,
                ChallengeType   = "Audio",
                ChallengeDetail = "Pronounce the word 'Antidisestablishmentarianism'.",
                CorrectAnswer   = "Antidisestablishmentarianism"
            };
            MyAnswer = "";

            recorder = new AudioRecorderService
            {
                TotalAudioTimeout      = TimeSpan.FromSeconds(15),
                StopRecordingOnSilence = true
            };

            player = new AudioPlayer();

            Record.IsEnabled = true;  // Initiate button.
            Stop.IsEnabled   = false; // Initiate button.
            Play.IsVisible   = false; // Initiate button.
            Play.IsEnabled   = false;

            BindingContext = this;
        }
Exemple #8
0
        public ListenPage()
        {
            InitializeComponent();
            //try
            //{
            //    c = Pocketsphinx.Decoder.DefaultConfig();
            //    c.SetString("-hmm", "/models/en-us/mdef");
            //    c.SetString("-dict", "/models/dict/cmudict-en-us.dict");
            //    c.SetFloat("-kws_threshold", 1e-30);

            //    c.SetFloat("-samprate", 44100);
            //    c.SetInt("-nfft", 2048);

            //    d = new Pocketsphinx.Decoder(c);
            //}catch(Exception ex)
            //{
            //    DisplayAlert("Oops!", ex.Message, "OK");
            //}
            recorder = new AudioRecorderService
            {
                StopRecordingAfterTimeout = false,
                //AudioSilenceTimeout = TimeSpan.FromSeconds(2),
                //TotalAudioTimeout = TimeSpan.FromSeconds(20)
            };

            //recorder.FilePath = "/audio";
            player = new AudioPlayer();
            player.FinishedPlaying += Player_FinishedPlaying;
            aplayer = CrossSimpleAudioPlayer.Current;
        }
Exemple #9
0
        private void RecordButton_Clicked(object sender, EventArgs e)
        {
            if (recorder == null)
            {
                recorder = new AudioRecorderService()
                {
                    FilePath = recordFilePath,
                    StopRecordingOnSilence    = false,
                    StopRecordingAfterTimeout = true,
                    TotalAudioTimeout         = TimeSpan.FromMinutes(Preferences.Get(AppSettingKeys.RecordTimeOut, 5)),
                };

                recorder.AudioInputReceived += Recorder_AudioInputReceived;
            }

            if (recorder.IsRecording)
            {
                recorder.StopRecording();

                RecordStatusLabel.IsVisible = false;
            }
            else
            {
                RecordButton.Text = AppResources.StopRecord;

                recorder.StartRecording();

                RecordStatusLabel.IsVisible = true;
            }
        }
        public MainPage()
        {
            InitializeComponent();

            //setting these in XAML doesn't seem to be working
            RecognitionModePicker.SelectedIndex = 0;
            OutputModePicker.SelectedIndex      = 0;
            ProfanityModePicker.SelectedIndex   = 0;

            recorder = new AudioRecorderService
            {
                StopRecordingOnSilence    = true,
                StopRecordingAfterTimeout = true,
                TotalAudioTimeout         = TimeSpan.FromSeconds(15)          //Bing speech REST API has 15 sec max
            };

            if (Keys.BingSpeech.SubscriptionKey == Keys.BingSpeech.BadSubscriptionKey)
            {
                throw new Exception("Get a Bing Speech API key here: https://azure.microsoft.com/en-us/pricing/details/cognitive-services/speech-api/");
            }

            bingSpeechClient = new BingSpeechApiClient(Keys.BingSpeech.SubscriptionKey);

            //go fetch an auth token up front - this should decrease latecy on the first call.
            //	Otherwise, this would be called automatically the first time I use the speech client
            Task.Run(() => bingSpeechClient.Authenticate());
        }
Exemple #11
0
        public async Task <string> RecordAudio()
        {
            string audioFile = null;
            var    _recorder = new AudioRecorderService
            {
                StopRecordingAfterTimeout = true,
                TotalAudioTimeout         = TimeSpan.FromSeconds(10),
                AudioSilenceTimeout       = TimeSpan.FromSeconds(2)
            };

            try
            {
                if (!_recorder.IsRecording)
                {
                    var recordTask = await _recorder.StartRecording();

                    audioFile = await recordTask;
                }
                return(audioFile);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Exemple #12
0
        private async Task UploadFile()
        {
            string serverDirPath = AppEnvironment.dataService.ServerUserDataDirPath + "/";

            await Task.Delay(10);

            try
            {
                UploadButton.IsEnabled = false;
                UploadButton.Text      = AppResources.Uploading;

                if (!FTPService.CheckDirExist(serverDirPath))
                {
                    FTPService.CreateDir(serverDirPath);
                }

                isUploaded = FTPService.UploadFile(recordFilePath, Path.Combine(serverDirPath, Path.GetFileName(recordFilePath)));

                if (!isUploaded)
                {
                    throw new Exception("Cannot upload file");
                }
            }
            catch (Exception ex)
            {
#if DEBUG
                DependencyService.Get <IToast>().Show(ex.ToString());
#endif
                DependencyService.Get <IToast>().Show(AppResources.UploadFail_ReUpload);

                UploadButton.IsEnabled = true;
            }
            finally
            {
                UploadButton.Text      = AppResources.Upload;
                RecordButton.IsEnabled = true;
                RecordButton.Text      = File.Exists(recordFilePath) ? AppResources.Re_Record : AppResources.Record;
            }

            try
            {
                (BindingContext as VoiceRecordDetailViewModel).UpdateItemInfo(isRecorded, isUploaded);

                DependencyService.Get <IToast>().Show(AppResources.Upload_Success);
            }
            catch (Exception)
            {
                DependencyService.Get <IToast>().Show("Cannot update info");
            }
            finally
            {
                UploadButton.IsEnabled = true;
                UploadButton.Text      = isUploaded ? AppResources.ReUpload : AppResources.Upload;

                UpdateButtonStatus();

                recorder = null;
            }
        }
 public EnglishAssistantView()
 {
     recorder = new AudioRecorderService
     {
         StopRecordingAfterTimeout = true,
         AudioSilenceTimeout       = TimeSpan.FromSeconds(60),
         TotalAudioTimeout         = TimeSpan.FromSeconds(60)
     };
 }
 public AudioService()
 {
     recorder = new AudioRecorderService
     {
         StopRecordingOnSilence    = true,
         StopRecordingAfterTimeout = true,
         TotalAudioTimeout         = TimeSpan.FromSeconds(15)
     };
 }
Exemple #15
0
 private void InitController()
 {
     recorder = new AudioRecorderService
     {
         StopRecordingOnSilence    = true,                    //will stop recording after 2 seconds (default)
         StopRecordingAfterTimeout = false,                   //stop recording after a max timeout (defined below)
         PreferredSampleRate       = 16,
         TotalAudioTimeout         = TimeSpan.FromSeconds(10) //audio will stop recording after 15 seconds
     };
 }
Exemple #16
0
 public SubirAudio(Audio audio)
 {
     Audio          = audio;
     BindingContext = audio;
     InitializeComponent();
     recorder = new AudioRecorderService();
     player   = new AudioPlayer();
     //Este evento se lanza cuando se termine la grabación
     player.FinishedPlaying += Finish_Playing;
 }
 protected AudioRecordingBaseViewModel()
 {
     Recorder = new AudioRecorderService
     {
         AudioSilenceTimeout       = TimeSpan.FromSeconds(4),
         StopRecordingOnSilence    = true,
         StopRecordingAfterTimeout = false,
         PreferredSampleRate       = 16000,
         SilenceThreshold          = 0.1f
     };
 }
Exemple #18
0
        public MainPage()
        {
            InitializeComponent();

            recorder = new AudioRecorderService {
            };


            player = new AudioPlayer();
            player.FinishedPlaying += Player_FinishedPlaying;
        }
        public WalkPage()
        {
            InitializeComponent();

            recorder = new AudioRecorderService
            {
                StopRecordingAfterTimeout = true,
                TotalAudioTimeout         = TimeSpan.FromSeconds(15),
                AudioSilenceTimeout       = TimeSpan.FromSeconds(5),
            };
        }
Exemple #20
0
        void cargargrabadora()
        {
            record = new AudioRecorderService
            {
                TotalAudioTimeout      = TimeSpan.FromSeconds(15),
                StopRecordingOnSilence = true,
                FilePath = "temp"
            };

            player.FinishedPlaying += Player_FinishedPlaying;
        }
Exemple #21
0
        public AddPage()
        {
            InitializeComponent();
            Context = this.BindingContext as AddPageViewModel;

            bingSpeechService      = new BingSpeechService(new AuthenticationService(Constants.BingSpeechApiKey), Device.RuntimePlatform);
            bingSpellCheckService  = new BingSpellCheckService();
            textTranslationService = new TextTranslationService(new AuthenticationService(Constants.TextTranslatorApiKey));

            audioRecordingService = new AudioRecorderService();
        }
        public TranslateSpeechPage()
        {
            InitializeComponent();

            recorder = new AudioRecorderService
            {
                StopRecordingOnSilence    = true,
                StopRecordingAfterTimeout = true,
                TotalAudioTimeout         = TimeSpan.FromSeconds(15),
                AudioSilenceTimeout       = TimeSpan.FromSeconds(2)
            };
        }
Exemple #23
0
        public SpeechToTextPage()
        {
            InitializeComponent();

            // Instantiate the AudioRecorderService
            recorder = new AudioRecorderService
            {
                StopRecordingAfterTimeout = true,
                TotalAudioTimeout         = TimeSpan.FromSeconds(15),
                AudioSilenceTimeout       = TimeSpan.FromSeconds(2)
            };
        }
Exemple #24
0
        public MainPage()
        {
            this.InitializeComponent();

            recorder = new AudioRecorderService
            {
                StopRecordingOnSilence    = false,
                StopRecordingAfterTimeout = false
            };

            recorder.AudioInputReceived += Recorder_AudioInputReceived;
        }
 private void InitializeAudioServices()
 {
     Audio = DependencyService.Get <IAudio>();
     Audio.StateChanged += Audio_StateChanged;
     recorder            = new AudioRecorderService
     {
         AudioSilenceTimeout       = TimeSpan.FromSeconds(2),
         StopRecordingOnSilence    = true, //will stop recording after 2 seconds (default)
         StopRecordingAfterTimeout = true  //,  //stop recording after a max timeout (defined below)
                                           //TotalAudioTimeout = TimeSpan.FromSeconds(15) //audio will stop recording after 15 seconds
     };
     recorder.AudioInputReceived += Recorder_AudioInputReceived;
 }
Exemple #26
0
        public VoiceOrderView()
        {
            InitializeComponent();
            recorder = new AudioRecorderService
            {
                StopRecordingAfterTimeout = true,
                TotalAudioTimeout         = TimeSpan.FromSeconds(15),
                AudioSilenceTimeout       = TimeSpan.FromSeconds(2)
            };

            player = new AudioPlayer();
            player.FinishedPlaying += Player_FinishedPlaying;
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            recorder = new AudioRecorderService
            {
                StopRecordingOnSilence    = false,
                StopRecordingAfterTimeout = false
            };

            recorder.AudioInputReceived += Recorder_AudioInputReceived;
        }
Exemple #28
0
        public MainPage()
        {
            this.InitializeComponent();

            recorder = new AudioRecorderService
            {
                StopRecordingOnSilence    = false,
                StopRecordingAfterTimeout = false
            };

            //alternative event-based API can be used here in lieu of the returned recordTask used below
            //recorder.AudioInputReceived += Recorder_AudioInputReceived;
        }
Exemple #29
0
        public RespondePreguntaPage(int idPostula, int idReque, ListPreguntaDet modelo, string nom, int flagEstadoRespt)
        {
            nomb       = nom;
            flagEstado = flagEstadoRespt;
            idReq      = idReque;
            idPost     = idPostula;
            idPregunta = modelo.idPregunta;

            string nombre = Servicio.GenerarNombre(idPostula, idReque, modelo.idListPregunta, modelo.idPregunta);

            //  var mediaTestPath = "/storage/emulated/0/Android/data/com.companyname.AppEntrevista/files/"+ nombre + ".wav";

            #region Development Code

            /*
             * nombre = nombre + ".wav";
             *
             * string rutaArchivoDeRutaPaAudio = "/storage/emulated/0/Android/data/com.companyname.AppEntrevista/files/";
             *
             * var mediaTestPath = Path.Combine(rutaArchivoDeRutaPaAudio, nombre);
             */
            #endregion

            #region Production Code
            nombre = nombre + ".wav";

            string rutaArchivoDeRutaPaAudio = "/data/user/0/com.companyname.AppEntrevista/cache/";

            var mediaTestPath = Path.Combine(rutaArchivoDeRutaPaAudio, nombre);
            #endregion


            InitializeComponent();

            //BindingContext = modelo;
            ListPreguntaDet = modelo;
            var assembly = IntrospectionExtensions.GetTypeInfo(typeof(RespondePreguntaPage)).Assembly;
            IDpostulante = idPostula;

            var mainDir = FileSystem.AppDataDirectory;// directorio raiz

            recorder = new AudioRecorderService
            {
                StopRecordingAfterTimeout = true,                     // detendrá la grabación después de un tiempo de espera máximo (definido a continuación)
                TotalAudioTimeout         = TimeSpan.FromSeconds(60), // el audio dejará de grabar después de 15 segundos
                AudioSilenceTimeout       = TimeSpan.FromSeconds(5),  // Tiempo de espera de silencio de audio
                FilePath = mediaTestPath
            };
            player = new AudioPlayer();
            player.FinishedPlaying += Player_FinishedPlaying;
        }
        public HomePage()
        {
            InitializeComponent();
            staticControls.Children.Remove(connectingLayout);
            position  = null;
            direction = new Direction();

            recorder = new AudioRecorderService
            {
                StopRecordingOnSilence    = true,                    //will stop recording after 2 seconds (default)
                StopRecordingAfterTimeout = true,                    //stop recording after a max timeout (defined below)
                TotalAudioTimeout         = TimeSpan.FromSeconds(15) //audio will stop recording after 15 seconds
            };
        }