レコーダーエンジン¶
Recorder Engine
Recorder Engine APIは、音声録音を容易にする一連の関数です。 APIは音声アクティビティ検出と統合されており、VADを有効または無効にして着信オーディオストリームを制御するオプションを提供します。 Recorder Engineには、AMRまたはAMRWB形式を使用してオーディオストリームをエンコードする機能も含まれています。
The Recorder Engine API is a set of functions to facilitate voice recording. The API is integrated with Voice Activity Detection, providing options to enable and disable VAD to control the incoming audio stream. The Recorder Engine also includes possibility to encode the audio stream using AMR or AMRWB formats.
APIリファレンス¶
API Reference
関数¶
Functions
- 
esp_err_t 
rec_engine_create(rec_config_t *cfg)¶ パラメータに従ってレコーダーエンジンを作成します。
Create recorder engine according to parameters.
- Note
 - デフォルトでは、サンプルレートは16k、1チャネル、16ビットです。 この関数が完了すると、rec_openコールバックがトリガーされます。
  
Sample rate is 16k, 1 channel, 16bits, by default. Upon completion of this function rec_open callback will be triggered.
 - Return
 - 0: 成功
  
0: Success
 - -1: エラー
  
-1: Error
 
- 0: 成功
  
 - Parameters
 cfg: 詳細については、rec_config_t構造体を参照してくださいcfg: See rec_config_t structure for additional details
- 
int 
rec_engine_data_read(uint8_t *buffer, int buffer_size, int waiting_time)¶ REC_EVENT_VAD_STARTの後に音声データを読み取ります。
Read voice data after REC_EVENT_VAD_START.
- Return
 - -2 : 読み取りのタイムアウト
  
-2 : timeout of read
 - -1 : パラメータが無効であるか、タスクが実行されていません。
  
-1 : parameters invalid or task not running.
 - 0 : 最後の音声ブロック。
  
0 : last voice block.
 - その他: 音声ブロックインデックス。
  
others: voice block index.
 
- -2 : 読み取りのタイムアウト
  
 - Parameters
 buffer: データポインタbuffer: data pointerbuffer_size: バッファのサイズ。REC_ONE_BLOCK_SIZEと同じである必要があります。buffer_size: Size of buffer, must be equal to REC_ONE_BLOCK_SIZE.waiting_time: データ読み取りのタイムアウト。 REC_ONE_BLOCK_SIZEのデフォルト時間は100msであり、100msより大きいことをお勧めします。waiting_time: Timeout for reading data. Default time of REC_ONE_BLOCK_SIZE is 100ms, larger than 100ms is recommended.
- 
esp_err_t 
rec_engine_detect_suspend(rec_voice_suspend_t flag)¶ vadによる音声検出を一時停止または有効にします。
Suspend or enable voice detection by vad.
- Return
 - 0: 成功
  
0: Success
 - -1: エラー
  
-1: Error
 
- 0: 成功
  
 - Parameters
 flag: REC_VOICE_SUSPEND_ON:音声検出が一時停止されています REC_VOICE_SUSPEND_OFF:音声検出が一時停止されていませんflag: REC_VOICE_SUSPEND_ON: Voice detection is suspended REC_VOICE_SUSPEND_OFF: Voice detection is not suspended
- 
esp_err_t 
rec_engine_trigger_start(void)¶ 強制的に録音を開始します。
Start recording by force.
- Return
 - 0: 成功
  
0: Success
 - -1: エラー
  
-1: Error
 
- 0: 成功
  
 
- 
esp_err_t 
rec_engine_trigger_stop(void)¶ 強制的に録音を停止します。
Stop recording by force.
- Return
 - 0: 成功
  
0: Success
 - -1: エラー
  
-1: Error
 
- 0: 成功
  
 
- 
esp_err_t 
rec_engine_destroy(void)¶ レコーダエンジンを破壊します。
Destroy the recorder engine.
- Note
 - この関数が完了すると、rec_closeコールバックがトリガーされます。
  
Upon completion of this function rec_close callback will be triggered.
 - Return
 - 0: 成功
  
0: Success
 - -1: エラー
  
-1: Error
 
- 0: 成功
  
 
- 
esp_err_t 
rec_engine_vad_enable(bool vad_enable)¶ VAD(音声アクティビティ検出)を無効または有効にします。
Disable or enable the VAD(voice activity detection).
- Note
 - デフォルトでvadを有効にします。 使用法:
rec_engine_trigger_startの前にこの関数を呼び出して音声アクティビティの検出を無効にします。rec_engine_trigger_stopの後にこの関数を呼び出して音声アクティビティの検出を有効にします。 音声アクティビティの検出を無効にしても、rec_engine_trigger_startおよびrec_engine_trigger_stopが呼び出されると、REC_EVENT_VAD_STARTおよびREC_EVENT_VAD_STOPイベントが通知されます。Enable vad by default. Usage: Call this function before
rec_engine_trigger_startto disable voice activity detection, Call this funciton afterrec_engine_trigger_stopto enable voice activity detection. Even if disable voice activity detection, theREC_EVENT_VAD_STARTandREC_EVENT_VAD_STOPevents still notified whenrec_engine_trigger_startandrec_engine_trigger_stopcalled. - Return
 - 0: 成功
  
0: Success
 - -1: エラー
  
-1: Error
 
- 0: 成功
  
 - Parameters
 vad_enable: trueはvadを有効にし、falseはvadを無効にしますvad_enable: true is enable vad, false disable vad
- 
esp_err_t 
rec_engine_enc_enable(bool enc_enable)¶ レコーダのエンコーディングを有効にするかどうか。
Enable the recoder encoding, or not.
- Note
 support_encodingを設定する必要があり、rec_engine_enc_enableを使用できます。 デフォルトでエンコードを無効にします。support_encodingmust be set,rec_engine_enc_enablecan be used. Disable encoding by default.- Return
 - 0: 成功
  
0: Success
 - -1: エラー
  
-1: Error
 
- 0: 成功
  
 - Parameters
 enc_enable: trueはエンコードを有効にし、falseは無効にします。enc_enable: true is enable encoding, false is disable.
- 
esp_err_t 
rec_engine_enc_data_read(uint8_t *buffer, int buffer_size, int waiting_time, int *out_size)¶ REC_EVENT_VAD_STARTの後に音声データを読み取ります。
Read voice data after REC_EVENT_VAD_START.
- Note
 support_encodingとrec_engine_enc_enableを設定する必要があります。support_encodingandrec_engine_enc_enablemust be set.- Return
 - -2 : 読み取りのタイムアウト
  
-2 : timeout of read
 - -1 : パラメータが無効であるか、エンコードモードではありません。
  
-1 : parameters invalid or not encoding mode.
 - 0 : 成功
  
0 : success.
 - その他: 音声ブロックインデックス。
  
others: voice block index.
 
- -2 : 読み取りのタイムアウト
  
 - Parameters
 buffer: データポインタbuffer: data pointerbuffer_size: バッファのサイズ。buffer_size: Size of buffer.waiting_time: データ読み取りのタイムアウト。waiting_time: Timeout for reading data.out_size: バッファの有効なサイズ。out_size: Valid size of buffer.
- 
esp_err_t 
rec_engine_mute_enable(bool mute_enable)¶ レコーダのミュートを有効にするかどうか。
Enable the recoder mute, or not.
- Note
 - ミュートを有効にすると、データがバッファーをいっぱいにしないため、
rec_engine_enc_data_readとrec_engine_data_readがブロックされます。if enable mute, no data fill the buffer, so the
rec_engine_enc_data_readandrec_engine_data_readwill be blocked. - Return
 - 0: 成功
  
0: Success
 - -1: エラー
  
-1: Error
 
- 0: 成功
  
 - Parameters
 mute_enable: trueはミュートですが、falseはミュートではありません。mute_enable: true is mute, false is not.
- 
esp_err_t 
rec_engine_get_wakeup_stat(bool *wakeup_start_t)¶ レコーダーエンジンのウェイクアップ状態を取得します。
Get recorder engine wakeup state.
- Return
 - 0: 成功
  
0: Success
 - -1: エラー
  
-1: Error
 
- 0: 成功
  
 - Parameters
 wakeup_start_t: trueはWAKEUP_STARTであり、falseはそうではありません。wakeup_start_t: true is WAKEUP_START, false is not.
構造体¶
Structures
- 
struct 
rec_config_t¶ レコーダ構成パラメーター
recorder configuration parameters
Public Members
- 
int 
one_frame_duration_ms¶ 1フレームの長さ(オプション)
Duration of one frame (optional)
- 
int 
sensitivity¶ 応答精度率感度用。 デフォルト0:90%、1:95%
For response accuracy rate sensitivity. Default 0: 90%, 1: 95%
- 
int 
vad_off_delay_ms¶ 音声が検出されない場合に停止するためのVadoff遅延
Vad off delay to stop if no voice is detected
- 
int 
wakeup_time_ms¶ 目覚めの時間
Time of wakeup
- 
bool 
support_encoding¶ データのエンコードをサポート
Support encoding data
- 
const char *
extension¶ エンコーディング形式。「amr」または「amrwb」のサポート
Encoding format.”amr” or “amrwb” support
- 
int 
task_core¶ コアで実行されているレコーダータスク(0または1)
Recorder task running in core (0 or 1)
- 
bool 
enable_wwe¶ Wake WordEngineを有効にするかどうか
Enable Wake Word Engine or not
- 
rec_callback 
evt_cb¶ レコーダイベントコールバック関数
Recorder event callback function
- 
void *
user_data¶ ユーザーデータへのポインター(オプション)
Pointer to user data (optional)
- 
int