简体   繁体   中英

Microsoft Translator Minutes in a SRT timestamp gets removed in Dutch translation

Uri: https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&to=NL&from=EN&category=General&textType=html

Example Text (JSON) Content: [{"text":"00:03:00.300 --> 00:03:08.300 "}]

Result: [{"translations":[{"text":"00:03:00.300--> 00:08.300 ","to":"nl"}]}]

In the result, the 3 in the minutes spot is simply removed from the result... Only in the end time slot. Oddly enough, this appears to only happen for the number 3.

Question : Is there any reason Dutch would have this behavior? Is it a bug in the translator service? I tested with a few other languages and it seems specific to Dutch.

I'm not doing anything particularly fancy in the code. The responseBody below already contains the odd data coming back.

        using (var httpClient = new HttpClient())
        {
            using (var request = new HttpRequestMessage())
            {
                request.Method = HttpMethod.Post;
                request.RequestUri = new Uri(uri);
                request.Content = new StringContent(requestBody, Encoding.UTF8, "application/json");
                request.Headers.Add("Authorization", token);

                var response = await httpClient.SendAsync(request);
                var responseBody = await response.Content.ReadAsStringAsync();
                if (response.IsSuccessStatusCode)
                {
                    //Logic on success
                }
            }
        }

Let me know if there's any other information needed. This seems like a particularly odd result.

It can happen that an arbitrary string produces arbitrary "translations". Best to avoid passing the time stamp to translation. With SRT file translation there is more to consider besides the time stamp. You also need to combine multiple lines into a single line before translation, and then split them again after translation.

Here is an example that does both of these: https://github.com/MicrosoftTranslator/DocumentTranslator/blob/master/TranslationAssistant.Business/SRTTranslationManager.cs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM