| | from gtts import gTTS |
| | from transformers import pipeline |
| | import soundfile as sf |
| | |
| | import gradio as gr |
| | narrator_en = pipeline("text-to-speech", model="facebook/mms-tts-eng" ) |
| | narrator_fr = pipeline("text-to-speech", model="facebook/mms-tts-fra") |
| |
|
| | |
| | demo = gr.Blocks(theme='NoCrypt/miku') |
| |
|
| | import soundfile as sf |
| | |
| | def gtts_func(text, lang): |
| | myobj = gTTS(text=text, lang=lang, slow=False) |
| | myobj.save("narrated_audio1.wav") |
| | return 'narrated_audio1.wav' |
| | |
| | def MMS_en_func(text): |
| | narrated_text = narrator_en(text) |
| | sf.write("narrated_audio2.wav", narrated_text["audio"][0], narrated_text["sampling_rate"]) |
| | return 'narrated_audio2.wav' |
| |
|
| | |
| | def MMS_fr_func(text): |
| | narrated_text = narrator_fr(text) |
| | sf.write("narrated_audio3.wav", narrated_text["audio"][0], narrated_text["sampling_rate"]) |
| | return 'narrated_audio3.wav' |
| |
|
| | |
| |
|
| | import joblib |
| |
|
| | languages = joblib.load('languages.joblib') |
| |
|
| |
|
| | gtts_iface = gr.Interface(fn = gtts_func, |
| | inputs = [gr.Textbox(label="Text", |
| | lines=6), gr.Dropdown(choices= languages, label="language")], |
| | outputs = 'audio', |
| | cache_examples = True, |
| | title = 'Text-to-speech gtts Application', |
| | description = 'This app allows you to narrate any english text by using gtts library' |
| |
|
| | ) |
| |
|
| | |
| | mms_en_iface = gr.Interface(fn = MMS_en_func, |
| | inputs = gr.Textbox(label="Text", |
| | lines=6), |
| | outputs = 'audio', |
| | title = 'MMS english Text-to-speech Application', |
| | description = 'This app allows you to narrate any english text by using MMS english text-to-speech of facebook' |
| |
|
| | ) |
| | |
| | mms_fr_iface = gr.Interface(fn = MMS_fr_func, |
| | inputs = gr.Textbox(label="Text", |
| | lines=6), |
| | outputs = 'audio', |
| | title = 'MMS french Text-to-speech Application', |
| | description = 'This app allows you to narrate any english text by using MMS french text-to-speech of facebook' |
| |
|
| | ) |
| |
|
| |
|
| | with demo: |
| | gr.TabbedInterface( |
| | [gtts_iface, |
| | mms_en_iface, |
| | mms_fr_iface], |
| | ["gtts narrator", |
| | "MMS english narrator", |
| | "MMS french narrator"]) |
| |
|
| | demo.launch() |