Use byte differences for sample matching
This commit is contained in:
parent
d53f5d5151
commit
3b9af75eec
7 changed files with 49 additions and 6 deletions
|
|
@ -92,7 +92,7 @@ COPY --from=build /home/mimic3/app/ ./
|
||||||
COPY --from=build /root/.local/share/mimic3/voices/ /usr/share/mimic3/voices/
|
COPY --from=build /root/.local/share/mimic3/voices/ /usr/share/mimic3/voices/
|
||||||
|
|
||||||
# Run test
|
# Run test
|
||||||
COPY tests/apope_sample.txt tests/apope_sample_*.wav ./tests/
|
COPY tests/* ./tests/
|
||||||
|
|
||||||
# Generate sample and check
|
# Generate sample and check
|
||||||
RUN export expected_sample="tests/apope_sample_${TARGETARCH}${TARGETVARIANT}.wav" && \
|
RUN export expected_sample="tests/apope_sample_${TARGETARCH}${TARGETVARIANT}.wav" && \
|
||||||
|
|
@ -101,7 +101,7 @@ RUN export expected_sample="tests/apope_sample_${TARGETARCH}${TARGETVARIANT}.wav
|
||||||
--voice 'en_UK/apope_low' \
|
--voice 'en_UK/apope_low' \
|
||||||
< tests/apope_sample.txt \
|
< tests/apope_sample.txt \
|
||||||
> tests/actual_sample.wav && \
|
> tests/actual_sample.wav && \
|
||||||
diff tests/actual_sample.wav "${expected_sample}"
|
tests/samples_match.sh tests/actual_sample.wav "${expected_sample}"
|
||||||
|
|
||||||
USER mimic3
|
USER mimic3
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,7 @@ RUN --mount=type=cache,id=apt-run,target=/var/cache/apt \
|
||||||
xargs apt install --yes
|
xargs apt install --yes
|
||||||
|
|
||||||
# Run test
|
# Run test
|
||||||
COPY tests/apope_sample.txt tests/apope_sample_*.wav tests/
|
COPY tests/* tests/
|
||||||
|
|
||||||
# Generate sample and check
|
# Generate sample and check
|
||||||
RUN export expected_sample="tests/apope_sample_${TARGETARCH}${TARGETVARIANT}.wav" && \
|
RUN export expected_sample="tests/apope_sample_${TARGETARCH}${TARGETVARIANT}.wav" && \
|
||||||
|
|
@ -175,7 +175,7 @@ RUN export expected_sample="tests/apope_sample_${TARGETARCH}${TARGETVARIANT}.wav
|
||||||
--voice 'en_UK/apope_low' \
|
--voice 'en_UK/apope_low' \
|
||||||
< tests/apope_sample.txt \
|
< tests/apope_sample.txt \
|
||||||
> tests/actual_sample.wav && \
|
> tests/actual_sample.wav && \
|
||||||
diff tests/actual_sample.wav "${expected_sample}"
|
tests/samples_match.sh tests/actual_sample.wav "${expected_sample}"
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
!pyinstaller/mimic3-download
|
!pyinstaller/mimic3-download
|
||||||
!tests/apope_sample.txt
|
!tests/apope_sample.txt
|
||||||
!tests/apope_sample_*.wav
|
!tests/apope_sample_*.wav
|
||||||
|
!tests/samples_match.sh
|
||||||
!voices/
|
!voices/
|
||||||
!wheels/
|
!wheels/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ COPY voices/ /root/.local/share/mimic3/voices/
|
||||||
RUN .venv/bin/mimic3-download 'en_UK/apope_low'
|
RUN .venv/bin/mimic3-download 'en_UK/apope_low'
|
||||||
|
|
||||||
# Run test
|
# Run test
|
||||||
COPY tests/apope_sample.txt tests/apope_sample_*.wav tests/
|
COPY tests/* tests/
|
||||||
|
|
||||||
# Generate sample and check
|
# Generate sample and check
|
||||||
RUN export expected_sample="tests/apope_sample_${TARGETARCH}${TARGETVARIANT}.wav" && \
|
RUN export expected_sample="tests/apope_sample_${TARGETARCH}${TARGETVARIANT}.wav" && \
|
||||||
|
|
@ -97,7 +97,7 @@ RUN export expected_sample="tests/apope_sample_${TARGETARCH}${TARGETVARIANT}.wav
|
||||||
--voice 'en_UK/apope_low' \
|
--voice 'en_UK/apope_low' \
|
||||||
< tests/apope_sample.txt \
|
< tests/apope_sample.txt \
|
||||||
> tests/actual_sample.wav && \
|
> tests/actual_sample.wav && \
|
||||||
diff tests/actual_sample.wav "${expected_sample}"
|
tests/samples_match.sh tests/actual_sample.wav "${expected_sample}"
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
!build-dist.sh
|
!build-dist.sh
|
||||||
!tests/apope_sample.txt
|
!tests/apope_sample.txt
|
||||||
!tests/apope_sample_*.wav
|
!tests/apope_sample_*.wav
|
||||||
|
!tests/samples_match.sh
|
||||||
!voices/
|
!voices/
|
||||||
!wheels/
|
!wheels/
|
||||||
!debian/control.in.*
|
!debian/control.in.*
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
!install.sh
|
!install.sh
|
||||||
!tests/apope_sample.txt
|
!tests/apope_sample.txt
|
||||||
!tests/apope_sample_*.wav
|
!tests/apope_sample_*.wav
|
||||||
|
!tests/samples_match.sh
|
||||||
!voices/
|
!voices/
|
||||||
!wheels/
|
!wheels/
|
||||||
!debian/control.in.*
|
!debian/control.in.*
|
||||||
|
|
|
||||||
40
tests/samples_match.sh
Executable file
40
tests/samples_match.sh
Executable file
|
|
@ -0,0 +1,40 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# Copyright 2022 Mycroft AI Inc.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Uses cmp to compare byte differences between two samples.
|
||||||
|
# Exits with an error if differences exceed a threshold.
|
||||||
|
#
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
if [ -z "$2" ]; then
|
||||||
|
echo 'Usage: samples_match.sh WAV1 WAV2 [threshold]';
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
wav1="$1"
|
||||||
|
wav2="$2"
|
||||||
|
threshold="${3:-5000}"
|
||||||
|
|
||||||
|
bytes_different="$(cmp -l "${wav1}" "${wav2}" | wc -l)"
|
||||||
|
|
||||||
|
if (( ${bytes_different} > ${threshold} )); then
|
||||||
|
echo "Samples differ too much (${bytes_different} > ${threshold})";
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo 'OK'
|
||||||
Loading…
Add table
Add a link
Reference in a new issue