小编Pan*_*ndi的帖子

将语音文化转换为其他语言

除了英国文化,我还有一些文字.例如:泰米尔文化.

如果我不提及文化,将采用默认英语.

如何将文本转换为语音(英语除外)?

代码段:

对于英语:

public static void ConvertTextToVoice()
    {
        SpeechSynthesizer speech = new SpeechSynthesizer();
        speech.Volume = 100;
        speech.Rate = 0;            
        speech.Speak("Welcome to india");
    }
Run Code Online (Sandbox Code Playgroud)

对于其他语言:

public static void ConvertTextToVoice()
{
    SpeechSynthesizer speech = new SpeechSynthesizer();
    speech.Volume = 100;
    speech.Rate = 0;

    //Tamil Text
    string text = "??????? ???? ??????? ????? ???????? ?????? ???? ???? ???";

    PromptBuilder builder = new PromptBuilder(new System.Globalization.CultureInfo("ta-IN"));
    builder.AppendText(text);           
    speech.SpeakAsync(builder);
}
Run Code Online (Sandbox Code Playgroud)

c# culture text-to-speech speech-synthesis

6
推荐指数
1
解决办法
211
查看次数

如何在没有等待opeartor的情况下获得返回值

我需要在没有await运算符的情况下获取返回值(在下面的示例中,我需要"hello world"var y没有await运算符的情况下获取).因为一个方法被引用到很多地方.但我的要求是对于特定操作异步执行方法.没有其他时间它足以同步执行.

如果我在所有引用的位置等待,方法需要更改为异步,并且引用的方法需要更改为async和await.是否有可能获得返回值?

请在下面找到示例代码段:

class Program
{
    static void Main(string[] args)
    {
        var x = getString();
    }

    public static async Task<string> getString()
    {
        var y = await GetString2();
        return y;
    }

    public static async Task<string> GetString2()
    {
        return "hello world";
    }

}
Run Code Online (Sandbox Code Playgroud)

var y没有等待运算符的情况下,有没有可能获得"hello world"字符串?

.net c# asynchronous async-await

5
推荐指数
2
解决办法
969
查看次数