mirror of
https://github.com/huggingface/lerobot.git
synced 2026-07-23 09:46:00 +00:00
Remove variable audio recordings data types (will be converted to float32 anyway)
This commit is contained in:
@@ -23,7 +23,6 @@ class MicrophoneConfig(draccus.ChoiceRegistry, abc.ABC):
|
|||||||
microphone_index: int
|
microphone_index: int
|
||||||
sampling_rate: int | None = None
|
sampling_rate: int | None = None
|
||||||
channels: list[int] | None = None
|
channels: list[int] | None = None
|
||||||
data_type: str | None = None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def type(self) -> str:
|
def type(self) -> str:
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ class Microphone:
|
|||||||
```python
|
```python
|
||||||
from lerobot.common.robot_devices.microphones.configs import MicrophoneConfig
|
from lerobot.common.robot_devices.microphones.configs import MicrophoneConfig
|
||||||
|
|
||||||
config = MicrophoneConfig(microphone_index=0, sampling_rate=16000, channels=[1], data_type="int16")
|
config = MicrophoneConfig(microphone_index=0, sampling_rate=16000, channels=[1])
|
||||||
microphone = Microphone(config)
|
microphone = Microphone(config)
|
||||||
|
|
||||||
microphone.connect()
|
microphone.connect()
|
||||||
@@ -131,7 +131,6 @@ class Microphone:
|
|||||||
# Store the recording sampling rate and channels
|
# Store the recording sampling rate and channels
|
||||||
self.sampling_rate = config.sampling_rate
|
self.sampling_rate = config.sampling_rate
|
||||||
self.channels = config.channels
|
self.channels = config.channels
|
||||||
self.data_type = config.data_type
|
|
||||||
|
|
||||||
# Input audio stream
|
# Input audio stream
|
||||||
self.stream = None
|
self.stream = None
|
||||||
@@ -192,7 +191,7 @@ class Microphone:
|
|||||||
device=self.microphone_index,
|
device=self.microphone_index,
|
||||||
samplerate=self.sampling_rate,
|
samplerate=self.sampling_rate,
|
||||||
channels=max(self.channels) + 1,
|
channels=max(self.channels) + 1,
|
||||||
dtype=self.data_type,
|
dtype="float32",
|
||||||
callback=self._audio_callback,
|
callback=self._audio_callback,
|
||||||
)
|
)
|
||||||
# Remark : the blocksize parameter could be passed to the stream to ensure that audio_callback always receive same length buffers.
|
# Remark : the blocksize parameter could be passed to the stream to ensure that audio_callback always receive same length buffers.
|
||||||
@@ -209,6 +208,7 @@ class Microphone:
|
|||||||
self.read_queue.put(indata[:, self.channels])
|
self.read_queue.put(indata[:, self.channels])
|
||||||
|
|
||||||
def _record_loop(self, output_file: Path) -> None:
|
def _record_loop(self, output_file: Path) -> None:
|
||||||
|
# Can only be run on a single process/thread for file writing safety
|
||||||
with sf.SoundFile(
|
with sf.SoundFile(
|
||||||
output_file,
|
output_file,
|
||||||
mode="x",
|
mode="x",
|
||||||
|
|||||||
Reference in New Issue
Block a user