-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Abnormal strings in translation results: ãã£ã£ãç§ã¡ã¡åã #95
Comments
Hi, could you please share the code you are running to get this result, and copy paste the input text instead of posting it as a screenshot? (So I can reproduce the text) |
Hi, @JanEbbing func DeepLTranslate(srcLang, targetLang, text string) (string, error) {
authKey := ""
urlValues := url.Values{}
urlValues.Add("auth_key", authKey)
urlValues.Add("target_lang", targetLang)
urlValues.Add("text", text)
if len(srcLang) > 0 {
urlValues.Add("source_lang", srcLang)
}
resp, err := ctxhttp.PostForm(context.Background(), &http.Client{}, "https://api.deepl.com/v2/translate", urlValues)
if err != nil {
return "", err
}
defer func(Body io.ReadCloser) {
err := Body.Close()
if err != nil {
fmt.Printf("DeepL translate error: %+v\n", err)
}
}(resp.Body)
if resp.StatusCode != http.StatusOK {
return "", err
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return "", err
}
result := map[string][]map[string]string{}
err = jsoniter.Unmarshal(body, &result)
if err != nil {
return "", err
}
return result["translations"][0]["text"], err
} original text: These texts are presented by OCR and may be different from the real thing。 I wonder if it's caused by illegal strings in the content, such as "?" inside the image. |
The Golang project is deployed on top of a linux machine located in Hong Kong's server room. The original text is uploaded by the client as a speech stream, and the text is generated by our speech recognition service, and then the DeepL translation interface is called via http, and the translation result is passed back to the chrome client via websocket. The above phenomenon is not a frequent occurrence, about two times in six months. @JanEbbing |
Yes but how/where is the text rendered? As I've shown, the API returns the characters well-formated in UTF-8. If you get artifacts like the ones in the screenshot, it is most likely an encoding issue somewhere in this pipeline. |
Yellow text is the result of a translation error, white text is the original text
The API used is:https://api.deepl.com/v2/translate
The text was updated successfully, but these errors were encountered: