[Cloud Natural Language API] Speech-to-Text API: Qwik Start

yejinยท2026๋…„ 4์›” 15์ผ

Google Skills

๋ชฉ๋ก ๋ณด๊ธฐ
5/46

Course

Analyze Speech and Language with Google APIs

Lab

๋ชฉ๋ก

  • Cloud Natural Language API: Qwik Start
  • Speech-to-Text API: Qwik Start โฌ…๏ธ ์˜ค๋Š˜์˜ Lab!
  • Entity and Sentiment Analysis with the Natural Language API
  • Analyze Speech and Language with Google APIs: Challenge Lab

๐ŸŒ Speech-to-Text API: Qwik Start

๊ฐœ์š”

Speech-to-Text API๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด Google ์Œ์„ฑ ์ธ์‹ ๊ธฐ์ˆ ์„ ๊ฐœ๋ฐœ์ž ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์— ๊ฐ„ํŽธํ•˜๊ฒŒ ํ†ตํ•ฉ์ด ๊ฐ€๋Šฅํ•˜๋‹ค. Speech-to-Text API๋ฅผ ํ˜ธ์ถœํ•ด๋ณด์ž!

์‹ค์Šต๊ณผ์ •

(1) API ํ‚ค ์ƒ์„ฑ

1) APIs & Service > Credentials > API key ์„ ํƒ

2) API restrictions ์„ ํƒ


โžก๏ธ Cloud Speech-to-Text API ์„ ํƒ


(2) ์ธ์Šคํ„ด์Šค์˜ SSH ์ ‘์†

1) Compute Engine > VM instances > linux-instance ์˜ SSH ํด๋ฆญ

2) API_KEY๋ฅผ ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋กœ ๋“ฑ๋ก


(3) Speech-to-Text API ์š”์ฒญ ๋งŒ๋“ค๊ธฐ

์ฐธ๊ณ 

Cloud Storage์—์„œ ์ œ๊ณต๋œ ํŒŒ์ผ์„ ์‚ฌ์šฉํ•˜์—ฌ ์ง„ํ–‰!
๐Ÿ”— gs://cloud-samples-tests/speech/brooklyn.flac

1) request.json ํŒŒ์ผ ์ƒ์„ฑ

touch request.json

2) request.json ํŒŒ์ผ ์—ด๊ธฐ

โžก๏ธ ์ด๋ฒˆ ์‹ค์Šต์—์„œ๋Š” nano๋ฅผ ํ™œ์šฉํ•˜์˜€๋‹ค!

nano request.json

3) ์š”์ฒญ์„ ๋ณด๋‚ผ ๋‚ด์šฉ ์ž‘์„ฑ


{
  "config": {
      "encoding":"FLAC",
      "languageCode": "en-US"
  },
  "audio": {
      "uri":"gs://cloud-samples-tests/speech/brooklyn.flac"
  }
}

nano๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํŒŒ์ผ ๋‚ด์šฉ ์ˆ˜์ • ๋ฐ ์ €์žฅ ๋ฐฉ๋ฒ• ๐ŸŒ

1) Ctrl + x -> y ๋ฅผ ๋ˆŒ๋Ÿฌ ์ €์žฅ
2) Enter ํ‚ค๋ฅผ ๋ˆŒ๋Ÿฌ request.json ํŒŒ์ผ ๋‹ซ๊ธฐ!

๋‚ด์šฉ ๋ถ„์„

  • config: ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฐฉ๋ฒ•์„ Speech-to-Text API์— ์•Œ๋ ค์ค€๋‹ค.
  • encoding: API๋กœ ํŒŒ์ผ์ด ์ „์†ก๋˜๋Š” ๋™์•ˆ ๊ฐœ๋ฐœ์ž๊ฐ€ ์‚ฌ์šฉํ•˜๋Š” ์˜ค๋””์˜ค ์ธ์ฝ”๋”ฉ ์œ ํ˜•์„ API์— ์•Œ๋ ค์ค€๋‹ค. (config ๊ฐ์ฒด์˜ ํ•„์ˆ˜ ํŒŒ๋ผ๋ฏธํ„ฐ!)

(4) Speech-to-Text API ํ˜ธ์ถœ

1) API ํ˜ธ์ถœํ•˜๊ธฐ

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

๋‚ด์šฉ ๋ถ„์„

  • trasnscript: API๊ฐ€ ์˜ค๋””์˜ค ํŒŒ์ผ์„ ๋ณ€ํ™˜ํ•˜์—ฌ ์ž‘์„ฑํ•œ ํ…์ŠคํŠธ ์Šคํฌ๋ฆฝํŠธ
  • confidence: API๊ฐ€ ์˜ค๋””์˜ค ํŒŒ์ผ๋กœ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์–ผ๋งˆ๋‚˜ ์ •ํ™•ํ•˜๊ฒŒ ์ž‘์„ฑํ–ˆ๋Š” ์ง€ ๋‚˜ํƒ€๋‚ด๋Š” ์ˆ˜์น˜

2) ์‘๋‹ต ๊ฒฐ๊ณผ๋ฅผ result.json ํŒŒ์ผ์— ์ €์žฅ

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
profile
์ƒˆ์‹น ๊ฐœ๋ฐœ์ž

0๊ฐœ์˜ ๋Œ“๊ธ€