jbetker commited on
Commit
a8264f5
1 Parent(s): f7c8dec

more cleanup

Browse files
tortoise/eval_multiple.py DELETED
@@ -1,38 +0,0 @@
1
- import os
2
-
3
- import torchaudio
4
-
5
- from api import TextToSpeech
6
- from tortoise.utils.audio import load_audio
7
-
8
- if __name__ == '__main__':
9
- fname = 'Y:\\clips\\books2\\subset512-oco.tsv'
10
- stop_after = 128
11
- outpath_base = 'D:\\tmp\\tortoise-tts-eval\\audiobooks'
12
- outpath_real = 'D:\\tmp\\tortoise-tts-eval\\real'
13
-
14
- os.makedirs(outpath_real, exist_ok=True)
15
- with open(fname, 'r', encoding='utf-8') as f:
16
- lines = [l.strip().split('\t') for l in f.readlines()]
17
-
18
- tts = TextToSpeech()
19
- for k in range(3):
20
- outpath = f'{outpath_base}_{k}'
21
- os.makedirs(outpath, exist_ok=True)
22
- recorder = open(os.path.join(outpath, 'transcript.tsv'), 'w', encoding='utf-8')
23
- for e, line in enumerate(lines):
24
- if e >= stop_after:
25
- break
26
- transcript = line[0]
27
- path = os.path.join(os.path.dirname(fname), line[1])
28
- cond_audio = load_audio(path, 22050)
29
- torchaudio.save(os.path.join(outpath_real, os.path.basename(line[1])), cond_audio, 22050)
30
- sample = tts.tts_with_preset(transcript, [cond_audio, cond_audio], preset='standard')
31
-
32
- down = torchaudio.functional.resample(sample, 24000, 22050)
33
- fout_path = os.path.join(outpath, os.path.basename(line[1]))
34
- torchaudio.save(fout_path, down.squeeze(0), 22050)
35
-
36
- recorder.write(f'{transcript}\t{fout_path}\n')
37
- recorder.flush()
38
- recorder.close()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tortoise/sweep.py DELETED
@@ -1,65 +0,0 @@
1
- import os
2
- from random import shuffle
3
-
4
- import torchaudio
5
-
6
- from api import TextToSpeech
7
- from tortoise.utils.audio import load_audio
8
-
9
-
10
- def permutations(args):
11
- res = []
12
- k = next(iter(args.keys()))
13
- vals = args[k]
14
- del args[k]
15
- if not args:
16
- return [{k: v} for v in vals]
17
- lower = permutations(args)
18
- for v in vals:
19
- for l in lower:
20
- lc = l.copy()
21
- lc[k] = v
22
- res.append(lc)
23
- return res
24
-
25
-
26
- if __name__ == '__main__':
27
- fname = 'Y:\\clips\\books2\\subset512-oco.tsv'
28
- stop_after = 512
29
- outpath_base = 'D:\\tmp\\tortoise-tts-eval\\sweep-2'
30
- outpath_real = 'D:\\tmp\\tortoise-tts-eval\\real'
31
-
32
- arg_ranges = {
33
- 'top_p': [.8,1],
34
- 'temperature': [.8,.9,1],
35
- 'diffusion_temperature': [.8,1],
36
- 'cond_free_k': [1,2,5,10],
37
- }
38
- cfgs = permutations(arg_ranges)
39
- shuffle(cfgs)
40
-
41
- for cfg in cfgs:
42
- cfg_desc = '_'.join([f'{k}-{v}' for k,v in cfg.items()])
43
- outpath = os.path.join(outpath_base, f'{cfg_desc}')
44
- os.makedirs(outpath, exist_ok=True)
45
- os.makedirs(outpath_real, exist_ok=True)
46
- with open(fname, 'r', encoding='utf-8') as f:
47
- lines = [l.strip().split('\t') for l in f.readlines()]
48
-
49
- recorder = open(os.path.join(outpath, 'transcript.tsv'), 'w', encoding='utf-8')
50
- tts = TextToSpeech()
51
- for e, line in enumerate(lines):
52
- if e >= stop_after:
53
- break
54
- transcript = line[0]
55
- path = os.path.join(os.path.dirname(fname), line[1])
56
- cond_audio = load_audio(path, 22050)
57
- torchaudio.save(os.path.join(outpath_real, os.path.basename(line[1])), cond_audio, 22050)
58
- sample = tts.tts(transcript, [cond_audio, cond_audio], num_autoregressive_samples=32, repetition_penalty=2.0,
59
- k=1, diffusion_iterations=32, length_penalty=1.0, **cfg)
60
- down = torchaudio.functional.resample(sample, 24000, 22050)
61
- fout_path = os.path.join(outpath, os.path.basename(line[1]))
62
- torchaudio.save(fout_path, down.squeeze(0), 22050)
63
- recorder.write(f'{transcript}\t{fout_path}\n')
64
- recorder.flush()
65
- recorder.close()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tortoise/{samples_generator.py → utils/samples_generator.py} RENAMED
@@ -4,7 +4,7 @@ import os
4
 
5
  if __name__ == '__main__':
6
  result = "<html><head><title>These words were never spoken.</title></head><body><h1>Handpicked results</h1>"
7
- for fv in os.listdir('../results/favorites'):
8
  url = f'https://github.com/neonbjb/tortoise-tts/raw/main/results/favorites/{fv}'
9
  result = result + f'<audio controls="" style="width: 600px;"><source src="{url}" type="audio/mp3"></audio><br>\n'
10
 
@@ -30,7 +30,7 @@ if __name__ == '__main__':
30
  line = line + f'<td><audio controls="" style="width: 150px;"><source src="{url}" type="audio/mp3"></audio></td>'
31
  line = line + "</tr>"
32
  lines.append(line)
33
- for txt in os.listdir('../results/various/'):
34
  if 'desktop' in txt:
35
  continue
36
  line = f'<tr><td>{txt}</td>'
@@ -42,7 +42,7 @@ if __name__ == '__main__':
42
  result = result + '\n'.join(lines) + "</table>"
43
 
44
  result = result + "<h1>Longform result for all voices:</h1>"
45
- for lf in os.listdir('../results/riding_hood'):
46
  url = f'https://github.com/neonbjb/tortoise-tts/raw/main/results/riding_hood/{lf}'
47
  result = result + f'<audio controls="" style="width: 600px;"><source src="{url}" type="audio/mp3"></audio><br>\n'
48
 
 
4
 
5
  if __name__ == '__main__':
6
  result = "<html><head><title>These words were never spoken.</title></head><body><h1>Handpicked results</h1>"
7
+ for fv in os.listdir('../../results/favorites'):
8
  url = f'https://github.com/neonbjb/tortoise-tts/raw/main/results/favorites/{fv}'
9
  result = result + f'<audio controls="" style="width: 600px;"><source src="{url}" type="audio/mp3"></audio><br>\n'
10
 
 
30
  line = line + f'<td><audio controls="" style="width: 150px;"><source src="{url}" type="audio/mp3"></audio></td>'
31
  line = line + "</tr>"
32
  lines.append(line)
33
+ for txt in os.listdir('../../results/various/'):
34
  if 'desktop' in txt:
35
  continue
36
  line = f'<tr><td>{txt}</td>'
 
42
  result = result + '\n'.join(lines) + "</table>"
43
 
44
  result = result + "<h1>Longform result for all voices:</h1>"
45
+ for lf in os.listdir('../../results/riding_hood'):
46
  url = f'https://github.com/neonbjb/tortoise-tts/raw/main/results/riding_hood/{lf}'
47
  result = result + f'<audio controls="" style="width: 600px;"><source src="{url}" type="audio/mp3"></audio><br>\n'
48