Skip to content

Sample Application

LordVader edited this page Jun 26, 2024 · 17 revisions

Sample application은 nugusdk_start_sample shell script를 사용해서 실행할 수 있습니다.

$ nugusdk_start_sample /usr/bin/nugu_sample

nugusdk_start_sample shell script를 사용하지 않고 직접 실행하려면 아래와 같이 토큰에 대한 환경 변수(NUGU_TOKEN)값을 설정한 후 실행하시면 됩니다.

$ export NUGU_TOKEN=...
$ /usr/bin/nugu_sample

기본 제공되는 model file 외에 별도의 model file 사용시 아래와 같이 해당 경로를 지정할 수 있습니다.

$ /usr/bin/nugu_sample -m {model-file-path}

정상적으로 실행이 되면, 아래와 같이 텍스트 기반의 UI가 콘솔에 표시됩니다.

=======================================================
NUGU SDK Command (Disconnected)
=======================================================
[ i] : initialize
[ d] : deinitialize
[ q] : quit
-------------------------------------------------------
Select Command >
명령 설명
i (initialize) SDK를 초기화하고 NUGU 서비스에 연결합니다.
d (deinitialize) SDK를 종료하고 NUGU 서비스 연결을 해제합니다.
q (quit) Sample application을 종료합니다.
Select Command > i
Network connection in progress.
Network connected.

NUGU 서비스 연결 성공시, 아래와 같이 음성/텍스트 및 기타 명령을 실행할 수 있는 UI로 전환됩니다.

=======================================================
NUGU SDK Command (Connected)
=======================================================
[cw] : change wakeup word
[ w] : start listening with wakeup
[ l] : start listening
[ s] : stop listening/wakeup
[ f] : finish listening
[ c] : cancel listening
[ t] : text input
[t2] : text input (ignore dialog attribute)
[ m] : set mic mute/unmute
[sm] : set speaker mute/unmute
[ +] : set speaker volume up
[ -] : set speaker volume down
[bp] : pair virtual 2nd bt device
[bu] : unpair virtual 2nd bt device
[bc] : connect virtual 2nd bt device success
[bd] : disconnect virtual 2nd bt device success
[sa] : suspend all
[ra] : restore all
-------------------------------------------------------
[ i] : initialize
[ d] : deinitialize
[ q] : quit
-------------------------------------------------------
[Volume] 50 / [MIC] ON
[PlayStack]
Select Command > 
명령 설명
cw (change wakeup word) wake-up word를 변경합니다. ("아리아" <-> "팅커벨")
w (start listening with wakeup) 정해진 Wake word("아리아")를 통해 wake-up 하기 위한 대기 상태로 진입합니다. wake-up 성공시, 음성 인식 상태로 자동 전환됩니다.
l (start listening) wake-up 없이 바로 음성 발화를 NUGU 서비스에 전달합니다. 발화가 끝나면 NUGU 서비스로부터 응답(TTS)을 받습니다.
s (stop listening/wakeup) wake-up 대기 및 음성 인식 상태를 해제합니다.
f (finish listening) 음성 발화 종료 상태를 NUGU 서비스에 전달합니다. NUGU 서비스로부터 응답(TTS)을 받습니다.
c (cancel listening) 음성 인식 상태를 해제합니다. 처리중인 directive가 있으면 중단됩니다.
t (text input) 텍스트(예: "오늘 며칠이야")를 NUGU 서비스에 전달합니다. 음성 발화와 동일하게 NUGU 서비스에서 응답을 받을 수 있습니다.
t2 (text input (ignore dialog attribute)) 위 text input 명령과 동일하나, DM 상황에서도 새로운 Context에 대한 서비스를 요청할 수 있습니다.
m (set mic mute/unmute) mic를 ON/OFF 시킵니다. mic OFF시, wake-up 및 음성 인식은 불가능하며 텍스트 명령만 NUGU 서비스에 전달 가능합니다.
sm (set speaker mute/unmute) Speaker 출력을 ON/OFF 시킵니다.
+ (set speaker volume up) Speaker Volume을 10 증가시킵니다. (최대 100)
- (set speaker volume down) Speaker Volume을 10 감소시킵니다. (최소 0)
bp (pair virtual 2nd bt device) 가상 bluetooth 장치와 pairing 합니다.
bu (unpair virtual 2nd bt device) 가상 bluetooth 장치와의 pairing을 해제합니다.
bc (connect virtual 2nd bt device success) 가상 bluetooth 장치와 연결합니다.
bd (disconnect virtual 2nd bt device success) 가상 bluetooth 장치와의 연결을 해제합니다.
sa (suspend all) 현재 실행 중인 음성/텍스트 명령을 취소하고, NUGU 서비스로부터 응답(TTS, AudioPlayer)을 처리중이면 바로 중단시킵니다.
ra (restore all) suspend all로 중단된 서비스 중, 복원 가능한 서비스를 복원합니다.
Select Command > w
[Wakeup] wakeup detecting (아리아)...

상태가 wakeup detecting 모드로 전환된 것을 확인할 수 있습니다. 이제 "아리아" 라고 발화를 하면 아래와 같이 wakeup 되고, 자동으로 사용자 음성을 듣기 위해 Listening 모드로 전환됩니다.

[Wakeup] wakeup detected
[ASR] LISTENING (WAKE_UP_WORD)

이제 "오늘 며칠이야" 라고 발화를 하면 Recognizing으로 상태로 바뀌면서 음성 데이터를 NUGU 서비스로 전송하게 됩니다. 사용자 발화가 끝나면 NUGU 서비스로부터 응답을 받기 위해 Busy 상태로 전환됩니다.

[ASR] RECOGNIZING 
[ASR] BUSY

NUGU 서비스로부터 응답이 오면 발화에 대한 인식 결과를 보여주고 해당 TTS를 출력합니다.

[ASR] onComplete > 오늘 며칠이야
[ASR] IDLE
[TTS] TEXT > 오늘은 1월 7일 목요일입니다. 
[TTS] PLAYING...
[TTS] PLAYING FINISHED
Clone this wiki locally