File size: 1,020 Bytes
597a3c5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Formerly the prototypical file, synth. Now it's just a graveyard of functions that may never return?
from pydub import AudioSegment


import concurrent.futures
from utils import get_output_path


# This function was intended to run with multiprocessing, but Coqui won't play nice with that.
def dub_task(sub, i):
	print(f"{i}/{len(subs_adjusted)}")
	try:
		return dub_line_ram(sub)
		# empty_audio = empty_audio.overlay(line, sub.start*1000) 
	except Exception as e:
		print(e)
		with open(f"output/errors/{i}-rip.txt", 'w') as f:
			f.write(e)
		# total_errors += 1

# This may be used for multithreading?
def combine_segments():
	empty_audio = AudioSegment.silent(total_duration * 1000, frame_rate=22050)
	total_errors = 0
	for sub in subs_adjusted:
		print(f"{sub.index}/{len(subs_adjusted)}")
		try:
			segment = AudioSegment.from_file(f'output/files/{sub.index}.wav')
			empty_audio = empty_audio.overlay(segment, sub.start*1000)
		except:
			total_errors += 1
	empty_audio.export('new.wav')
	print(total_errors)