File size: 3,490 Bytes
f0fa26d
51c86c4
f0fa26d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53792d8
13fa91a
0d67145
53792d8
3948240
f0fa26d
 
53792d8
 
 
28363d1
53792d8
f0fa26d
 
 
0d67145
a894787
f0fa26d
 
 
 
a894787
f0fa26d
a4ed697
366ecce
f0fa26d
2dfee05
53792d8
2dfee05
53792d8
 
28363d1
2dfee05
 
28363d1
a4ed697
53792d8
 
2dfee05
f0fa26d
 
53792d8
 
3948240
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53792d8
 
3948240
f0fa26d
 
 
 
 
 
 
 
 
 
 
 
 
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import gradio as gr
import subprocess, os
import scripts.runSQ


#https://huggingface.co/spaces/clr/prosalign/blob/main/app.py


def setup():
    r0 = subprocess.run(["pwd"], capture_output=True, text=True)
    print('PWD::', r0.stdout)
    r1 = subprocess.run(["wget", "https://github.com/google/REAPER/archive/refs/heads/master.zip"], capture_output=True, text=True)
    print(r1.stdout)
    subprocess.run(["unzip", "./master.zip"])
    subprocess.run(["mv", "REAPER-master", "REAPER"])
    subprocess.run(["rm", "./master.zip"])
    os.chdir('./REAPER')
    subprocess.run(["mkdir", "build"])
    os.chdir('./build')
    r2 = subprocess.run(["cmake", ".."], capture_output=True, text=True)
    print(r2.stdout)
    r3 = subprocess.run(["make"], capture_output=True, text=True)
    print(r3.stdout)
    
    os.chdir('../..')
    r9 = subprocess.run(["ls", "-la"], capture_output=True, text=True)
    print('LS::', r9.stdout)

                        
print('about to setup')
setup()


def f1(voices, sent, indices):
    #tts_audio, tts_score, graph = scripts.runSQ.run(sent, voices, indices)
    tts_audio, tts_score, tts_fig_p, mid_fig_p, bad_fig_p, tts_fig_e, fig_mid_e, fig_bad_e = scripts.runSQ.run(sent, [voices], indices)
    score_report = f'Difference from TTS to real speech: {round(tts_score,2)}'
    return (tts_audio, score_report, tts_fig_p, mid_fig_p, bad_fig_p, tts_fig_e, fig_mid_e, fig_bad_e)


def label_indices(sentence):
    sentence = scripts.runSQ.snorm(sentence)
    sentence = sentence.split(' ')
    labelled = [(f'{word} {i+1} ', str(i+1)) for i, word in enumerate(sentence)]
    return labelled



temp_sentences = scripts.runSQ.create_temp_sent_list()

bl = gr.Blocks()
with bl:


    #temp_sentences = ['Litlaus græn hugmynd?','Var það ekki nóg?', 'Ef svo er hvað heita þau þá?','Eru maríuhænur á Íslandi?']
    
    voices = ['Dilja_v2', 'Alfur_v2', 'Dilja', 'Alfur', 'Bjartur', 'Rosa', 'Karl', 'Dora']

    
    #with gr.Row():
        #with gr.Column(scale=4):
    temp_sentmenu = gr.Dropdown(temp_sentences, label="Sentence")
        #voiceselect = gr.CheckboxGroup(voices, label="TTS voice",value='Alfur')

    marked_sentence = gr.HighlightedText(interactive=False,label="Word selection key",color_map = {str(i):"#dcfce7" for i in range(333)})

    with gr.Row():
        spanselect = gr.Textbox(value='1-3',label="Select words",info='Enter the index of the word(s) to analyse, according to the key above. It can be a single word: 4 or a span of words separated by a dash: 2-3')
        voiceselect = gr.Radio(voices, label="TTS voice",value='Alfur_v2')

        #with gr.Column(scale=1):
        temp_button = gr.Button(value="Run with selected options")
    
    
    tts_output = gr.Audio(interactive=False)
    report_score = gr.Markdown('Difference from TTS to real speech:')
    
    with gr.Tabs():
        with gr.TabItem("Pitch"):
    
            pl1 = gr.Plot()
            with gr.Row():
                pl2 = gr.Plot()
                pl3 = gr.Plot()
                
        with gr.TabItem("Energy"):
    
            pl4 = gr.Plot()
            with gr.Row():
                pl5 = gr.Plot()
                pl6 = gr.Plot()
        




    temp_sentmenu.input(label_indices,temp_sentmenu,marked_sentence)
    temp_button.click(f1,[voiceselect,temp_sentmenu,spanselect],[tts_output,report_score,pl1,pl2,pl3,pl4,pl5,pl6])
    
    
if __name__ == "__main__":
    bl.launch()