์ตœ๊ทผ ๋งŽ์€ ์Œ์„ฑ์ธ์‹ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜๋“ค์ด ๊ฐœ๋ฐœ๋˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ์Œ์„ฑ์ธ์‹ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ ์ธ์‹๋ฅ ์€ ์ค‘์š”ํ•œ ์ฒ™๋„์ž…๋‹ˆ๋‹ค. Watson STT์˜ ๊ฒฝ์šฐ ์ด๋Ÿฌํ•œ ์ธ์‹๋ฅ ์„ ํ–ฅ์ƒ ์‹œํ‚ฌ ์ˆ˜ ์žˆ๋Š” ํŠธ๋ ˆ์ด๋‹ ๋ฐฉ๋ฒ•์„ ์ œ๊ณตํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ๋ณธ ์‹œ๋ฆฌ์ฆˆ์—์„œ๋Š” NodeJS๋ฅผ ์ด์šฉํ•˜์—ฌ Watson STT๋ฅผ ์ด์šฉํ•œ ์Œ์„ฑ ์ธ์‹ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๋งŒ๋“œ๋Š” ๋ฐฉ๋ฒ•์„ ์„ค๋ช…ํ•˜๊ณ , Watson STT์˜ ์Œ์„ฑ ์ธ์‹์œจ์„ ํ–ฅ์ƒ์‹œํ‚ค๊ธฐ ์œ„ํ•œ ํŠธ๋ ˆ์ด๋‹ ๋ฐฉ๋ฒ•์— ๋Œ€ํ•˜์—ฌ ์•Œ์•„๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ๋ณธ ์‹œ๋ฆฌ์ฆˆ๋Š” ์ด 3๊ฐœ๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

๊ฐ ์‹œ๋ฆฌ์ฆˆ์˜ ์†Œ์Šค๋Š” https://github.com/blbird/STT ์—์„œ ํ™•์ธํ•˜์‹ค์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Watson STT ์‚ฌ์šฉ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ œ์ž‘

์šฐ์„  ์‹œ๋ฆฌ์ฆˆ์˜ ์ฒซ๋ฒˆ์งธ๋กœ NodeJS๋ฅผ ์ด์šฉํ•œ Watson STT ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ์ œ์ž‘ํ•ด ๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ์ด ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์€ ๋งˆ์ดํฌ๋ฅผ ํ†ตํ•ด ์ž…๋ ฅ ๋ฐ›์€ ์Œ์„ฑ ๋ฐ์ดํ„ฐ๋ฅผ Watson STT๋ฅผ ์ด์šฉํ•˜์—ฌ ์ธ์‹์‹œํ‚จ ํ›„, ์ธ์‹๋œ ํ…์ŠคํŠธ๋ฅผ ํ™”๋ฉด์— ์ถœ๋ ฅํ•˜๋Š” ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์ž…๋‹ˆ๋‹ค.

1. Watson STT ์„œ๋น„์Šค ์ƒ์„ฑ
  • IBM cloud์—์„œ Watson STT ์„œ๋น„์Šค๋ฅผ ์ƒ์„ฑ ํ•ฉ๋‹ˆ๋‹ค.

2. Watson STT ์‚ฌ์šฉ์„ ์œ„ํ•œ credential ์ƒ์„ฑ
  • ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ ์‚ฌ์šฉํ•  credential ์ •๋ณด๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. 1)๋ฒˆ์—์„œ ๋งŒ๋“ค์–ด์ง„ ์„œ๋น„์Šค์—์„œ Service Credentials ๋ฉ”๋‰ด์˜ New Credential ๋ฒ„ํŠผ์„ ํ†ตํ•ด ์ƒˆ๋กœ์šด credential์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

3. config.js ๋ณ€๊ฒฝ
  • 2) ์—์„œ ์ƒ์„ฑํ•œ credential ์ •๋ณด๋ฅผ config.js ํŒŒ์ผ์˜ module.exports.credential ๋ถ€๋ถ„์— ๋ฐ˜์˜์„ ํ•ฉ๋‹ˆ๋‹ค.
  • ๋˜ํ•œ ์•ž์œผ๋กœ STT ํŠธ๋ ˆ์ด๋‹์— ์‚ฌ์šฉํ•  customization model name ๋ฐ base model ๋“ฑ์„ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.
4. ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ (์†Œ์Šค stt_stream.js)
  • ๋ณธ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์€ mic๋ฅผ ํ†ตํ•ด ์ž…๋ ฅ ๋ฐ›์€ ์Œ์„ฑ ๋ฐ์ดํ„ฐ๋ฅผ Watson STT๋ฅผ ์ด์šฉํ•˜์—ฌ ํ…์ŠคํŠธ๋ฅผ ์–ป๋Š” ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์ž…๋‹ˆ๋‹ค.
    ์šฐ์„  Watson STT๋ฅผ ์‚ฌ์šฉํ•˜๋Š” NodeJS ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด์„œ๋Š” package.json์˜ dependencies์— โ€œwatson-developer-cloudโ€ pacakge๋ฅผ ์ถ”๊ฐ€ํ•˜์…”์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ , ๋ณธ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ๋Š” mic์˜ ์ž…๋ ฅ์„ ๋ฐ›๊ธฐ ์œ„ํ•ด โ€œmicโ€ ๋ชจ๋“ˆ์„ ์‚ฌ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค.
  • STT ๋ชจ๋“ˆ์˜ ์‚ฌ์šฉ์€ ์•„๋ž˜ ์ฒ˜๋Ÿผ ์ƒ์„ฑํ•˜์—ฌ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

    const SpeechToTextV1 = require('watson-developer-cloud/speech-to-text/v1');
    const speechToText = new SpeechToTextV1(credential);
  • startRecording() ํ•จ์ˆ˜๋Š” newMicDevice() ํ•จ์ˆ˜๋ฅผ ํ†ตํ•ด mic ๋ชจ๋“ˆ ์ดˆ๊ธฐํ™” ๋ฐ ์ž…๋ ฅ ๋ฐ›์€ ์Œ์„ฑ ์ŠคํŠธ๋ฆผ์— ๋Œ€ํ•œ event๋ฅผ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค. ๋˜ํ•œ STT instance ์ƒ์„ฑ ๋ฐ ์ƒ์„ฑ๋œ STT instance์— ์Œ์„ฑ ๋ฐ์ดํ„ฐ๋ฅผ ์ „๋‹ฌํ•˜๊ธฐ ์œ„ํ•ด createRecognizeStream() ํ•จ์ˆ˜๋ฅผ ์ด์šฉํ•˜์—ฌ ์Œ์„ฑ ๋ฐ์ดํ„ฐ๋ฅผ ์ž…๋ ฅํ•˜๊ธฐ ์œ„ํ•œ ์ŠคํŠธ๋ฆผ์„ ์ƒ์„ฑํ•˜๊ณ , ์ž…๋ ฅ ๋ฐ›์€ ์Œ์„ฑ ์ŠคํŠธ๋ฆผ์„ ์ด ์ƒ์„ฑ๋œ ์ŠคํŠธ๋ฆผ์— ์ „๋‹ฌํ•ฉ๋‹ˆ๋‹ค. ๋งŒ์•ฝ ํŠน์ • ํŒŒ์ผ์„ ์ด์šฉํ•˜์—ฌ STT๋ฅผ ์‚ฌ์šฉํ•˜์‹œ๋ ค๋ฉด recognize() ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค. createRecognizeStream()์— ์‚ฌ์šฉ๋˜๋Š” ์˜ต์…˜์€ ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.
    • content_type : ์Œ์„ฑ ๋ฐ์ดํ„ฐ ํฌ๋งท. (ex. audio/wav, audio/mp3 ๋“ฑ). ๋ณธ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ๋Š” audio/l16์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ์ด ํฌ๋งท์˜ ๊ฒฝ์šฐ ์ƒ˜ํ”Œ๋ง rate(rate)๊ณผ ์ฑ„๋„์ˆ˜(channels)์— ๋Œ€ํ•œ ์˜ต์…˜์ด ๋ช…์‹œ๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
    • model : ์‚ฌ์šฉํ•  ๋ฒ ์ด์Šค ๋ชจ๋ธ id
    • customization_id : ๋‘๋ฒˆ์งธ ๋ฌธ์„œ์— ๋ช…์‹œ๋œ ํ…์ŠคํŠธ ํŠธ๋ ˆ์ด๋‹ ํ•œ customization model id
    • acoustic_customization_id : ์„ธ๋ฒˆ์งธ ๋ฌธ์„œ์—์„œ ๋ช…์‹œ๋œ ์Œ์„ฑ ๋ฐ์ดํ„ฐ๋ฅผ ํŠธ๋ ˆ์ด๋‹ํ•œ acoustic customization model id
    • smart_formatting : ๋‚ ์งœ, ์‹œ๊ฐ„, ์ˆซ์ž ๋“ฑ์˜ ๋ฐ์ดํ„ฐ๋ฅผ ์ฝ๊ธฐ ์ข‹๊ฒŒ ๋ฐ”๊ฟ” ์คŒ.

    ์ด์™ธ์— ์—ฌ๋Ÿฌ๊ฐ€์ง€ ์˜ต์…˜์ด ์žˆ์œผ๋‹ˆ, ๋‹ค๋ฅธ ์˜ต์…˜๋“ค์— ๋Œ€ํ•ด์„œ๋Š” ๋‹ค์Œ ๋งํฌ๋ฅผ ํ™•์ธํ•˜์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.
    https://www.ibm.com/watson/developercloud/speech-to-text/api/v1/#recognize_audio_websockets

  • STT์— ์˜ํ•ด ์ธ์‹๋œ ํ…์ŠคํŠธ๋Š” ์•„๋ž˜์™€ ๊ฐ™์ด STT ์ž…๋ ฅ stream์˜ data ์ด๋ฒคํŠธ๋ฅผ ํ†ตํ•ด ํ™•์ธํ•˜์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

    recognizeStream.on('data', function(event) {
    let resultTranscript = event.toString();
    console.log('transcript : ' + resultTranscript);
    });
5. ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ์‹คํ–‰

– npm install
– node stt_stream

ํ† ๋ก  ์ฐธ๊ฐ€

์ด๋ฉ”์ผ์€ ๊ณต๊ฐœ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ํ•„์ˆ˜ ์ž…๋ ฅ์ฐฝ์€ * ๋กœ ํ‘œ์‹œ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.