I decided to touch ruby for the first time in a few years, so I tried using Google's SpeechToText API. In the process, I had a hard time forgetting how to read the environment variables described in the .env file in the .rb file, so I will summarize them.
Place the .env file in the same directory as the .rb file
Read environment variables using a gem called dotenv What kind of gem is What is dotenv? .
Do the following on the command line
$ gem install dotenv
And
bundle install
sample.rb
require 'dotenv'
Dotenv.load
that's all
Recommended Posts