Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove hardcoded directory separator #19

Merged
merged 1 commit into from
Feb 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions autosub/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def ds_process_audio(ds, audio_file, file_handle):
infered_text = ds.stt(audio)

# File name contains start and end times in seconds. Extract that
limits = audio_file.split("/")[-1][:-4].split("_")[-1].split("-")
limits = audio_file.split(os.sep)[-1][:-4].split("_")[-1].split("-")

if len(infered_text) != 0:
line_count += 1
Expand Down Expand Up @@ -102,7 +102,7 @@ def main():
base_directory = os.getcwd()
output_directory = os.path.join(base_directory, "output")
audio_directory = os.path.join(base_directory, "audio")
video_file_name = input_file.split("/")[-1].split(".")[0]
video_file_name = input_file.split(os.sep)[-1].split(".")[0]
audio_file_name = os.path.join(audio_directory, video_file_name + ".wav")
srt_file_name = os.path.join(output_directory, video_file_name + ".srt")

Expand All @@ -121,7 +121,7 @@ def main():
audio_segment_path = os.path.join(audio_directory, file)

# Dont run inference on the original audio file
if audio_segment_path.split("/")[-1] != audio_file_name.split("/")[-1]:
if audio_segment_path.split(os.sep)[-1] != audio_file_name.split(os.sep)[-1]:
ds_process_audio(ds, audio_segment_path, file_handle)

print("\nSRT file saved to", srt_file_name)
Expand All @@ -132,4 +132,4 @@ def main():
os.mkdir(audio_directory)

if __name__ == "__main__":
main()
main()