Using the Google Cloud Speech API

목록
- Speech-to-Text API: Qwik Start ⬅️ 오늘의 Lab!
- Speaking with a Webpage - Streaming Speech Transcripts
- Speech to Text Transcription with the Speech-to-Text API
- Using the Google Cloud Speech API: Challenge Lab
API 키 만들고, Speech-to-Text API request 생성 및 호출을 해보자!

➡️ APIs & Services > Credentials > Create credentials > API Key 클릭

✅ Create 후에 나오는 API Key 값을 꼭 복사해두기!

➡️ Compute Engine > VM instances > 해당 VM의 SSH

export API_KEY=<API_KEY>
echo $API_KEY # API Key 환경 변수 등록 확인

# 파일 생성
touch request.json
# 내용 수정
nano request.json
# 파일 내용
{
"config": {
"encoding":"FLAC",
"languageCode": "en-US"
},
"audio": {
"uri":"gs://cloud-samples-tests/speech/brooklyn.flac"
}
}
# 확인
cat request.json

curl -s -X POST -H "Content-Type: application/json" --data-binary @request.json \
"https://speech.googleapis.com/v1/speech:recognize?key=${API_KEY}"

curl -s -X POST -H "Content-Type: application/json" --data-binary @request.json \
"https://speech.googleapis.com/v1/speech:recognize?key=${API_KEY}" > result.json
# result.json 파일 내용 확인
cat result.json