under bark, properly use transcribed audio if the audio wasn't actually sliced (oops)

remotes/1714475420079237655/master
mrq 2023-07-11 14:53:32 +07:00
parent a325496661
commit e2a6dc1c0a
1 changed files with 24 additions and 1 deletions

@ -192,13 +192,36 @@ if BARK_ENABLED:
candidates = []
for file in transcriptions:
result = transcriptions[file]
added = 0
for segment in result['segments']:
path = file.replace(".wav", f"_{pad(segment['id'], 4)}.wav")
# check if the slice actually exists
if not os.path.exists(f'./training/{voice}/audio/{path}'):
continue
entry = (
file.replace(".wav", f"_{pad(segment['id'], 4)}.wav"),
path,
segment['end'] - segment['start'],
segment['text']
)
candidates.append(entry)
added = added + 1
# if nothing got added (assuming because nothign was sliced), use the master file
if added == 0: # added < len(result['segments']):
start = 0
end = 0
for segment in result['segments']:
start = max( start, segment['start'] )
end = max( end, segment['end'] )
entry = (
file,
end - start,
result['text']
)
candidates.append(entry)
candidates.sort(key=lambda x: x[1])
candidate = random.choice(candidates)