Skip to content

Commit

Permalink
Merge pull request #98 from ROBERT-MCDOWELL/v2.0
Browse files Browse the repository at this point in the history
fix conf inversion, added BobRoss in fine-tuned
  • Loading branch information
DrewThomasson authored Dec 22, 2024
2 parents 82793bd + 1439306 commit fdeb5f4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
6 changes: 3 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ def main():
help='Top-p sampling. Lower values mean more likely outputs and increased audio generation speed. Default to 0.8')
parser.add_argument(options[15], type=float, default=1.0,
help='Speed factor for the speech generation. Default to 1.0')
parser.add_argument(options[16], type=str, default=default_fine_tuned,
parser.add_argument(options[16], action='store_true',
help='Enable splitting text into sentences. Default to False.')
parser.add_argument(options[17], type=str, default=default_fine_tuned,
help='Name of the fine tuned model. Optional, uses the standard model according to the TTS engine and language.')
parser.add_argument(options[17], action='store_true',
help='Enable splitting text into sentences. Default to False.')
parser.add_argument(options[18], action='version',version=f'ebook2audiobook version {version}',
help='Show the version of the script and exit')

Expand Down
5 changes: 5 additions & 0 deletions lib/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@
"lang": "eng",
"repo": "drewThomasson/fineTunedTTSModels/xtts-v2/eng/DavidAttenborough",
"voice": os.path.abspath(os.path.join("voices", "eng", "elder", "male", "DavidAttenborough_24khz.wav"))
},
"BobRoss": {
"lang": "eng",
"repo": "drewThomasson/fineTunedTTSModels/xtts-v2/eng/BobRoss",
"voice": os.path.abspath(os.path.join("voices", "eng", "adult", "male", "BobRoss_24khz.wav"))
}
},
"fairseq": {
Expand Down
26 changes: 19 additions & 7 deletions lib/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,8 @@ def convert_chapters_to_audio(session):
'''
if session['metadata']['language'] in language_xtts:
params['tts_model'] = 'xtts'
print(f"Loading TTS {params['tts_model']} model...")
if session['custom_model'] is not None:
print(f"Loading TTS {params['tts_model']} model from {session['custom_model']}...")
model_path = os.path.join(session['custom_model'], 'model.pth')
config_path = os.path.join(session['custom_model'],'config.json')
vocab_path = os.path.join(session['custom_model'],'vocab.json')
Expand All @@ -512,13 +512,14 @@ def convert_chapters_to_audio(session):
params['voice_file'] = session['voice_file'] if session['voice_file'] is not None else voice_path
params['gpt_cond_latent'], params['speaker_embedding'] = params['tts'].get_conditioning_latents(audio_path=[params['voice_file']])
else:
print(f"Loading TTS {params['tts_model']} model from {models[params['tts_model']][session['fine_tuned']]['repo']}...")
params['tts'] = XTTS(models[params['tts_model']][session['fine_tuned']]['repo'])
params['voice_file'] = session['voice_file'] if session['voice_file'] is not None else models[params['tts_model']][session['fine_tuned']]['voice']
params['tts'].to(session['device'])
else:
params['tts_model'] = 'fairseq'
print(f"Loading TTS {params['tts_model']} model...")
model_repo = models[params['tts_model']][session['fine_tuned']]['repo'].replace("[lang]", session['metadata']['language'])
print(f"Loading TTS {model_repo} model from {model_repo}...")
params['tts'] = XTTS(model_repo)
params['voice_file'] = session['voice_file'] if session['voice_file'] is not None else models[params['tts_model']][session['fine_tuned']]['voice']
params['tts'].to(session['device'])
Expand Down Expand Up @@ -1397,6 +1398,12 @@ async def change_gr_custom_model_file(custom_model_file, session_id):
yield gr.update(), gr.update(), gr.update(value=f'Error: {str(e)}')
return

def change_gr_fine_tuned(fine_tuned):
visible = False
if fine_tuned == 'std':
visible = True
return gr.update(visible=visible)

def change_gr_data(data):
data['event'] = 'change_data'
return data
Expand Down Expand Up @@ -1492,16 +1499,21 @@ def submit_convert_btn(
inputs=gr_audiobooks_ddn,
outputs=[gr_audiobook_link, gr_audio_player, gr_audio_player]
)
gr_custom_model_list.change(
fn=change_gr_custom_model_list,
inputs=[gr_custom_model_list],
outputs=[gr_fine_tuned]
)
gr_custom_model_file.change(
fn=change_gr_custom_model_file,
inputs=[gr_custom_model_file, gr_session],
outputs=[gr_fine_tuned, gr_custom_model_list, gr_conversion_progress]
)
gr_custom_model_list.change(
fn=change_gr_custom_model_list,
inputs=gr_custom_model_list,
outputs=gr_fine_tuned
)
gr_fine_tuned.change(
fn=change_gr_fine_tuned,
inputs=gr_fine_tuned,
outputs=gr_group_custom_model
)
gr_session.change(
fn=change_gr_data,
inputs=gr_data,
Expand Down

0 comments on commit fdeb5f4

Please sign in to comment.