File size: 2,248 Bytes
7f0cc16
 
 
53016e3
7f0cc16
8bb6a40
7f0cc16
926be5d
53016e3
f64d86f
 
c594ce9
c3646e2
 
c594ce9
7f0cc16
 
 
 
 
2c3e79f
f47653c
cd62b9b
53016e3
f64d86f
 
 
23ce701
7f0cc16
 
adc69be
 
 
 
3729983
7f0cc16
 
 
 
5bd665a
7f0cc16
2c3e79f
7f0cc16
6cfa8d7
7f0cc16
c594ce9
 
 
2c3e79f
 
23ce701
7f0cc16
23ce701
53016e3
7f0cc16
 
 
 
f64d86f
 
adc69be
 
 
 
f64d86f
eb0f4fb
4e5413c
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 tempfile
import gradio as gr
import os
from espeak_phonemizer import Phonemizer

MAX_TXT_LEN = 325

#fonemitzador = Phonemizer("ca")

request_count = 0

def phonemiser(text, dialect):
    dialects = {"Central": "ca", "Valencian": "ca-va", "North-West": "ca-nw"}
    dialect = dialects[dialect] #Define dialect from espeak-ng-data/lang/roa/ca*
    fonemitzador = Phonemizer(dialect) #Set correct dialect for the phonemiser
    if len(text) > MAX_TXT_LEN:
        text = text[:MAX_TXT_LEN]
        print(f"Input text was cutoff since it went over the {MAX_TXT_LEN} character limit.")
    print(text)

    # synthesize

    fonemes = fonemitzador.phonemize(text, keep_clause_breakers=True)

    global request_count
    request_count += 1
    print(f"Requests: {request_count}")
    return fonemes

description="""
Transcripció fonètica en català
Transcipció fonètica per a diferents dialectes del català mitjançant eSpeak.
Phonetic transcription for different dialects of Catalan 
using eSpeak.

"""
article= ""

iface = gr.Interface(
    fn=phonemiser,
    inputs=[
        gr.Textbox(
            label="Text",
            value="L'Èlia i l'Alí a l'aula.  L'oli i l'ou.  Lulú olorava la lila.",
        ),
        gr.Dropdown(label="Dialect", choices=["Central", "Valencian", "North-West"],
        value="Central",
        )
    ],
    outputs=[
        gr.Markdown(label="Fonemes")
    ],

    title="Comparativa de síntesi lliure en català️",
    description=description,
    article=article,
    allow_flagging="never",
    layout="vertical",
    live=False,
    examples=[
        ["Duc pà sec al sac, m'assec on sóc i el suco amb suc", "ca", "ca"],
        ["Un plat pla blanc, ple de pebre negre n’era. Un plat blanc pla, ple de pebre negre està", "ca-va", "ca-va"],
        ["Visc al bosc i busco vesc i visc del vesc que busco al bosc", "ca-nw", "ca-nw"],
        ["Una polla xica, pica, pellarica, camatorta i becarica va tenir sis polls xics, pics, pellarics, camacurts i becarics. Si la polla no hagués sigut xica, pica, pellarica, camatorta i becarica, els sis polls no haurien sigut xics, pics, pellarics, camacurts i becarics.", "ca", "ca"]
    ]
)   
iface.launch(server_name="0.0.0.0", server_port=7860)