Issue with Speech translation from English to Persian

Kristian Lamens 0 Reputation points
2023-03-24T20:25:35.3766667+00:00

I have created a speech service to translate Spoken English into Persian using C#. I have managed to get this working in some European languages but Persian returns ??????? instead of the translated phrases.

Can you provide any assistance?

Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
2,069 questions
Azure AI Translator
Azure AI Translator
An Azure service to easily conduct machine translation with a simple REST API call.
487 questions
Developer technologies | C#
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. YutongTie-MSFT 53,971 Reputation points Moderator
    2023-03-26T20:15:42.94+00:00

    Hello @Kristian Lamens

    Thanks for reaching out to us, it seems like the issue might be related to the encoding of the output text in C#.

    I have seen the same error when I working with some non-ASCII characters as well. For non-ASCII characters, it's important to make sure that the text is encoded properly. Persian language uses the Arabic script, which means that the text is written from right to left and contains characters that are not present in the ASCII character set.

    In C#, you can use the System.Text.Encoding class to specify the character encoding for your output. The Encoding class provides a GetString method that you can use to convert a byte array into a string, using the specified encoding.

    One common encoding for Persian text is UTF-8. You can try specifying UTF-8 encoding when converting your output byte array into a string, like this:

    byte[] outputBytes = ... // your output byte array
    string outputText = System.Text.Encoding.UTF8.GetString(outputBytes);
    

    If your output still shows ???????, it's possible that the issue is with the font being used to display the Persian characters. Make sure that you're using a font that supports the Arabic script, such as Microsoft's "Arial Unicode MS" font.

    If neither of these solutions works, please provide more details about your code and the specific library or API you're using for the translation, how you process the translation, which Azure product you are using, so that we can understand this issue better.

    I hope this helps.

    Regards,

    Yutong

    -Please kindly accept the answer and vote 'Yes' if you feel helpful to support the community, thanks a lot.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.