Пример #1
0
        public virtual async Task <CreateJobResponse> CreateImageJobAsync(string imageUrl, string teamName, string contentId, string workflowName, string callbackEndpoint = "")
        {
            var response = await RepositoryClient.SendAsync(
                ApiKeys.ContentModerator,
                $"{ApiKeys.ContentModeratorEndpoint}{reviewUrl}{teamName}/jobs?ContentType=Image&ContentId={contentId}&WorkflowName={workflowName}{GetCreateJobQuerystring(callbackEndpoint)}",
                RepositoryClient.GetByteArray(JsonConvert.SerializeObject(new JobRequest {
                ContentValue = imageUrl
            })),
                "application/json",
                "POST",
                GetToken());

            return(JsonConvert.DeserializeObject <CreateJobResponse>(response));
        }
Пример #2
0
        /// <summary>
        /// This transcribes voice queries
        /// </summary>
        /// <param name="audioStream">Audio stream</param>
        /// <param name="scenario">The context for performing a recognition.</param>
        /// <param name="locale">Language code of the audio content in IETF RFC 5646. Case does not matter. </param>
        /// <param name="os">Operating system the client is running on. This is an open field but we encourage clients to use it consistently across devices and applications.</param>
        /// <param name="fromDeviceId">A globally unique device identifier of the device making the request.</param>
        /// <param name="maxnbest">Maximum number of results the voice application API should return. The default is 1. The maximum is 5. Example: maxnbest=3</param>
        /// <param name="profanitycheck">Scan the result text for words included in an offensive word list. If found, the word will be delimited by bad word tag. Example: result.profanity=1 (0 means off, 1 means on, default is 1.)</param>
        public virtual async Task <SpeechToTextResponse> SpeechToTextAsync(Stream audioStream, ScenarioOptions scenario, SpeechLocaleOptions locale, SpeechOsOptions os, Guid fromDeviceId, int maxnbest = 1, int profanitycheck = 1)
        {
            string url   = GetSpeechToTextUrl(scenario, locale, os, fromDeviceId, maxnbest, profanitycheck);
            string token = GetSpeechToken();

            byte[] data = RepositoryClient.GetByteArray(audioStream);

            var response = await RepositoryClient.SendAsync(ApiKeys.Speech, url, data, contentType, "POST", token, true, "speech.platform.bing.com");

            return(JsonConvert.DeserializeObject <SpeechToTextResponse>(response));
        }