Skip to content
This repository was archived by the owner on Oct 6, 2025. It is now read-only.

Commit e5cb84c

Browse files
authored
Merge pull request #302 from JarbasAl/patch-1
fix single speaker models speaker_id arg
2 parents 2fa4c2c + d43ecbc commit e5cb84c

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/python_run/piper/voice.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -162,25 +162,24 @@ def synthesize_ids_to_raw(
162162
dtype=np.float32,
163163
)
164164

165+
args = {
166+
"input": phoneme_ids_array,
167+
"input_lengths": phoneme_ids_lengths,
168+
"scales": scales
169+
}
170+
171+
if self.config.num_speakers <= 1:
172+
speaker_id = None
173+
165174
if (self.config.num_speakers > 1) and (speaker_id is None):
166175
# Default speaker
167176
speaker_id = 0
168177

169-
sid = None
170-
171178
if speaker_id is not None:
172179
sid = np.array([speaker_id], dtype=np.int64)
180+
args["sid"] = sid
173181

174182
# Synthesize through Onnx
175-
audio = self.session.run(
176-
None,
177-
{
178-
"input": phoneme_ids_array,
179-
"input_lengths": phoneme_ids_lengths,
180-
"scales": scales,
181-
"sid": sid,
182-
},
183-
)[0].squeeze((0, 1))
183+
audio = self.session.run(None, args, )[0].squeeze((0, 1))
184184
audio = audio_float_to_int16(audio.squeeze())
185-
186185
return audio.tobytes()

0 commit comments

Comments
 (0)