|
|
|
from pydub import AudioSegment |
|
|
|
|
|
import concurrent.futures |
|
from utils import get_output_path |
|
|
|
|
|
|
|
def dub_task(sub, i): |
|
print(f"{i}/{len(subs_adjusted)}") |
|
try: |
|
return dub_line_ram(sub) |
|
|
|
except Exception as e: |
|
print(e) |
|
with open(f"output/errors/{i}-rip.txt", 'w') as f: |
|
f.write(e) |
|
|
|
|
|
|
|
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) |
|
|