Skip to content

Commit

Permalink
remove debug line and add better print messages
Browse files Browse the repository at this point in the history
  • Loading branch information
lotka committed Mar 29, 2024
1 parent 3cc15f4 commit 50086f5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/subsai/models/whisper_api_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")

Expand All @@ -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)
Expand Down

0 comments on commit 50086f5

Please sign in to comment.