Closed Rob117 closed 5 years ago
@Rob117 Thanks for reporting this issue! Can you post the entire error backtrace?
I see no way to create a RecognitionConfig object
You can either pass the options as arguments to the initializer:
require "google/cloud/speech/v1p1beta1"
config = Google::Cloud::Speech::V1p1beta1::RecognitionConfig.new \
sample_rate_hertz: 8000,
enable_word_time_offsets: true,
language_code: 'en-US',
enable_speaker_diarization: true
Or you can create the object and set each attribute separately:
require "google/cloud/speech/v1p1beta1"
config = Google::Cloud::Speech::V1p1beta1::RecognitionConfig.new
config.sample_rate_hertz = 8000
config.enable_word_time_offsets = true
config.language_code = 'en-US'
config.enable_speaker_diarization = true
@Rob117 Have you been able to give this a try?
@quartzmo @blowmage I just gave it a go, and it works! For those who come after:
init:
TextToSpeech = Google::Cloud::Speech.new(version: :V1p1beta1)
TTSConfig = Google::Cloud::Speech::V1p1beta1::RecognitionConfig.new sample_rate_hertz: 8000,
enable_word_time_offsets: true,
language_code: 'en-US',
enable_speaker_diarization: true
some other place:
audio_file = File.binread '/Users/USER/Documents/stt.flac'
# audio = { content: request.body }
audio = { content: audio_file }
response = TextToSpeech.recognize TTSConfig, audio
Environment details
Problem
enable_speaker_diarization
in config settings givesArgumentError (Unknown field name 'enable_speaker_diarization' in initialization map entry.):
error.Code example
initiaizer:
Actual calling code
I specifically required the beta version thinking that would resolve the message (by requiring the beta file, although now I feel like that might not solve the issue).
Regardless, enable_speaker_diarization flag is not recognized.
I consulted the documentation at http://googleapis.github.io/google-cloud-ruby/docs/google-cloud-speech/latest/Google/Cloud/Speech/V1p1beta1/RecognitionConfig.html#enable_speaker_diarization-instance_method.
It says it's a method, but I see no way to create a RecognitionConfig object, so I passed the argument in a hash like the rest of the config settings.