I am trying to use Google Speech API v1 in .net and facing a challange in making a call.
Below is my code.
Dim userSpeech = Google.Cloud.Speech.V1.SpeechClient.Create
Dim response = userSpeech.Recognize(New RecognitionConfig, RecognitionAudio.FromFile(filePath))
For Each result In response.Results
For Each alternative In result.Alternatives
Console.WriteLine(alternative.Transcript)
Next
Next
I never reach line of first FOR. I also don't get any error. The API is enabled. Google Cloud Credentials are set as environment variables. So, no problem there.
Then I tried in C# as below. But I get exact same result i.e. I don't get to foreach line.
var speech = SpeechClient.Create();
var response = speech.Recognize(new RecognitionConfig()
{
Encoding = RecognitionConfig.Types.AudioEncoding.Linear16,
SampleRateHertz = 16000,
LanguageCode = "en",
}, RecognitionAudio.FromFile("audio.raw"));
textBox1.Text = "";
foreach (var result in response.Results)
{
foreach (var alternative in result.Alternatives)
{
textBox1.Text = textBox1.Text + " " + alternative.Transcript;
}
}
Other API calls in the same application works e.g. language detection.
Any help will be highlight appreciated.
Thanks in advance.