Update: Refactored the code
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
from src.file_manager import FileManager
|
||||
from src.transcriber import Transcriber
|
||||
|
||||
|
||||
class TranscriptGenerator:
|
||||
def __init__(self):
|
||||
self.file_manager = FileManager()
|
||||
self.transcriber = Transcriber()
|
||||
|
||||
def generate(self, input_sources):
|
||||
for i, source in enumerate(input_sources):
|
||||
if source.startswith('http'):
|
||||
mp4_filename = f"audio_{i + 1}.mp4"
|
||||
wav_filename = f"audio_{i + 1}.wav"
|
||||
|
||||
self.file_manager.download_youtube_audio(source, mp4_filename)
|
||||
self.file_manager.convert_to_wav(mp4_filename, wav_filename)
|
||||
else:
|
||||
wav_filename = self.file_manager.load_local_file(source)
|
||||
|
||||
transcription = self.transcriber.transcribe(wav_filename)
|
||||
|
||||
json_output_file = f'result_{i + 1}.json'
|
||||
txt_output_file = f'transcripts_{i + 1}.txt'
|
||||
self.transcriber.save_transcript(json_output_file, txt_output_file)
|
||||
|
||||
print('Transcription generation completed.')
|
||||
Reference in New Issue
Block a user