catiR commited on
Commit
f0fa26d
1 Parent(s): 82bdcd7
Files changed (3) hide show
  1. app.py +78 -0
  2. scripts/__init__.py +0 -0
  3. scripts/runSQ.py +28 -11
app.py ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import subprocess
3
+ import scripts.runSQ
4
+
5
+
6
+ #https://huggingface.co/spaces/clr/prosalign/blob/main/app.py
7
+
8
+
9
+ def setup():
10
+ r0 = subprocess.run(["pwd"], capture_output=True, text=True)
11
+ print('PWD::', r0.stdout)
12
+ r1 = subprocess.run(["wget", "https://github.com/google/REAPER/archive/refs/heads/master.zip"], capture_output=True, text=True)
13
+ print(r1.stdout)
14
+ subprocess.run(["unzip", "./master.zip"])
15
+ subprocess.run(["mv", "REAPER-master", "REAPER"])
16
+ subprocess.run(["rm", "./master.zip"])
17
+ os.chdir('./REAPER')
18
+ subprocess.run(["mkdir", "build"])
19
+ os.chdir('./build')
20
+ r2 = subprocess.run(["cmake", ".."], capture_output=True, text=True)
21
+ print(r2.stdout)
22
+ r3 = subprocess.run(["make"], capture_output=True, text=True)
23
+ print(r3.stdout)
24
+
25
+ os.chdir('../..')
26
+ r9 = subprocess.run(["ls", "-la"], capture_output=True, text=True)
27
+ print('LS::', r9.stdout)
28
+
29
+
30
+ print('about to setup')
31
+ setup()
32
+
33
+
34
+ def f1(voices, sent):
35
+ one_tts = scripts.runSQ.run(sentence,voices)
36
+ return (one_tts)
37
+
38
+
39
+
40
+
41
+
42
+ bl = gr.Blocks()
43
+ with bl:
44
+
45
+
46
+ temp_sentences = ['Litlaus græn hugmynd?','Var það ekki nóg?', 'Ef svo er hvað heita þau þá?','Eru maríuhænur á Íslandi?']
47
+
48
+ voices = ['Alfur','Dora']
49
+ # currently i only get json speech marks for those two.
50
+ # supposedly they also provided for Karl, Dora, but i dont even get their wavs
51
+ # i get everyone elses wavs tho
52
+
53
+ with gr.Row():
54
+ with gr.column(scale=4):
55
+ voiceselect = gr.checkboxgroup(voices, label="TTS voice",value='Alfur')
56
+ temp_sentmenu = gr.dropdown(temp_sentences, label="Sentence")
57
+ with gr.column(scale=1:)
58
+ temp_button = gr.Button(value="A button")
59
+
60
+
61
+ tts_output = gr.Audio(interactive=False)
62
+
63
+
64
+
65
+ tmp_button.click(f1,[voiceselect,temp_sentmenu],[tts_output])
66
+
67
+
68
+ if __name__ == "__main__":
69
+ bl.launch()
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
scripts/__init__.py ADDED
File without changes
scripts/runSQ.py CHANGED
@@ -8,30 +8,41 @@ from tapi import tiro
8
  # report how many, or if 0.
9
 
10
 
11
- def run():
12
- sentence = 'hvaða sjúkdómar geta fylgt óbeinum reykingum'
13
- voices = ['Alfur','Dilja','Karl', 'Dora']
14
  # On tts.tiro.is speech marks are only available
15
  # for the voices: Alfur, Dilja, Karl and Dora.
16
 
17
- corpus_meta = 'human_data/SQL1adult_metadata.tsv'
18
- speech_dir = 'human_data/audio/squeries/'
19
- speech_aligns = 'human_data/aligns/squeries/'
20
- speech_f0 = 'human_data/f0/squeries/'
21
  align_model_path ="carlosdanielhernandezmena/wav2vec2-large-xlsr-53-icelandic-ep10-1000h"
22
 
23
- tts_dir = 'tts_data/'
24
-
 
 
25
 
26
- meta = get_recordings(sentence, corpus_meta)
27
  if meta:
28
  align_human(meta,speech_aligns,speech_dir,align_model_path)
29
  f0_human(meta, speech_f0, speech_dir, 'TODO path to reaper')
30
  if voices:
31
- get_tts(sentence,voices,tts_dir)
32
  f0_tts(sentence, voices, tts_dir, 'TODO path to reaper')
 
 
33
 
34
 
 
 
 
 
 
 
 
35
  # find all the recordings of a given sentence
36
  # listed in the corpus metadata.
37
  # sentence should be provided lowercase without punctuation
@@ -122,12 +133,16 @@ def get_tts(sentence,voices,ttsdir):
122
  dpath = sentence.replace(' ','_')[:65]
123
 
124
  no_voice = []
 
 
125
 
126
  for v in voices:
127
  wpath = f'{ttsdir}{dpath}/{v}.wav'
128
  jpath = f'{ttsdir}{dpath}/{v}.json'
129
  if not (os.path.exists(wpath) and os.path.exists(jpath)):
130
  no_voice.append(v)
 
 
131
 
132
  if no_voice:
133
  print(f'Need to generate TTS for {len(no_voice)} voices')
@@ -138,6 +153,8 @@ def get_tts(sentence,voices,ttsdir):
138
 
139
  else:
140
  print('TTS for all voices existed')
 
 
141
 
142
 
143
 
 
8
  # report how many, or if 0.
9
 
10
 
11
+ def run(sentence, voices):
12
+ #sentence = 'hvaða sjúkdómar geta fylgt óbeinum reykingum'
13
+ #voices = ['Alfur','Dilja','Karl', 'Dora']
14
  # On tts.tiro.is speech marks are only available
15
  # for the voices: Alfur, Dilja, Karl and Dora.
16
 
17
+ corpus_meta = '../human_data/SQL1adult_metadata.tsv'
18
+ speech_dir = '../human_data/audio/squeries/'
19
+ speech_aligns = '../human_data/aligns/squeries/'
20
+ speech_f0 = '../human_data/f0/squeries/'
21
  align_model_path ="carlosdanielhernandezmena/wav2vec2-large-xlsr-53-icelandic-ep10-1000h"
22
 
23
+ tts_dir = '../tts_data/'
24
+
25
+
26
+ norm_sentencd = snorm(sentence)
27
 
28
+ meta = get_recordings(norm_sentence, corpus_meta)
29
  if meta:
30
  align_human(meta,speech_aligns,speech_dir,align_model_path)
31
  f0_human(meta, speech_f0, speech_dir, 'TODO path to reaper')
32
  if voices:
33
+ temp_a_sample = get_tts(sentence,voices,tts_dir)
34
  f0_tts(sentence, voices, tts_dir, 'TODO path to reaper')
35
+
36
+ return temp_a_sample
37
 
38
 
39
+ def snorm(s):
40
+ s = ''.join([c.lower() for c in s if not unicodedata.category(c).startswith("P") ])
41
+ while ' ' in s:
42
+ s = s.replace(' ', ' ')
43
+ return s
44
+
45
+
46
  # find all the recordings of a given sentence
47
  # listed in the corpus metadata.
48
  # sentence should be provided lowercase without punctuation
 
133
  dpath = sentence.replace(' ','_')[:65]
134
 
135
  no_voice = []
136
+
137
+ temp_sample_path = ''
138
 
139
  for v in voices:
140
  wpath = f'{ttsdir}{dpath}/{v}.wav'
141
  jpath = f'{ttsdir}{dpath}/{v}.json'
142
  if not (os.path.exists(wpath) and os.path.exists(jpath)):
143
  no_voice.append(v)
144
+ if not temp_sample_path:
145
+ temp_sample_path = wpath
146
 
147
  if no_voice:
148
  print(f'Need to generate TTS for {len(no_voice)} voices')
 
153
 
154
  else:
155
  print('TTS for all voices existed')
156
+
157
+ return temp_sample_path
158
 
159
 
160