maui - SpeechToText method does not provide Turkish results - Stack Overflow

I'm trying the speech-to-text method, but the resulting text is in English.9.0, CommunityToolkit.M

I'm trying the speech-to-text method, but the resulting text is in English.

9.0, CommunityToolkit.Maui 11.0

These are my codes:

    public async Task<string> MediaToolKitSpeechToTextAsync()
{
    var options = new SpeechToTextOptions
    {
        Culture = CultureInfo.GetCultureInfo("tr-TR") 
    };

    await SpeechToText.Default.StartListenAsync(options, CancellationToken.None);

    SpeechToText.Default.RecognitionResultCompleted += (s, args) =>
    {
        if (args.RecognitionResult != null && !string.IsNullOrEmpty(args.RecognitionResult.Text))
        {
            transcript = args.RecognitionResult.Text;
        }
        else
        {
            MainThread.BeginInvokeOnMainThread(async () =>
            {
                await DisplayAlert("Hata", "Ses anlaşılamadı.", "Tamam");
            });
        }
    };

    return transcript;
}

I'm trying the speech-to-text method, but the resulting text is in English.

9.0, CommunityToolkit.Maui 11.0

These are my codes:

    public async Task<string> MediaToolKitSpeechToTextAsync()
{
    var options = new SpeechToTextOptions
    {
        Culture = CultureInfo.GetCultureInfo("tr-TR") 
    };

    await SpeechToText.Default.StartListenAsync(options, CancellationToken.None);

    SpeechToText.Default.RecognitionResultCompleted += (s, args) =>
    {
        if (args.RecognitionResult != null && !string.IsNullOrEmpty(args.RecognitionResult.Text))
        {
            transcript = args.RecognitionResult.Text;
        }
        else
        {
            MainThread.BeginInvokeOnMainThread(async () =>
            {
                await DisplayAlert("Hata", "Ses anlaşılamadı.", "Tamam");
            });
        }
    };

    return transcript;
}
Share Improve this question edited Feb 10 at 10:52 Hakan DOĞAN asked Feb 10 at 10:51 Hakan DOĞANHakan DOĞAN 54 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

And finally, I found the bug. I replaced culture with tr_TR and done.

public async Task<string> MediaToolKitSpeechToTextAsync(){

var options = new SpeechToTextOptions
{
    Culture = CultureInfo.GetCultureInfo("tr_TR") 
};

await SpeechToText.Default.StartListenAsync(options, CancellationToken.None);

SpeechToText.Default.RecognitionResultCompleted += (s, args) =>
{
    if (args.RecognitionResult != null && !string.IsNullOrEmpty(args.RecognitionResult.Text))
    {
        transcript = args.RecognitionResult.Text;
    }
    else
    {
        MainThread.BeginInvokeOnMainThread(async () =>
        {
            await DisplayAlert("Hata", "Ses anlaşılamadı.", "Tamam");
        });
    }
};

return transcript;

}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745219851a4617197.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信