Gradio callback to clone voice using text and optional prompt speech. - text: The input text to be synthesised. - prompt_text: Additional textual info for the prompt (optional). - prompt_wav_upload/prompt_wav_record: Audio files used as reference.
(text, prompt_text, prompt_wav_upload, prompt_wav_record)
| 98 | |
| 99 | # Define callback function for voice cloning |
| 100 | def voice_clone(text, prompt_text, prompt_wav_upload, prompt_wav_record): |
| 101 | """ |
| 102 | Gradio callback to clone voice using text and optional prompt speech. |
| 103 | - text: The input text to be synthesised. |
| 104 | - prompt_text: Additional textual info for the prompt (optional). |
| 105 | - prompt_wav_upload/prompt_wav_record: Audio files used as reference. |
| 106 | """ |
| 107 | prompt_speech = prompt_wav_upload if prompt_wav_upload else prompt_wav_record |
| 108 | prompt_text_clean = None if len(prompt_text) < 2 else prompt_text |
| 109 | |
| 110 | audio_output_path = run_tts( |
| 111 | text, |
| 112 | model, |
| 113 | prompt_text=prompt_text_clean, |
| 114 | prompt_speech=prompt_speech |
| 115 | ) |
| 116 | return audio_output_path |
| 117 | |
| 118 | # Define callback function for creating new voices |
| 119 | def voice_creation(text, gender, pitch, speed): |