File size: 3,632 Bytes
7b8af6a
 
 
 
 
81129a3
7b8af6a
82874d8
7b8af6a
 
 
bcd1b0c
 
 
 
0e01f8f
 
 
e5bae82
bcd1b0c
 
0e01f8f
7b8af6a
7f4bb9f
4faf2e9
 
12d395a
82874d8
 
4faf2e9
 
 
 
 
7d88195
7b8af6a
 
 
 
 
 
 
bcd9d0f
7b8af6a
 
 
 
 
 
 
 
 
6b587db
7b8af6a
 
 
 
 
 
 
 
 
 
 
a87c5b3
7b8af6a
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import gradio as gr
import tempfile
from TTS.utils.synthesizer import Synthesizer
from huggingface_hub import hf_hub_download

REPO_ID = "denZLS/luxembourgish-female-vits-tts"

my_title = "🇱🇺 Lëtzebuergesch Sproochsynthees mat enger Fraestëmm ! 🇱🇺"

my_description = "Female Text-to-Speech (TTS) synthesizer speaking Luxembourgish. This model is based on VITS, thanks to 🐸 [Coqui.ai](https://coqui.ai/)." 

schwäin_text = "Patrull Wëllschwäin : duerch déck an dënn."
fuuss_text = "Patrull Fuuss : rau a schlau."
wisel_text = "Patrull Wisel : ëmmer flénk."
nordwand_text = "An der Zäit hunn sech den Nordwand an d'Sonn gestridden, wie vun hinnen zwee wuel méi staark wier, wéi e Wanderer, deen an ee waarme Mantel agepak war, iwwert de Wee koum. Si goufen sech eens, datt deejéinege fir dee Stäerkste gëlle sollt, deen de Wanderer forcéiere géif, säi Mantel auszedoen. Dunn huet d'Sonn d'Loft mat hire frëndleche Strale gewiermt, a schonn no kuerzer Zäit huet de Wanderer säi Mantel ausgedoen. Do huet den Nordwand missen zouginn, datt d'Sonn vun hinnen zwee dee Stäerkste wier."

my_examples = [
    [schwäin_text],
    [fuuss_text],
    [wisel_text],
    [nordwand_text]
]

my_article = "<h3>More Infos</h3>" \
             "<table><tr>" \
             "<td><image src = 'https://www.web3.lu/wp-content/uploads/2024/07/qubit-bookcovers-200.png' alt = 'bookcovers'></td>" \
             "<td><p>User guide : 1. Click an example text below the input field and click the play button in the audio field at the right side of the screen.</p>" \
             "<p>2. Enter your own text in the input field, click the submit button, wait for the audio generation and click the play button in the audio field at the right side of the screen.</p>" \
             "<p>Technical informations about the development, the training, the model and the dataset are available on my <a href = 'https://github.com/mbarnig/TTS-for-LOD'>Github repository.</a></p>" \
             "<p> If you are interested in knowing the whole history of technology projects in relation to the Luxembourgish language, the first volume of my book Qubit Lëtzebuerg is made for you." \
             " In chapters 2.1.3. to 2.1.8. you will discover EPISTOLE-PC, CORTINA, SpellChecker, LOD, SYSTRAN, EUROTRA, CRETA, eTranslation, Google Translate, Yandex Translate, Euroscript," \
             " Wordbee, LuNa, Strips, Spellux, Spacy, CyanogenMod, Gruut, eSpeak-NG-lb, MaryLux , lb_de_fr_en_pt_COQUI_VITS_TTS, Wav2Vec-XLS-R, Coqui STT, schreimaschinn.lu, Whisper, etc." \
             " You will find all the details about this book on my website <a href = 'https://www.web3.lu'>web3.lu : Internet with a Brain.</a></p></td>" \
             "</tr></table>"

my_inputs = [
  gr.Textbox(lines=5, label="Input Text"),
]

my_outputs = gr.Audio(type="filepath", label="Output Audio")

def tts(text: str):
    best_model_path = hf_hub_download(repo_id=REPO_ID, filename="checkpoint_40000.pth") 
    config_path = hf_hub_download(repo_id=REPO_ID, filename="config.json")
    
    # init synthesizer  
    synthesizer = Synthesizer(
        best_model_path,
        config_path
    )

    # create audio file
    wavs = synthesizer.tts(text.lower())
    with tempfile.NamedTemporaryFile(suffix = ".wav", delete = False) as fp:
        synthesizer.save_wav(wavs, fp)                      
    return fp.name 
 
iface = gr.Interface(
    fn=tts, 
    inputs=my_inputs, 
    outputs=my_outputs, 
    title=my_title, 
    description = my_description, 
    article = my_article,
    examples = my_examples, 
    allow_flagging=False
)
iface.launch()