Пример #1
0
        public virtual SpeechToTextResponse SpeechToText(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 = RepositoryClient.SendSpeechTokenRequest(ApiKeys.SpeechTokenEndpoint, ApiKeys.Speech);

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

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

            return(JsonConvert.DeserializeObject <SpeechToTextResponse>(response));
        }
Пример #2
0
        public virtual CreateJobResponse CreateImageJob(string imageUrl, string teamName, string contentId, string workflowName, string callbackEndpoint = "")
        {
            var response = RepositoryClient.Send(
                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));
        }
Пример #3
0
        public virtual async Task <byte[]> GetThumbnailAsync(string url, int width, int height, bool smartCropping = true)
        {
            var response = await RepositoryClient.SendJsonPostAsync(ApiKeys.ComputerVision, $"{ApiKeys.ComputerVisionEndpoint}generateThumbnail?width={width}&height={height}&smartCropping={smartCropping}", GetImageUrlJson(url));

            return(RepositoryClient.GetByteArray(response));
        }