Feature request: added json config

This commit is contained in:
2023-10-10 14:17:38 +02:00
parent 101f2db788
commit e2b5ad15b4
4 changed files with 41 additions and 14 deletions
+7 -6
View File
@@ -15,9 +15,10 @@ class TranscriptGenerator:
to generate transcriptions from given input sources.
"""
def __init__(self):
def __init__(self, job_name, language_code="en"):
self.file_manager = FileManager()
self.transcriber = Transcriber()
self.transcriber = Transcriber(language_code)
self.job_name = job_name
def generate(self, input_sources: List[str]) -> None:
"""
@@ -29,15 +30,15 @@ class TranscriptGenerator:
for i, source in enumerate(input_sources):
try:
if source.startswith("http"):
mp4_filename = f"audio_{i + 1}.mp4"
wav_filename = f"audio_{i + 1}.wav"
mp4_filename = f"audio_{self.job_name}_{i + 1}.mp4"
wav_filename = f"audio_{self.job_name}_{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)
self.transcriber.transcribe(wav_filename)
json_output_file = f"result_{i + 1}.json"
txt_output_file = f"transcripts_{i + 1}.txt"
json_output_file = f"result_{self.job_name}_{i + 1}.json"
txt_output_file = f"transcripts_{self.job_name}_{i + 1}.txt"
self.transcriber.save_transcript(json_output_file, txt_output_file)
except Exception as e:
logger.exception(