title: Google Speech to Text API Undefined Method
body: <p>I'm trying to learn how to use the google speech to text API but I'm getting an undefined method error when running the code. The code is taken from google cloud client library to use. I'm not sure how to fix the error.
  Error: : undefined method alternatives for nil:NilClass (NoMethodError)</p>
  <pre><code>#use gem install google-cloud-speech
  
  require &quot;google/cloud/speech&quot;
  
  
  speech = Google::Cloud::Speech.speech
  
  
  file_name = &quot;file_path&quot;
  
  
  audio_file = File.binread file_name
  
  
  config = { encoding:          :LINEAR16,
         sample_rate_hertz: 16_000,
         language_code:     &quot;en-US&quot; }
  audio  = { content: audio_file }
  
  
  response = speech.recognize config: config, audio: audio
  
  results = response.results
  
  results.first.alternatives.each do |alternatives|
  puts &quot;Transcription: #{alternatives.transcript}&quot;
    end
  </code></pre>