Feature request: added json config
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user