Skip to content

Commit

Permalink
Merge pull request #302 from JarbasAl/patch-1
Browse files Browse the repository at this point in the history
fix single speaker models speaker_id arg
  • Loading branch information
synesthesiam authored Jan 22, 2024
2 parents 2fa4c2c + d43ecbc commit e5cb84c
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/python_run/piper/voice.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,25 +162,24 @@ def synthesize_ids_to_raw(
dtype=np.float32,
)

args = {
"input": phoneme_ids_array,
"input_lengths": phoneme_ids_lengths,
"scales": scales
}

if self.config.num_speakers <= 1:
speaker_id = None

if (self.config.num_speakers > 1) and (speaker_id is None):
# Default speaker
speaker_id = 0

sid = None

if speaker_id is not None:
sid = np.array([speaker_id], dtype=np.int64)
args["sid"] = sid

# Synthesize through Onnx
audio = self.session.run(
None,
{
"input": phoneme_ids_array,
"input_lengths": phoneme_ids_lengths,
"scales": scales,
"sid": sid,
},
)[0].squeeze((0, 1))
audio = self.session.run(None, args, )[0].squeeze((0, 1))
audio = audio_float_to_int16(audio.squeeze())

return audio.tobytes()

0 comments on commit e5cb84c

Please sign in to comment.