Skip to content

Commit 33c4d5d

Browse files
authored
Merge pull request #53 from rhasspy/revert-48-sentence-silence
Revert "add sentence silence"
2 parents 18a75ad + 27496a8 commit 33c4d5d

4 files changed

Lines changed: 9 additions & 37 deletions

File tree

tests/test_piper.py

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
_DIR = Path(__file__).parent
2020
_LOCAL_DIR = _DIR.parent / "local"
2121
_TIMEOUT = 60
22-
_REBASELINE = False
2322

2423

2524
@pytest.mark.asyncio
@@ -34,8 +33,6 @@ async def test_piper() -> None:
3433
"en_US-ryan-low",
3534
"--data-dir",
3635
str(_LOCAL_DIR),
37-
"--sentence-silence",
38-
"0.5",
3936
stdin=PIPE,
4037
stdout=PIPE,
4138
)
@@ -61,7 +58,7 @@ async def test_piper() -> None:
6158

6259
# Synthesize text
6360
await async_write_event(
64-
Synthesize("This is a test. This is sentence two.", voice=SynthesizeVoice("en_US-ryan-low")).event(),
61+
Synthesize("This is a test.", voice=SynthesizeVoice("en_US-ryan-low")).event(),
6562
proc.stdin,
6663
)
6764

@@ -70,6 +67,13 @@ async def test_piper() -> None:
7067
assert AudioStart.is_type(event.type)
7168
audio_start = AudioStart.from_event(event)
7269

70+
with wave.open(str(_DIR / "this_is_a_test.wav"), "rb") as wav_file:
71+
assert audio_start.rate == wav_file.getframerate()
72+
assert audio_start.width == wav_file.getsampwidth()
73+
assert audio_start.channels == wav_file.getnchannels()
74+
expected_audio = wav_file.readframes(wav_file.getnframes())
75+
expected_array = np.frombuffer(expected_audio, dtype=np.int16)
76+
7377
actual_audio = bytes()
7478
while True:
7579
event = await asyncio.wait_for(async_read_event(proc.stdout), timeout=_TIMEOUT)
@@ -86,21 +90,6 @@ async def test_piper() -> None:
8690

8791
actual_array = np.frombuffer(actual_audio, dtype=np.int16)
8892

89-
if _REBASELINE:
90-
with wave.open(str(_DIR / "this_is_a_test.wav"), "w") as wav_file:
91-
wav_file.setframerate(audio_start.rate)
92-
wav_file.setsampwidth(audio_start.width)
93-
wav_file.setnchannels(audio_start.channels)
94-
wav_file.writeframes(actual_audio)
95-
return
96-
else:
97-
with wave.open(str(_DIR / "this_is_a_test.wav"), "rb") as wav_file:
98-
assert audio_start.rate == wav_file.getframerate()
99-
assert audio_start.width == wav_file.getsampwidth()
100-
assert audio_start.channels == wav_file.getnchannels()
101-
expected_audio = wav_file.readframes(wav_file.getnframes())
102-
expected_array = np.frombuffer(expected_audio, dtype=np.int16)
103-
10493
# Less than 20% difference in length
10594
assert (
10695
abs(len(actual_array) - len(expected_array))

tests/this_is_a_test.wav

-38.5 KB
Binary file not shown.

wyoming_piper/__main__.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import asyncio
44
import json
55
import logging
6-
import signal
76
from functools import partial
87
from pathlib import Path
8+
import signal
99
from typing import Any, Dict, Set
1010

1111
from wyoming.info import Attribution, Info, TtsProgram, TtsVoice, TtsVoiceSpeaker
@@ -54,11 +54,6 @@ async def main() -> None:
5454
parser.add_argument(
5555
"--noise-w-scale", "--noise-w", type=float, help="Phoneme width noise"
5656
)
57-
parser.add_argument(
58-
"--sentence-silence",
59-
type=float,
60-
help="Seconds of silence to add after each sentence",
61-
)
6257
#
6358
parser.add_argument(
6459
"--auto-punctuation",

wyoming_piper/handler.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -233,18 +233,6 @@ async def _handle_synthesize(
233233
with wav_writer:
234234
_VOICE.synthesize_wav(text, wav_writer, syn_config)
235235

236-
if self.cli_args.sentence_silence is not None and not send_stop:
237-
# 16-bit samples for silence
238-
wav_writer.writeframes(
239-
bytes(
240-
int(
241-
_VOICE.config.sample_rate
242-
* self.cli_args.sentence_silence
243-
* 2
244-
)
245-
)
246-
)
247-
248236
output_file.seek(0)
249237

250238
wav_file: wave.Wave_read = wave.open(output_file, "rb")

0 commit comments

Comments
 (0)