Google Cloud Speech API capability for non-sense words or phonetics

馋奶兔 提交于 2020-01-05 05:58:21

问题


Is is possible for the API to return the phonetics of what the sound file says? Or, is it possible to provide non-real vocabulary words?

I have a foreign language tutorial where I might be able to use this. It for examples teaches non-Latin alphabets like Cyrillic, Hebrew, Arabic, Chinese, etc...

I have a library of non-sense words to help the student learn; the reason for non-sense words vs real words is that it breaks the steps down to just two letters at a time; and at first, there aren't many real words that can be created with just those letters.

I'd like to show one of these non-sense words, record the student saying it, then verify if they said it correctly in order to give them feedback.


回答1:


It is possible to add phrases, but not using a phonetic alphabet. This, for instance, would recognise the ficticious word "Affelfaffel", provided it's pronounced as it should be according to the specified language code:

var speech = SpeechClient.Create();
string url = @"gs://your-bucket-name/your-file";
StringBuilder sb = new StringBuilder();

RecognitionConfig rc = new RecognitionConfig()
{
    Encoding = RecognitionConfig.Types.AudioEncoding.Linear16,
    SampleRate = 16000,
    LanguageCode = LanguageCodes.English.UnitedKingdom
};
rc.SpeechContext = new SpeechContext();
rc.SpeechContext.Phrases.Add("Affelfaffel");

var longOperation = speech.AsyncRecognize(rc, RecognitionAudio.FromStorageUri(url));
longOperation = await longOperation.PollUntilCompletedAsync();
var response = longOperation.Result;
foreach (var result in response.Results)
{
     foreach (var alternative in result.Alternatives)
     {
         sb.Append(alternative.Transcript);
     }
}


来源:https://stackoverflow.com/questions/43261093/google-cloud-speech-api-capability-for-non-sense-words-or-phonetics

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!