示例#1
0
        private async Task SendSTTResultToUser(string text, IEnumerable <Participant> participants)
        {
            var to   = participants.Single(x => x.Originator);
            var from = participants.First(x => !x.Originator);

            await AgentListener.Resume(to.Identity, to.DisplayName, from.Identity, from.DisplayName, to.Identity, text);
        }
        //public async Task GetText(Stream audiostream)
        //{
        //    var preferences = new Preferences(DefaultLocale, new Uri(SpeechRecognitionUri), new CognitiveServicesAuthorizationProvider(SubscriptionKey));

        //    // Create a a speech client
        //    using (var speechClient = new SpeechClient(preferences))
        //    {
        //        speechClient.SubscribeToPartialResult(this.OnPartialResultAsync);
        //        speechClient.SubscribeToRecognitionResult(this.OnRecognitionResult);
        //        // create an audio content and pass it a stream.
        //        var deviceMetadata = new DeviceMetadata(DeviceType.Near, DeviceFamily.Desktop, NetworkType.Wifi, OsName.Windows, "1607", "Dell", "T3600");
        //        var applicationMetadata = new ApplicationMetadata("SampleApp", "1.0.0");
        //        var requestMetadata = new RequestMetadata(Guid.NewGuid(), deviceMetadata, applicationMetadata, "SampleAppService");
        //        await speechClient.RecognizeAsync(new SpeechInput(audiostream, requestMetadata), CancellationToken.None).ConfigureAwait(false);
        //    }
        //}

        /// <summary>
        /// Invoked when the speech client receives a partial recognition hypothesis from the server.
        /// </summary>
        /// <param name="args">The partial response recognition result.</param>
        /// <returns>
        /// A task
        /// </returns>
        public Task OnPartialResultAsync(RecognitionPartialResult args)

        {
            Debug.WriteLine("--- Partial result received by OnPartialResult ---");

            Debug.WriteLine(args.DisplayText);
            // Print the partial response recognition hypothesis.
            return(AgentListener.Resume(args.DisplayText));
            //Debug.WriteLine(args.DisplayText);
            //return CompletedTask;
        }
示例#3
0
 private async Task SendSTTResultToUser(string text)
 {
     foreach (var participant in Participants)
     {
         if (participant.Originator)
         {
             AgentListener.toId           = participant.Identity;
             AgentListener.toName         = participant.DisplayName;
             AgentListener.conversationId = participant.Identity; // same as channelid
         }
         else
         {
             AgentListener.fromId   = participant.Identity;
             AgentListener.fromName = participant.DisplayName;
         }
     }
     AgentListener.channelId  = "skype";
     AgentListener.serviceUrl = "https://skype.botframework.com";
     MicrosoftAppCredentials.TrustServiceUrl(AgentListener.serviceUrl);
     await AgentListener.Resume(text);
 }