| BUILD.gn |
|
3050 |
- |
| DEPS |
|
69 |
- |
| neural_feature_extractor.cc |
|
4402 |
- |
| neural_feature_extractor.h |
|
2619 |
- |
| neural_feature_extractor_unittest.cc |
Python script used to generate the test data:
import numpy as np
from typing import List
def python_feature_extractor(time_frame: np.ndarray) -> np.ndarray:
frame_length: int = 256
sqrt_hann: np.ndarray = np.sqrt(np.hanning(frame_length))
magnitude_spectrum: np.ndarray = np.abs(np.fft.rfft(time_frame * sqrt_hann))
return np.power(magnitude_spectrum + 1e-8, 0.3)
def format_as_cpp_array(data: np.ndarray, name: str) -> str:
elements_per_line = 6
s = f"constexpr float {name}[] = {{\n "
for i, x in enumerate(data):
s += f"{x:.8f}, "
if (i + 1) % elements_per_line == 0 and i < len(data) - 1:
s += "\n "
s = s.rstrip(", ") + "\n};"
return s
# Generate two frames of white noise
np.random.seed(0) # for reproducibility
noise1: np.ndarray = np.random.uniform(-1.0, 1.0, 256)
noise2: np.ndarray = np.random.uniform(-1.0, 1.0, 256)
# Scale to match the C++ implementation's expected input range
noise1_scaled: np.ndarray = noise1 * 32768.0
noise2_scaled: np.ndarray = noise2 * 32768.0
# Python equivalent
expected_output1: np.ndarray = python_feature_extractor(noise1)
expected_output2: np.ndarray = python_feature_extractor(noise2)
print(format_as_cpp_array(noise1_scaled, "noise1_scaled"))
print(format_as_cpp_array(noise2_scaled, "noise2_scaled"))
print(format_as_cpp_array(expected_output1, "expected_output1"))
print(format_as_cpp_array(expected_output2, "expected_output2"))
|
14414 |
- |
| neural_residual_echo_estimator.proto |
|
555 |
- |
| neural_residual_echo_estimator_impl.cc |
|
16533 |
- |
| neural_residual_echo_estimator_impl.h |
|
4591 |
- |
| neural_residual_echo_estimator_impl_unittest.cc |
frame_size= |
13261 |
- |