class Recorder
录音器可以从麦克风录制音频,并将音频编码为 wav 或 amr 格式。
class audio.Recorder
构造函数
Methods
- Recorder.record(uri: str, time: int, sync=True)
从麦克风录制音频到文件。
- 参数:
uri (str) – 音频文件的 URI。例如:”file://flash/test.amr”、”file:///sd/test.wav”。
time (int) – 录音的持续时间,单位为秒。
sync (bool) – 是否同步录制。
UiFlow2:


- Recorder.create_pcm_buf(time) bytearray
创建一个缓冲区来存储音频数据。音频数据为 PCM 格式。
数据缓冲区的长度为:\(sample * bits * time / 8\)。
- 参数:
time (int) – 录音的持续时间,单位为秒。
- 返回:
用于存储音频数据的缓冲区。
UiFlow2:

- Recorder.record_into(buf, sample=8000, bits=16, stereo=False, sync=True)
播放原始音频数据。
- 参数:
UiFlow2:

- Recorder.pause()
暂停录制器。
UiFlow2:

- Recorder.resume()
恢复录音器。
UiFlow2:

- Recorder.stop()
停止录制器。
UiFlow2:





