SDK สำหรับ TESAIoT Dev Kit
คู่มืออ้างอิง API และ Tutorial (ModusToolbox)
Toggle main menu visibility
Loading...
Searching...
No Matches
voice_capture.h
Go to the documentation of this file.
1
/*******************************************************************************
2
* File Name: voice_capture.h
3
*
4
* Description: Microphone capture → `bento.voice.chunk` NUS event emitter.
5
*
6
* STUB. The real I²S mic capture path is not yet wired (the
7
* AI Kit / Eva Kit PDM-PCM pipeline lands in a follow-up
8
* change). For now the stub emits a single synthetic 1-second
9
* silence clip split across `bento.voice.chunk` frames so the
10
* desktop side can validate its end-to-end parser before a
11
* real mic is hooked up.
12
*
13
* Shape of each outbound frame:
14
* {"cmd":"bento.voice.chunk","id":"<clip>",
15
* "chunk_index":0,"pcm_base64":"<b64>",
16
* "sample_rate":16000,"final":false}
17
* The last frame in a clip carries `"final":true` with an
18
* empty pcm_base64.
19
*
20
* Control entry points:
21
* voice_capture_start(id, sample_rate)
22
* voice_capture_stop()
23
*
24
******************************************************************************/
25
26
#ifndef VOICE_CAPTURE_H
27
#define VOICE_CAPTURE_H
28
29
#include <stdbool.h>
30
#include <stddef.h>
31
#include <stdint.h>
32
33
#ifdef __cplusplus
34
extern
"C"
{
35
#endif
36
37
/* Default sample rate reported in `bento.voice.chunk`. Matches the planned
38
* PDM decimation target and the desktop TTS output rate. Real capture
39
* paths may override when they land. */
40
#define VOICE_CAPTURE_DEFAULT_SAMPLE_RATE_HZ (16000U)
41
42
/* Number of audio samples carried per outbound chunk. 1600 samples at
43
* 16 kHz = 100 ms, which is small enough that the BLE link can keep up
44
* over a typical 244-byte NUS MTU without backpressure. */
45
#define VOICE_CAPTURE_SAMPLES_PER_CHUNK (1600U)
46
47
/* Start mic capture. `id` is the caller-supplied clip identifier that
48
* travels on every outbound `bento.voice.chunk` frame (typically matches
49
* what the desktop will see echoed back through STT). `sample_rate_hz`
50
* is advisory — the stub ignores it and uses the default.
51
*
52
* Returns 0 on success, -1 if capture was already running or if no
53
* link is available. */
54
int
voice_capture_start
(
const
char
*
id
, uint32_t sample_rate_hz);
55
56
/* Stop mic capture. Idempotent. Emits a final `"final":true` chunk if a
57
* capture is active, so the desktop side can close out its accumulator. */
58
void
voice_capture_stop
(
void
);
59
60
/* True iff a capture is currently running. Exposed so the UI page can
61
* toggle its mic-button label. */
62
bool
voice_capture_is_running
(
void
);
63
64
#ifdef __cplusplus
65
}
66
#endif
67
68
#endif
/* VOICE_CAPTURE_H */
voice_capture_is_running
bool voice_capture_is_running(void)
คืน true ก็ต่อเมื่อมีการบันทึกทำงานอยู่ ใช้กับป้ายปุ่มไมโครโฟนและเป็นตัวกันก่อนเริ่ม ไม่มีผู้เรียกที่...
voice_capture_stop
void voice_capture_stop(void)
หยุดแบบ idempotent ส่ง chunk สุดท้ายที่มี "final":true ออกไปถ้ามีการบันทึกทำงานอยู่
voice_capture_start
int voice_capture_start(const char *id, uint32_t sample_rate_hz)
เริ่มการบันทึกเสียง (ซึ่งเป็น stub) ส่งความเงียบหนึ่งวินาทีออกไปแบบซิงโครนัส — ผู้เรียกจะถูกบล็อก
dist
ble_nus
include
voice_capture.h
Generated by
1.18.0