class Recorder
The recorder can record audio from the microphone and encode the audio into wav or amr format.
class audio.Recorder
Constructors
Methods
- Recorder.record(uri: str, time: int, sync=True)
Record audio from microphone to file.
- Parameters:
uri (str) – The uri of the audio file. e.g. “file://flash/test.amr”, “file:///sd/test.wav”.
time (int) – The duration of the recording, The unit is seconds.
sync (bool) – Whether to record synchronously.
UIFLOW2:


- Recorder.create_pcm_buf(time) bytearray
Create a buffer to store the audio data. The audio data is in PCM format.
The length of the data buffer is \(sample * bits * time / 8\)
- Parameters:
time (int) – The duration of the recording, The unit is seconds.
- Returns:
The buffer to store the audio data.
UIFLOW2:

- Recorder.record_into(buf, sample=8000, bits=16, stereo=False, sync=True)
Play the raw audio data.
- Parameters:
UIFLOW2:

- Recorder.pause()
Pause the Recorder.
UIFLOW2:

- Recorder.resume()
Resume the Recorder.
UIFLOW2:

- Recorder.stop()
Stop the Recorder.
UIFLOW2:

- Recorder.rms() float
Get the root mean square of the audio data.
- Returns:
The root mean square of the audio data. The unit is dB.
UIFLOW2:

- Recorder.volume() int
Get the volume of the audio data.
- Returns:
The volume of the audio data. The range is 0-100.
UIFLOW2:



