示例#1
0
        public async Task <VerificationResult> RecordAndVerifyUserAsync(
            string user, TimeSpan recordingTime)
        {
            VerificationResult result = null;

            Guid?accountGuid = await AccountMap.GetGuidForUserNameAsync(user);

            if (!accountGuid.HasValue)
            {
                throw new ArgumentException($"user name {user} is not recognised");
            }
            using (var recordedStream = await this.RecordSpeechToFileAsync(recordingTime))
            {
                result = await this.restClient.VerifyAsync(
                    accountGuid.Value, recordedStream);
            }
            return(result);
        }
示例#2
0
        public async Task <EnrollmentResult> RecordAndEnrollUserAsync(
            string user, TimeSpan recordingTime)
        {
            EnrollmentResult result = null;

            Guid?accountGuid = await AccountMap.GetGuidForUserNameAsync(user);

            if (accountGuid == null)
            {
                var profile = await this.restClient.AddVerificationProfileAsync();

                accountGuid = profile.VerificationProfileId;
                await AccountMap.SetGuidForUserNameAsync(user, accountGuid.Value);
            }
            using (var recordedStream = await this.RecordSpeechToFileAsync(recordingTime))
            {
                result = await this.restClient.EnrollAsync(accountGuid.Value, recordedStream);
            }
            return(result);
        }