admin管理员组

文章数量:1415664

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;

}

本文标签: mauiSpeechToText method does not provide Turkish resultsStack Overflow