Python Snippets
Set speaker volume
import navel
with navel.Robot() as robot:
print(f"Previous volume: {robot.volume}%")
robot.volume += 3
print(f"New volume: {robot.volume}%")
Stream audio to Google ASR
In your virtual environment, pip install pyaudio
.
Follow examples on Github.
You can configure what microphone to use by adding an input_device_index
in self._audio_interface.open()
.
To list the available devices with indices, use the following code.
import pyaudio
p = pyaudio.PyAudio()
for i in range(p.get_device_count()):
print(p.get_device_info_by_index(i))
Disable automatic facial expressions
Facial expressions are in auto-mode by default, which weakens your manual control. You can disable it until restart with the following code.
import navel
with navel.Robot() as robot:
robot.config_set("cns_fer_cont_t1", 0, navel.DataType.U32)
robot.config_set("cns_fer_cont_t2", 0, navel.DataType.U32)
robot.config_set("cns_fer_peak_t1", 0, navel.DataType.U32)
robot.config_set("cns_fer_peak_t2", 0, navel.DataType.U32)
robot.config_set("cns_fer_overlay_inc", 0, navel.DataType.F32)
robot.config_set("cns_fer_overlay_max", 0, navel.DataType.F32)
robot.config_set("cns_fer_overlay_peak_min", 0, navel.DataType.F32)
robot.config_set("cns_fer_peak_max", 0, navel.DataType.F32)