Пример #1
0
        public async Task <string> SpeakerVerification([FromBody] VerifySpeaker verifySpeaker)
        {
            var sb = new StringBuilder();

            try
            {
                // Create the service
                Console.WriteLine("Creating the Speaker Verification Service.");
                var svService = new SpeakerVerificationService(Constants.SPEAKER_RECOGNITION_KEY);
                Console.WriteLine("Done");
                Console.WriteLine("");

                //Delete all existing profiles
                //Console.WriteLine("Deleting All Existing Profiles.");
                //svService.DeleteAllProfiles().Wait();
                //Console.WriteLine("Done");
                //Console.WriteLine("");



                // Verify Speaker
                string obj = await SpeakerVerificationMethods.SVVerifySpeaker(svService, verifySpeaker);

                sb.AppendLine($"obj: {obj}");
                return(sb.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
                return(ex.Message.ToString());
            }
        }
Пример #2
0
        public async Task <JsonResult> VerifySpeaker(VerifySpeaker model)
        {
            if (ModelState.IsValid)
            {
                var result = await AudioVerificationService.VerifySpeaker(model);

                return(new JsonResult(result));
            }

            return(new JsonResult(string.Empty));
        }
        public async Task <VerifySpeakerResponse> VerifySpeaker(VerifySpeaker model)
        {
            var url = $"{Configuration["AudioAnalyticsAPI"]}verify?verificationProfileId={model.Id}";

            var key = Configuration["AudioAnalyticsKey"];

            using (var inputStream = model.Audio.OpenReadStream())
            {
                var response = await CognitiveServicesHttpClient.HttpPostAudio(inputStream, url, key);

                var responseBytes = await response.Content.ReadAsStringAsync();

                return(JSONHelper.FromJson <VerifySpeakerResponse>(responseBytes));
            }
        }
        public static async Task <string> SVVerifySpeaker(SpeakerVerificationService svService, VerifySpeaker verifySpeaker)
        {
            // Open the sound file and load it in
            var speaker1Verification = File.OpenRead(verifySpeaker.file);

            // Enroll the speaker
            Console.WriteLine("Identify Speaker");
            var obj = await svService.VerifyUser(speaker1Verification);

            return(obj);
        }