mirror of
https://github.com/TaterTotterson/microWakeWord-Trainer-Nvidia-Docker.git
synced 2026-06-12 20:10:19 -06:00
Sat Samples
This commit is contained in:
@@ -18,6 +18,8 @@ parser.add_argument("--output-dir", type=str, help="Wake word output dir. Defaul
|
||||
# Personal inputs/outputs (NEW)
|
||||
parser.add_argument("--personal-dir", type=str, help="Personal WAV dir. Default: <data-dir>/personal_samples", required=False)
|
||||
parser.add_argument("--personal-output-dir", type=str, help="Personal features output dir. Default: <data-dir>/work/personal_augmented_features", required=False)
|
||||
parser.add_argument("--negative-dir", type=str, help="Reviewed negative WAV dir. Default: <data-dir>/negative_samples", required=False)
|
||||
parser.add_argument("--negative-output-dir", type=str, help="Reviewed negative features output dir. Default: <data-dir>/work/reviewed_negative_features", required=False)
|
||||
|
||||
# Dataset dirs
|
||||
parser.add_argument("--mit-rirs-16k-dir", type=str, help="MIT RIR input directory. Default: <data-dir>/training_datasets/mit_rirs_16k", required=False)
|
||||
@@ -57,6 +59,17 @@ if not args.personal_output_dir:
|
||||
else:
|
||||
args.personal_output_dir = os.path.realpath(args.personal_output_dir)
|
||||
|
||||
# Reviewed negative defaults
|
||||
if not args.negative_dir:
|
||||
args.negative_dir = os.path.join(args.data_dir, "negative_samples")
|
||||
else:
|
||||
args.negative_dir = os.path.realpath(args.negative_dir)
|
||||
|
||||
if not args.negative_output_dir:
|
||||
args.negative_output_dir = os.path.join(work_dir, "reviewed_negative_features")
|
||||
else:
|
||||
args.negative_output_dir = os.path.realpath(args.negative_output_dir)
|
||||
|
||||
# Dataset defaults
|
||||
if not args.mit_rirs_16k_dir:
|
||||
args.mit_rirs_16k_dir = os.path.join(args.data_dir, "training_datasets", "mit_rirs_16k")
|
||||
@@ -205,7 +218,7 @@ def bind_wav_generator(clips_obj: Clips, wav_dir: str):
|
||||
|
||||
clips_obj.audio_generator = types.MethodType(audio_generator_from_wavs, clips_obj)
|
||||
|
||||
def generate_feature_set(input_wav_dir: str, out_root_dir: str, label: str):
|
||||
def generate_feature_set(input_wav_dir: str, out_root_dir: str, label: str, *, remove_silence: bool = True):
|
||||
files = glob.glob(os.path.join(input_wav_dir, "*.wav"))
|
||||
if not files:
|
||||
print(f"ℹ️ No WAVs found for {label} in: {input_wav_dir} (skipping)")
|
||||
@@ -218,7 +231,7 @@ def generate_feature_set(input_wav_dir: str, out_root_dir: str, label: str):
|
||||
input_directory=input_wav_dir,
|
||||
file_pattern="*.wav",
|
||||
max_clip_duration_s=5,
|
||||
remove_silence=True,
|
||||
remove_silence=remove_silence,
|
||||
random_split_seed=10,
|
||||
split_count=0.1,
|
||||
)
|
||||
@@ -263,9 +276,12 @@ def generate_feature_set(input_wav_dir: str, out_root_dir: str, label: str):
|
||||
# Wake word generated/TTS features (existing behavior)
|
||||
generate_feature_set(args.input_dir, args.output_dir, "generated")
|
||||
|
||||
# Personal features (NEW)
|
||||
# Personal features
|
||||
generate_feature_set(args.personal_dir, args.personal_output_dir, "personal")
|
||||
|
||||
# Reviewed false-positive / hard-negative features
|
||||
generate_feature_set(args.negative_dir, args.negative_output_dir, "reviewed negatives", remove_silence=False)
|
||||
|
||||
END_TIME = datetime.now(timezone.utc).replace(microsecond=0)
|
||||
et = END_TIME - START_TIME
|
||||
print(f"\n{'=' * 80}")
|
||||
|
||||
@@ -111,6 +111,16 @@ else
|
||||
echo "ℹ️ No personal features found at ${PERSONAL_FEATURES_DIR}/training (continuing without personal weighting)"
|
||||
fi
|
||||
|
||||
# Reviewed false-positive features are optional hard negatives.
|
||||
REVIEWED_NEGATIVE_FEATURES_DIR="${WORK_DIR}/reviewed_negative_features"
|
||||
HAS_REVIEWED_NEGATIVE="false"
|
||||
if [ -d "${REVIEWED_NEGATIVE_FEATURES_DIR}/training" ] ; then
|
||||
HAS_REVIEWED_NEGATIVE="true"
|
||||
echo "✅ Found reviewed negative features: ${REVIEWED_NEGATIVE_FEATURES_DIR}/training (will weight as hard negatives)"
|
||||
else
|
||||
echo "ℹ️ No reviewed negative features found at ${REVIEWED_NEGATIVE_FEATURES_DIR}/training (continuing with stock negatives)"
|
||||
fi
|
||||
|
||||
cd "${WORK_DIR}"
|
||||
|
||||
echo "===== Starting ${TRAINING_STEPS} training steps ====="
|
||||
@@ -133,6 +143,7 @@ features:
|
||||
truth: true
|
||||
type: mmap
|
||||
__PERSONAL_FEATURE_MARKER__
|
||||
__REVIEWED_NEGATIVE_FEATURE_MARKER__
|
||||
- features_dir: __NEG_SPEECH__
|
||||
penalty_weight: 1.0
|
||||
sampling_weight: 12.0
|
||||
@@ -208,6 +219,22 @@ else
|
||||
sed -i -e "/__PERSONAL_FEATURE_MARKER__/d" "${YAML_PATH}"
|
||||
fi
|
||||
|
||||
# Insert/remove reviewed hard-negative block
|
||||
if [ "${HAS_REVIEWED_NEGATIVE}" = "true" ]; then
|
||||
reviewed_negative_block="$(cat <<EOF
|
||||
- features_dir: ${REVIEWED_NEGATIVE_FEATURES_DIR}
|
||||
penalty_weight: 1.25
|
||||
sampling_weight: 8.0
|
||||
truncation_strategy: random
|
||||
truth: false
|
||||
type: mmap
|
||||
EOF
|
||||
)"
|
||||
perl -0777 -i -pe "s#__REVIEWED_NEGATIVE_FEATURE_MARKER__#${reviewed_negative_block}#g" "${YAML_PATH}"
|
||||
else
|
||||
sed -i -e "/__REVIEWED_NEGATIVE_FEATURE_MARKER__/d" "${YAML_PATH}"
|
||||
fi
|
||||
|
||||
echo " Wrote training_parameters.yaml"
|
||||
rm -rf "${WORK_DIR}/trained_models/wakeword"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user