Datasets:

Formats:
parquet
Languages:
English
ArXiv:
DOI:
Libraries:
Datasets
Dask
License:
daniel-treble commited on
Commit
9778af7
·
verified ·
1 Parent(s): 4a46b48

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +23 -12
README.md CHANGED
@@ -106,18 +106,29 @@ plt.show()
106
  ## Example: Accessing a reverberant speech file encoded to 8th-order Ambisonics
107
  ```python
108
  from datasets import load_dataset, Audio
109
- ds = load_dataset(
110
- "treble-technologies/Treble10-Speech",
111
- split="speech_hoa8",
112
- streaming=True,
113
- )
114
- # Keep native sampling rate (don’t ask TorchCodec to resample)
115
- ds = ds.cast_column("audio", Audio())
116
- rec = next(iter(ds))
117
- # Read the samples from the TorchCodec decoder object:
118
- samples = rec["audio"].get_all_samples()
119
- speech = samples.data.cpu().numpy() # shape: (frames, channels), HOA preserved
120
- sr = samples.sample_rate
 
 
 
 
 
 
 
 
 
 
 
121
  ```
122
 
123
  ## Example: Accessing a reverberant speech file at the microphones of a 6-channel device
 
106
  ## Example: Accessing a reverberant speech file encoded to 8th-order Ambisonics
107
  ```python
108
  from datasets import load_dataset, Audio
109
+ import io, soundfile as sf
110
+
111
+ # Load dataset in streaming mode
112
+ ds = load_dataset("treble-technologies/Treble10-Speech", split="speech_hoa8", streaming=True)
113
+
114
+ # Disable automatic decoding (we'll do it manually)
115
+ ds = ds.cast_column("audio", Audio(decode=False))
116
+
117
+ # Get one sample from the iterator
118
+ sample = next(iter(ds))
119
+
120
+ # Fetch raw audio bytes
121
+ audio_bytes = sample["audio"]["bytes"]
122
+
123
+ # Some older datasets may not have "bytes", so fall back to reading from the file
124
+ if audio_bytes is None:
125
+ # Use huggingface's file object directly
126
+ with sample["audio"]["path"].open("rb") as f:
127
+ audio_bytes = f.read()
128
+
129
+ # Decode the HOA audio directly from memory
130
+ rir_hoa, sr = sf.read(io.BytesIO(audio_bytes))
131
+ print(f"Loaded HOA audio: shape={rir_hoa.shape}, sr={sr}")
132
  ```
133
 
134
  ## Example: Accessing a reverberant speech file at the microphones of a 6-channel device