Skip to content

Commit

Permalink
Allow character voices within prompts to change
Browse files Browse the repository at this point in the history
Signed-off-by: bghira <[email protected]>
  • Loading branch information
bghira committed May 2, 2023
1 parent 060b4e7 commit 7979e98
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions discord_tron_client/classes/tts/bark/torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,20 @@ def concatenate_audio_segments(audio_segments):
@staticmethod
def process_line(line, characters):
if characters is None:
logging.debug(f"No characters were given to process_line so we will just return the input line: {line}")
return line, None
logging.debug(f"We have the characters we need.")
pattern = r"\{([^}]+)\}:?"
match = re.search(pattern, line)
logging.debug(f"For line {line} we have {match} match?")
if match:
actor = match.group(1)
logging.debug(f"We found actor {actor}")
line = re.sub(pattern, "", line).strip()
logging.debug(f"Stripping the actor out of the line to: {line}")
# This can strip out "not-found" {STRINGS} so beware...
character_voice = characters.get(actor, {}).get("voice", None)
logging.debug(f"Selected character voice: {character_voice}")
else:
character_voice = None
return line, character_voice

0 comments on commit 7979e98

Please sign in to comment.