-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactoring code and setting up api server
- Loading branch information
Aadesh Kulkarni
authored and
Aadesh Kulkarni
committed
Jan 10, 2024
1 parent
5ac164f
commit 7042e05
Showing
4 changed files
with
54 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import whisper | ||
from whisper import utils | ||
|
||
|
||
def generate_subtitles(input_file_path, output_type, output_file_path, output_file_name): | ||
model = whisper.load_model("tiny") | ||
result = model.transcribe(input_file_path) | ||
writer = utils.get_writer(output_type, output_file_path) | ||
writer_args = { | ||
"highlight_words": False, | ||
"max_line_count": None, | ||
"max_line_width": None, | ||
"max_words_per_line": None, | ||
} | ||
writer(result, output_file_name, **writer_args) | ||
output_path = f"{output_file_path}/{output_file_name}.{output_type}" | ||
print("⚡️ Success! ⚡️ Subtitles have been generated @ "+output_path) | ||
return output_path |