From 50086f5dce1cffee4d5c7cf5b3383b1fa82b8279 Mon Sep 17 00:00:00 2001 From: Luka Milic Date: Fri, 29 Mar 2024 12:46:54 +0000 Subject: [PATCH] remove debug line and add better print messages --- src/subsai/models/whisper_api_model.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/subsai/models/whisper_api_model.py b/src/subsai/models/whisper_api_model.py index 877af7e..4c6ff59 100644 --- a/src/subsai/models/whisper_api_model.py +++ b/src/subsai/models/whisper_api_model.py @@ -24,8 +24,6 @@ def split_filename(filepath): filename, ext = os.path.splitext(full_filename) return path,filename,ext -path,filename,ext = split_filename('/Users/luka/Desktop/y2mate.is - AGI Inches Closer 5 Key Quotes Altman Huang and The Most Interesting Year -fPzp_sdCf2Y-1080pp-1711573970.mp3') - def convert_video_to_audio_ffmpeg(video_file, output_ext="mp3"): # Construct the output file name path,filename,ext = split_filename(video_file) @@ -126,7 +124,7 @@ def transcribe(self, media_file) -> str: for i, (chunk,offset) in enumerate(chunks): chunk_path = os.path.join(TMPDIR,f'chunk_{i}.mp3') - print('Saving audio chunk {} to {}'.format(i,chunk_path)) + print('Transcribing audio chunk {}/{}'.format(i,len(chunks))) chunk.export(chunk_path, format='mp3') audio_file = open(chunk_path, "rb") @@ -140,6 +138,9 @@ def transcribe(self, media_file) -> str: response_format="srt" ) + with open(chunk_path+'.srt','w') as f: + f.write(result) + # shift subtitles by offset result = SSAFile.from_string(result) result.shift(ms=offset)