readValue() public method

Reads a value from a given file
public readValue ( string filename ) : string
filename string The file to read the value from
return string
コード例 #1
0
ファイル: EnrollPage.xaml.cs プロジェクト: roseg31/DoughNut
        /// <summary>
        /// Initialize the speaker information
        /// </summary>
        private async void initializeSpeaker()
        {
            IsolatedStorageHelper _storageHelper = IsolatedStorageHelper.getInstance();
            string _savedSpeakerId = _storageHelper.readValue(MainWindow.SPEAKER_FILENAME);

            if (_savedSpeakerId != null)
            {
                _speakerId = new Guid(_savedSpeakerId);
            }
            record.IsEnabled = false;
            if (_speakerId == Guid.Empty)
            {
                bool created = await createProfile();

                if (created)
                {
                    refreshPhrases();
                }
            }
            else
            {
                setStatus("Using profile Id: " + _speakerId.ToString());
                refreshPhrases();
                string enrollmentsStatus = _storageHelper.readValue(MainWindow.SPEAKER_ENROLLMENTS);
                if ((enrollmentsStatus != null) && (enrollmentsStatus.Equals("Done")))
                {
                    resetBtn.IsEnabled = true;
                }
            }
        }
        /// <summary>
        /// Initialization constructor for the verify speaker page
        /// </summary>
        public VerifySpeakerPage()
        {
            InitializeComponent();
            try
            {
                _subscriptionKey = ((MainWindow)Application.Current.MainWindow).SubscriptionKey;
                IsolatedStorageHelper _storageHelper = IsolatedStorageHelper.getInstance();
                string _savedSpeakerId = _storageHelper.readValue(MainWindow.SPEAKER_FILENAME);
                if (_savedSpeakerId != null)
                {
                    _speakerId = new Guid(_savedSpeakerId);
                }

                if (_speakerId == Guid.Empty)
                {
                    ((MainWindow)Application.Current.MainWindow).Log("You need to create a profile and complete enrollments first before verification");
                    recordBtn.IsEnabled     = false;
                    stopRecordBtn.IsEnabled = false;
                }
                else
                {
                    initializeRecorder();
                    _serviceClient = new SpeakerVerificationServiceClient(_subscriptionKey);
                    string userPhrase = _storageHelper.readValue(MainWindow.SPEAKER_PHRASE_FILENAME);
                    userPhraseTxt.Text      = userPhrase;
                    stopRecordBtn.IsEnabled = false;
                }
            }
            catch (Exception gexp)
            {
                setStatus("Error: " + gexp.Message);
                recordBtn.IsEnabled     = false;
                stopRecordBtn.IsEnabled = false;
            }
        }
コード例 #3
0
        /// <summary>
        /// Initialize the speaker information
        /// </summary>
        private async void initializeSpeaker()
        {
            IsolatedStorageHelper _storageHelper = IsolatedStorageHelper.getInstance();
            string _savedSpeakerId = _storageHelper.readValue(MainWindow.SPEAKER_FILENAME);

            if (_savedSpeakerId != null)
            {
                _speakerId = new Guid(_savedSpeakerId);
            }
            record.IsEnabled = false;
            if (_speakerId == Guid.Empty)
            {
                bool created = await createProfile();

                if (created)
                {
                    refreshPhrases();
                }
                resetBtn.IsEnabled = false;
            }
            else
            {
                setStatus("Using profile Id: " + _speakerId.ToString());
                refreshPhrases();

                string remEnrollments = _storageHelper.readValue(MainWindow.SPEAKER_ENROLLMENTS);
                int    _remainingEnrollments;
                if (!Int32.TryParse(remEnrollments, out _remainingEnrollments))
                {
                    Profile profile = await _serviceClient.GetProfileAsync(_speakerId);

                    _remainingEnrollments = profile.RemainingEnrollmentsCount;
                    _storageHelper.writeValue(MainWindow.SPEAKER_ENROLLMENTS, _remainingEnrollments.ToString());
                }
                string enrollmentStatus = _storageHelper.readValue(MainWindow.SPEAKER_ENROLLMENT_STATUS);
                if (enrollmentStatus != null && !enrollmentStatus.Equals("Empty"))
                {
                    resetBtn.IsEnabled = true;
                }

                setDisplayText(_remainingEnrollments.ToString(), _storageHelper.readValue(MainWindow.SPEAKER_PHRASE_FILENAME));
            }
        }
コード例 #4
0
        /// <summary>
        /// Initialization constructor for the verify speaker page
        /// </summary>
        public VerifySpeakerPage()
        {
            InitializeComponent();
            _subscriptionKey = ((MainWindow)Application.Current.MainWindow).SubscriptionKey;
            IsolatedStorageHelper _storageHelper = IsolatedStorageHelper.getInstance();

            _speakerId = _storageHelper.readValue(MainWindow.SPEAKER_FILENAME);
            if (_speakerId == null)
            {
                ((MainWindow)Application.Current.MainWindow).Log("You need to create a profile and complete enrollments first before verification");
                recordBtn.IsEnabled     = false;
                stopRecordBtn.IsEnabled = false;
            }
            else
            {
                initializeRecorder();
                _serviceClient = new SpeechVerificationServiceClient(_subscriptionKey);
                string userPhrase = _storageHelper.readValue(MainWindow.SPEAKER_PHRASE_FILENAME);
                userPhraseTxt.Text      = userPhrase;
                stopRecordBtn.IsEnabled = false;
            }
        }